CFx SDK Documentation 2024 SP0
Loading...
Searching...
No Matches
DbSymUtl.h
Go to the documentation of this file.
1
2// Copyright (C) 2002-2022, Open Design Alliance (the "Alliance").
3// All rights reserved.
4//
5// This software and its documentation and related materials are owned by
6// the Alliance. The software may only be incorporated into application
7// programs owned by members of the Alliance, subject to a signed
8// Membership Agreement and Supplemental Software License Agreement with the
9// Alliance. The structure and organization of this software are the valuable
10// trade secrets of the Alliance and its suppliers. The software is also
11// protected by copyright law and international treaty provisions. Application
12// programs incorporating this software must include the following statement
13// with their copyright notices:
14//
15// This application incorporates Open Design Alliance software pursuant to a license
16// agreement with Open Design Alliance.
17// Open Design Alliance Copyright (C) 2002-2022 by Open Design Alliance.
18// All rights reserved.
19//
20// By use of this software, its documentation or related materials, you
21// acknowledge and accept the above terms.
23
24
25
26
27#ifndef DBSYMUTL_DEFINED
28#define DBSYMUTL_DEFINED
29
30#include "TD_PackPush.h"
31
32#include "OdString.h"
33#include "DbObjectId.h"
34#include "DbSymbolTable.h"
35#include "DbSymbolTableRecord.h"
37#include "DbDictionary.h"
38#include "DbDatabase.h"
39
40// Predefined names
41#define AC_STRING(name, val) \
42extern TOOLKIT_EXPORT_GLOBAL const OdConstString name;
43#include "StdStrings.h"
44#undef AC_STRING
45
50namespace OdDbSymUtil
51{
52 // --- DbSymbolUtilities Services ---
53
55 OdString& newName,
56 const OdString& oldName,
57 const OdDbDatabase* pDb,
58 bool allowVerticalBar = false,
59 const OdChar symSubst = L'_',
60 bool insertPrefix = true);
61
72 OdString& newName,
73 const OdString& oldName,
74 const OdDbDatabase* pDb,
75 bool allowVerticalBar = false,
76 const OdChar symSubst = L'_',
77 bool insertPrefix = true);
78
80 const OdString& name,
81 const OdDbDatabase* pDb,
82 bool allowVerticalBar = false);
83
93 const OdString& name,
94 const OdDbDatabase* pDb,
95 bool allowVerticalBar = false);
96
98 OdUInt32& maxLength,
99 OdUInt32& maxSize,
100 bool isNewName,
101 bool compatibilityMode); // true for extended names
102
104 {
107 if (!pRec.isNull())
108 {
109 return pRec->getName();
110 }
111 return OdString::kEmpty;
112 }
113
114 #define DBSYMUTL_MAKE_GETSYMBOLID_FUNC(T_TABLE) \
115 inline OdDbObjectId \
116 get ## T_TABLE ## Id(const OdString& name, const OdDbDatabase *pDb) \
117 { \
118 if (!pDb) return OdDbObjectId::kNull; \
119 OdDbSymbolTablePtr pTable = pDb->get ## T_TABLE ## TableId().safeOpenObject(); \
120 ODA_ASSERT(!pTable->isOdDbObjectIdsInFlux()); \
121 return pTable->getAt(name); \
122 }
129 //DBSYMUTL_MAKE_GETSYMBOLID_FUNC(TextStyle)
130
132 {
133 if (!pDb) return OdDbObjectId::kNull;
134 OdDbSymbolTablePtr pTable = pDb->getTextStyleTableId().safeOpenObject();
135 ODA_ASSERT(!pTable->isOdDbObjectIdsInFlux());
136 OdDbTextStyleTableRecordPtr pRec = pTable->getAt(name, OdDb::kForRead);
137
138 if (pRec.get())
139 if (!pRec->isShapeFile())
140 return pRec->objectId();
141 return OdDbObjectId::kNull;
142 }
143
146 #undef DBSYMUTL_MAKE_GETSYMBOLID_FUNC
147
149 {
150 if (!pDb) return OdDbObjectId::kNull;
152 if (!pDic.isNull())
153 {
154 ODA_ASSERT(!pDic->isOdDbObjectIdsInFlux());
155 return pDic->getAt(name);
156 }
157 return OdDbObjectId::kNull;
158 }
159
161 {
162 if (!pDb) return OdDbObjectId::kNull;
164 if (!pDic.isNull())
165 {
166 ODA_ASSERT(!pDic->isOdDbObjectIdsInFlux());
167 return pDic->getAt(name);
168 }
169 return OdDbObjectId::kNull;
170 }
171
173 {
174 if (!pDb) return OdDbObjectId::kNull;
176 if (!pDic.isNull())
177 {
178 ODA_ASSERT(!pDic->isOdDbObjectIdsInFlux());
179 return pDic->getAt(name);
180 }
181 return OdDbObjectId::kNull;
182 }
183
185 {
186 if (!pDb) return OdDbObjectId::kNull;
188 if (!pDic.isNull())
189 {
190 ODA_ASSERT(!pDic->isOdDbObjectIdsInFlux());
191 return pDic->getAt(name);
192 }
193 return OdDbObjectId::kNull;
194 }
195
197 {
198 if (!pDb) return OdDbObjectId::kNull;
200 if (!pDic.isNull())
201 {
202 ODA_ASSERT(!pDic->isOdDbObjectIdsInFlux());
203 return pDic->getAt(name);
204 }
205 return OdDbObjectId::kNull;
206 }
207
209 { return byLayerNameStr; }
210
212 { return !odStrICmp(name, linetypeByLayerName()); }
213
215 { return byBlockNameStr; }
216
218 { return !odStrICmp(name, linetypeByBlockName()); }
219
221 { return linetypeContinuousNameStr; }
222
224 { return !odStrICmp(name, linetypeContinuousName()); }
225
226 inline const OdString& layerZeroName()
227 { return layerZeroNameStr; }
228
229 inline bool isLayerZeroName(const OdString& name)
230 { return !odStrICmp(name, layerZeroName()); }
231
233 { return layerDefpointsNameStr; }
234
236 { return !odStrICmp(name, layerDefpointsName()); }
237
239 { return standardStr; }
240
242 { return standardStr; }
243
245 { return !odStrICmp(name, MLineStyleStandardName()); }
246
248 { return measurement == OdDb::kEnglish ? standardStr : metricDimStandardStr; }
249
251 { return viewportActiveNameStr; }
252
254 { return !odStrICmp(name, viewportActiveName()); }
255
257 { return !odStrICmp(name, textStyleStandardName()); }
258
262 // Returns layer Id for given name. Creates new layer if it's missing
264
266 { return version <= OdDb::vAC12 ? modelSpaceStr_R12 : modelSpaceStr; }
267
269 { return odStrICmp(pN, blockModelSpaceName(version)) == 0; }
270
272 { return version <= OdDb::vAC12 ? paperSpaceStr_R12 : paperSpaceStr; }
273
275 { return odStrICmp(pN, blockPaperSpaceName(version)) == 0; }
276
278 {
279 OdString strPaperSpaceName = OdDbSymUtil::blockPaperSpaceName(version);
280 return odStrICmp(pN.left(strPaperSpaceName.getLength()), strPaperSpaceName) == 0;
281 }
282
284 { return plotStyleNormalNameStr;}
285
287 { return standardStr; }
288
290 { return !odStrICmp(name, TableStyleStandardName()); }
291
293 { return standardStr; }
294
297
299 {
300 ODA_ASSERT_ONCE(pDb);
301 return (pDb && pDb->getMEASUREMENT() == OdDb::kMetric) ? standardMetricDictStr : standardImperialDictStr;
302 }
303
305 {
307 }
308
310 {
311 return DetailViewStyleStandardName(pDb);
312 }
313
315 {
317 }
318}
319// namespace OdDbSymUtil
320
321#include "TD_PackPop.h"
322
323#endif // DBSYMUTL_DEFINED
324
#define TOOLKIT_EXPORT
Definition: DbExport.h:40
#define DBSYMUTL_MAKE_GETSYMBOLID_FUNC(T_TABLE)
Definition: DbSymUtl.h:114
#define ODA_ASSERT_ONCE(exp)
Definition: DebugStuff.h:73
#define ODA_ASSERT(exp)
Definition: DebugStuff.h:57
#define odStrICmp
Definition: OdPlatform.h:409
unsigned int OdUInt32
wchar_t OdChar
OdResult
Definition: OdResult.h:29
bool isNull() const
Definition: BaseObjectPtr.h:86
OdDbObjectId getVisualStyleDictionaryId(bool createIfNotFound=true) const
OdDbObjectId getMLStyleDictionaryId(bool createIfNotFound=true) const
OdDbObjectId getTableStyleDictionaryId(bool createIfNotFound=true) const
OdDbObjectId getMLeaderStyleDictionaryId(bool createIfNotFound=true) const
OdDbObjectId getPlotStyleNameDictionaryId(bool createIfNotFound=true) const
static TOOLKIT_EXPORT_STATIC const OdDbObjectId kNull
Definition: DbObjectId.h:110
OdResult openObject(OdDbObjectPtr &pObj, OdDb::OpenMode openMode=OdDb::kForRead, bool openErasedOne=false) const
static OdRxObjectPtr cast(const OdRxObject *pointer)
Definition: RxObject.h:640
const T * get() const
Definition: SmartPtr.h:339
OdString left(int length) const
FIRSTDLL_EXPORT_STATIC static const OdString kEmpty
Definition: OdString.h:98
int getLength() const
Definition: OdString.h:133
GLuint const GLchar * name
Definition: gles2_ext.h:265
DwgVersion
Definition: OdaDefs.h:47
@ kDHL_CURRENT
Definition: OdaDefs.h:102
@ vAC12
Definition: OdaDefs.h:69
MeasurementValue
Definition: OdaDefs.h:442
@ kMetric
Metric system.
Definition: OdaDefs.h:444
@ kEnglish
English system.
Definition: OdaDefs.h:443
@ kForRead
Definition: DbObjectId.h:56
bool isLayerDefpointsName(const OdString &name)
Definition: DbSymUtl.h:235
const OdString & blockModelSpaceName(OdDb::DwgVersion version=OdDb::kDHL_CURRENT)
Definition: DbSymUtl.h:265
const OdString & dimStyleStandardName(OdDb::MeasurementValue measurement)
Definition: DbSymUtl.h:247
TOOLKIT_EXPORT OdResult repairPreExtendedSymbolName(OdString &newName, const OdString &oldName, const OdDbDatabase *pDb, bool allowVerticalBar=false, const OdChar symSubst=L '_', bool insertPrefix=true)
bool isViewportActiveName(const OdString &name)
Definition: DbSymUtl.h:253
OdDbObjectId getMLeaderStyleId(const OdString &name, const OdDbDatabase *pDb)
Definition: DbSymUtl.h:184
TOOLKIT_EXPORT OdResult validateSymbolName(const OdString &name, const OdDbDatabase *pDb, bool allowVerticalBar=false)
bool isBlockPaperSpaceName(const OdString &pN, OdDb::DwgVersion version=OdDb::kDHL_CURRENT)
Definition: DbSymUtl.h:274
const OdString & linetypeByBlockName()
Definition: DbSymUtl.h:214
bool isMLeaderStandardName(const OdString &name)
Definition: DbSymUtl.h:295
const OdString & viewportActiveName()
Definition: DbSymUtl.h:250
TOOLKIT_EXPORT const OdDbObjectId MLineStyleStandardId(const OdDbDatabase *pDb)
TOOLKIT_EXPORT const OdDbObjectId & dimStyleStandardId(const OdDbDatabase *pDb)
TOOLKIT_EXPORT const OdDbObjectId & textStyleStandardId(const OdDbDatabase *pDb)
OdDbObjectId getPlotstyleId(const OdString &name, const OdDbDatabase *pDb)
Definition: DbSymUtl.h:148
const OdString & plotStyleNormalName()
Definition: DbSymUtl.h:283
const OdString & linetypeByLayerName()
Definition: DbSymUtl.h:208
const OdString & SectionViewStyleStandardName(OdDbDatabase *pDb)
Definition: DbSymUtl.h:309
bool isTextStyleStandardName(const OdString &name)
Definition: DbSymUtl.h:256
const OdString & layerDefpointsName()
Definition: DbSymUtl.h:232
bool isLinetypeByBlockName(const OdString &name)
Definition: DbSymUtl.h:217
TOOLKIT_EXPORT OdResult repairSymbolName(OdString &newName, const OdString &oldName, const OdDbDatabase *pDb, bool allowVerticalBar=false, const OdChar symSubst=L '_', bool insertPrefix=true)
bool isLayerZeroName(const OdString &name)
Definition: DbSymUtl.h:229
const OdString & blockPaperSpaceName(OdDb::DwgVersion version=OdDb::kDHL_CURRENT)
Definition: DbSymUtl.h:271
const OdString & textStyleStandardName()
Definition: DbSymUtl.h:238
OdDbObjectId getTextStyleId(const OdString &name, const OdDbDatabase *pDb)
Definition: DbSymUtl.h:131
const OdString & DetailViewStyleStandardName(OdDbDatabase *pDb)
Definition: DbSymUtl.h:298
TOOLKIT_EXPORT const OdDbObjectId getLayerId(OdDbDatabase *pDb, const OdString &strLayer)
TOOLKIT_EXPORT OdResult validatePreExtendedSymbolName(const OdString &name, const OdDbDatabase *pDb, bool allowVerticalBar=false)
bool isLinetypeContinuousName(const OdString &name)
Definition: DbSymUtl.h:223
OdDbObjectId getVisualStyleId(const OdString &name, const OdDbDatabase *pDb)
Definition: DbSymUtl.h:196
bool isDetailViewStyleStandardName(OdDbDatabase *pDb, const OdString &name)
Definition: DbSymUtl.h:304
const OdString & layerZeroName()
Definition: DbSymUtl.h:226
const OdString & MLeaderStyleStandardName()
Definition: DbSymUtl.h:292
OdString getSymbolName(const OdDbObjectId &objId)
Definition: DbSymUtl.h:103
bool isSectionViewStyleStandardName(OdDbDatabase *pDb, const OdString &name)
Definition: DbSymUtl.h:314
OdDbObjectId getMLStyleId(const OdString &name, const OdDbDatabase *pDb)
Definition: DbSymUtl.h:160
bool isLinetypeByLayerName(const OdString &name)
Definition: DbSymUtl.h:211
bool isKindOfBlockPaperSpaceName(const OdString &pN, OdDb::DwgVersion version=OdDb::kDHL_CURRENT)
Definition: DbSymUtl.h:277
bool isBlockModelSpaceName(const OdString &pN, OdDb::DwgVersion version=OdDb::kDHL_CURRENT)
Definition: DbSymUtl.h:268
bool isTableStandardName(const OdString &name)
Definition: DbSymUtl.h:289
const OdString & TableStyleStandardName()
Definition: DbSymUtl.h:286
const OdString & MLineStyleStandardName()
Definition: DbSymUtl.h:241
TOOLKIT_EXPORT bool getMaxSymbolNameLength(OdUInt32 &maxLength, OdUInt32 &maxSize, bool isNewName, bool compatibilityMode)
bool isMLineStandardName(const OdString &name)
Definition: DbSymUtl.h:244
const OdString & linetypeContinuousName()
Definition: DbSymUtl.h:220
OdDbObjectId getTableStyleId(const OdString &name, const OdDbDatabase *pDb)
Definition: DbSymUtl.h:172