CFx SDK Documentation  2023 SP0
DbSymUtl.h
Go to the documentation of this file.
1 // Copyright (C) 2002-2017, 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 Teigha(R) software pursuant to a license
16 // agreement with Open Design Alliance.
17 // Teigha(R) Copyright (C) 2002-2017 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"
36 #include "DbTextStyleTableRecord.h"
37 #include "DbDictionary.h"
38 #include "DbDatabase.h"
39 
40 // Predefined names
41 #define AC_STRING(name, val) \
42 extern TOOLKIT_EXPORT_GLOBAL const OdConstString name;
43 #include "StdStrings.h"
44 #undef AC_STRING
45 
50 namespace 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 
103  inline OdString getSymbolName(const OdDbObjectId& objId)
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  {
151  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 
211  inline bool isLinetypeByLayerName(const OdString& name)
212  { return !odStrICmp(name, linetypeByLayerName()); }
213 
215  { return byBlockNameStr; }
216 
217  inline bool isLinetypeByBlockName(const OdString& name)
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 
232  inline const OdString& layerDefpointsName()
233  { return layerDefpointsNameStr; }
234 
235  inline bool isLayerDefpointsName(const OdString& name)
236  { return !odStrICmp(name, layerDefpointsName()); }
237 
239  { return standardStr; }
240 
242  { return standardStr; }
243 
244  inline bool isMLineStandardName(const OdString& name)
245  { return !odStrICmp(name, MLineStyleStandardName()); }
246 
248  { return measurement == OdDb::kEnglish ? standardStr : metricDimStandardStr; }
249 
250  inline const OdString& viewportActiveName()
251  { return viewportActiveNameStr; }
252 
253  inline bool isViewportActiveName(const OdString& name)
254  { return !odStrICmp(name, viewportActiveName()); }
255 
257  { return !odStrICmp(name, textStyleStandardName()); }
258 
262 
264  { return version <= OdDb::vAC12 ? modelSpaceStr_R12 : modelSpaceStr; }
265 
267  { return odStrICmp(pN, blockModelSpaceName(version)) == 0; }
268 
270  { return version <= OdDb::vAC12 ? paperSpaceStr_R12 : paperSpaceStr; }
271 
273  { return odStrICmp(pN, blockPaperSpaceName(version)) == 0; }
274 
276  { return plotStyleNormalNameStr;}
277 
279  { return standardStr; }
280 
281  inline bool isTableStandardName(const OdString& name)
282  { return !odStrICmp(name, TableStyleStandardName()); }
283 
285  { return standardStr; }
286 
287  inline bool isMLeaderStandardName(const OdString& name)
288  { return !odStrICmp(name, MLeaderStyleStandardName()); }
289 
291  {
292  ODA_ASSERT_ONCE(pDb);
293  return (pDb && pDb->getMEASUREMENT() == OdDb::kMetric) ? standardMetricDictStr : standardImperialDictStr;
294  }
295 
297  {
299  }
300 
302  {
303  return DetailViewStyleStandardName(pDb);
304  }
305 
307  {
309  }
310 }
311 // namespace OdDbSymUtil
312 
313 #include "TD_PackPop.h"
314 
315 #endif // DBSYMUTL_DEFINED
316 
#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:51
#define ODA_ASSERT(exp)
Definition: DebugStuff.h:49
#define odStrICmp
Definition: OdPlatform.h:369
unsigned int OdUInt32
wchar_t OdChar
OdResult
Definition: OdResult.h:29
bool isNull() const
Definition: BaseObjectPtr.h:70
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:118
OdResult openObject(OdDbObjectPtr &pObj, OdDb::OpenMode openMode=OdDb::kForRead, bool openErasedOne=false) const
static OdRxObjectPtr cast(const OdRxObject *pointer)
Definition: RxObject.h:659
const T * get() const
Definition: SmartPtr.h:326
FIRSTDLL_EXPORT_STATIC static const OdString kEmpty
Definition: OdString.h:98
GLuint const GLchar * name
Definition: gles2_ext.h:265
DwgVersion
Definition: OdaDefs.h:46
@ kDHL_CURRENT
Definition: OdaDefs.h:101
@ vAC12
Definition: OdaDefs.h:68
MeasurementValue
Definition: OdaDefs.h:439
@ kMetric
Metric system.
Definition: OdaDefs.h:441
@ kEnglish
English system.
Definition: OdaDefs.h:440
@ kForRead
Definition: DbObjectId.h:56
bool isLayerDefpointsName(const OdString &name)
Definition: DbSymUtl.h:235
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)
const OdString & SectionViewStyleStandardName(OdDbDatabase *pDb)
Definition: DbSymUtl.h:301
const OdString & plotStyleNormalName()
Definition: DbSymUtl.h:275
bool isBlockPaperSpaceName(const OdString &pN, OdDb::DwgVersion version=OdDb::kDHL_CURRENT)
Definition: DbSymUtl.h:272
const OdString & linetypeByBlockName()
Definition: DbSymUtl.h:214
const OdString & layerZeroName()
Definition: DbSymUtl.h:226
bool isMLeaderStandardName(const OdString &name)
Definition: DbSymUtl.h:287
OdDbObjectId getPlotstyleId(const OdString &name, const OdDbDatabase *pDb)
Definition: DbSymUtl.h:148
TOOLKIT_EXPORT const OdDbObjectId MLineStyleStandardId(OdDbDatabase *pDb)
const OdString & TableStyleStandardName()
Definition: DbSymUtl.h:278
const OdString & textStyleStandardName()
Definition: DbSymUtl.h:238
const OdString & DetailViewStyleStandardName(OdDbDatabase *pDb)
Definition: DbSymUtl.h:290
bool isTextStyleStandardName(const OdString &name)
Definition: DbSymUtl.h:256
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)
const OdString & linetypeByLayerName()
Definition: DbSymUtl.h:208
const OdString & viewportActiveName()
Definition: DbSymUtl.h:250
bool isLayerZeroName(const OdString &name)
Definition: DbSymUtl.h:229
const OdString & dimStyleStandardName(OdDb::MeasurementValue measurement)
Definition: DbSymUtl.h:247
const OdString & MLineStyleStandardName()
Definition: DbSymUtl.h:241
OdDbObjectId getTextStyleId(const OdString &name, const OdDbDatabase *pDb)
Definition: DbSymUtl.h:131
TOOLKIT_EXPORT OdResult validatePreExtendedSymbolName(const OdString &name, const OdDbDatabase *pDb, bool allowVerticalBar=false)
const OdString & linetypeContinuousName()
Definition: DbSymUtl.h:220
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:296
const OdString & MLeaderStyleStandardName()
Definition: DbSymUtl.h:284
OdString getSymbolName(const OdDbObjectId &objId)
Definition: DbSymUtl.h:103
bool isSectionViewStyleStandardName(OdDbDatabase *pDb, const OdString &name)
Definition: DbSymUtl.h:306
const OdString & blockPaperSpaceName(OdDb::DwgVersion version=OdDb::kDHL_CURRENT)
Definition: DbSymUtl.h:269
const OdString & blockModelSpaceName(OdDb::DwgVersion version=OdDb::kDHL_CURRENT)
Definition: DbSymUtl.h:263
OdDbObjectId getMLStyleId(const OdString &name, const OdDbDatabase *pDb)
Definition: DbSymUtl.h:160
bool isLinetypeByLayerName(const OdString &name)
Definition: DbSymUtl.h:211
bool isBlockModelSpaceName(const OdString &pN, OdDb::DwgVersion version=OdDb::kDHL_CURRENT)
Definition: DbSymUtl.h:266
bool isTableStandardName(const OdString &name)
Definition: DbSymUtl.h:281
TOOLKIT_EXPORT const OdDbObjectId & textStyleStandardId(OdDbDatabase *pDb)
TOOLKIT_EXPORT bool getMaxSymbolNameLength(OdUInt32 &maxLength, OdUInt32 &maxSize, bool isNewName, bool compatibilityMode)
TOOLKIT_EXPORT const OdDbObjectId & dimStyleStandardId(OdDbDatabase *pDb)
bool isMLineStandardName(const OdString &name)
Definition: DbSymUtl.h:244
OdDbObjectId getTableStyleId(const OdString &name, const OdDbDatabase *pDb)
Definition: DbSymUtl.h:172
const OdString & layerDefpointsName()
Definition: DbSymUtl.h:232
@ version
Definition: Tf.h:335