CFx SDK Documentation  2020SP3
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 
OdResult
OdResult
Definition: OdResult.h:29
OdDbSymUtil
Definition: DbSymUtl.h:51
OdDb::kMetric
@ kMetric
Metric system.
Definition: OdaDefs.h:439
OdDb::MeasurementValue
MeasurementValue
Definition: OdaDefs.h:437
OdDb::kDHL_CURRENT
@ kDHL_CURRENT
Definition: OdaDefs.h:101
OdString
Definition: OdString.h:95
OdDbDatabase
Definition: DbDatabase.h:421
OdDbSymUtil::isBlockModelSpaceName
bool isBlockModelSpaceName(const OdString &pN, OdDb::DwgVersion version=OdDb::kDHL_CURRENT)
Definition: DbSymUtl.h:266
OdTf::version
@ version
Definition: Tf.h:335
OdDbSymUtil::isDetailViewStyleStandardName
bool isDetailViewStyleStandardName(OdDbDatabase *pDb, const OdString &name)
Definition: DbSymUtl.h:296
name
GLuint const GLchar * name
Definition: gles2_ext.h:265
OdDbSymUtil::isTextStyleStandardName
bool isTextStyleStandardName(const OdString &name)
Definition: DbSymUtl.h:256
OdDbSymUtil::blockPaperSpaceName
const OdString & blockPaperSpaceName(OdDb::DwgVersion version=OdDb::kDHL_CURRENT)
Definition: DbSymUtl.h:269
OdDbObjectId
Definition: DbObjectId.h:99
OdDbSymUtil::blockModelSpaceName
const OdString & blockModelSpaceName(OdDb::DwgVersion version=OdDb::kDHL_CURRENT)
Definition: DbSymUtl.h:263
OdDbDatabase::getMLStyleDictionaryId
OdDbObjectId getMLStyleDictionaryId(bool createIfNotFound=true) const
ODA_ASSERT_ONCE
#define ODA_ASSERT_ONCE(exp)
Definition: DebugStuff.h:51
OdDbSymUtil::getVisualStyleId
OdDbObjectId getVisualStyleId(const OdString &name, const OdDbDatabase *pDb)
Definition: DbSymUtl.h:196
OdDb::kEnglish
@ kEnglish
English system.
Definition: OdaDefs.h:438
OdDbSymUtil::validatePreExtendedSymbolName
TOOLKIT_EXPORT OdResult validatePreExtendedSymbolName(const OdString &name, const OdDbDatabase *pDb, bool allowVerticalBar=false)
OdDbSymUtil::getMaxSymbolNameLength
TOOLKIT_EXPORT bool getMaxSymbolNameLength(OdUInt32 &maxLength, OdUInt32 &maxSize, bool isNewName, bool compatibilityMode)
OdDbSymUtil::isSectionViewStyleStandardName
bool isSectionViewStyleStandardName(OdDbDatabase *pDb, const OdString &name)
Definition: DbSymUtl.h:306
OdDbSymUtil::getTableStyleId
OdDbObjectId getTableStyleId(const OdString &name, const OdDbDatabase *pDb)
Definition: DbSymUtl.h:172
TD_PackPop.h
OdDbSymUtil::isLinetypeByBlockName
bool isLinetypeByBlockName(const OdString &name)
Definition: DbSymUtl.h:217
OdDbSymUtil::isLinetypeByLayerName
bool isLinetypeByLayerName(const OdString &name)
Definition: DbSymUtl.h:211
OdDbSymUtil::getMLeaderStyleId
OdDbObjectId getMLeaderStyleId(const OdString &name, const OdDbDatabase *pDb)
Definition: DbSymUtl.h:184
OdDbSymUtil::textStyleStandardName
const OdString & textStyleStandardName()
Definition: DbSymUtl.h:238
OdDbSymUtil::isMLineStandardName
bool isMLineStandardName(const OdString &name)
Definition: DbSymUtl.h:244
OdUInt32
unsigned int OdUInt32
Definition: OdPlatformSettings.h:783
OdDbDatabase::getVisualStyleDictionaryId
OdDbObjectId getVisualStyleDictionaryId(bool createIfNotFound=true) const
OdDbDatabase::getMLeaderStyleDictionaryId
OdDbObjectId getMLeaderStyleDictionaryId(bool createIfNotFound=true) const
OdDb::DwgVersion
DwgVersion
Definition: OdaDefs.h:46
OdDb::kForRead
@ kForRead
Definition: DbObjectId.h:56
OdDbSymUtil::dimStyleStandardId
TOOLKIT_EXPORT const OdDbObjectId & dimStyleStandardId(OdDbDatabase *pDb)
OdDbSymUtil::isViewportActiveName
bool isViewportActiveName(const OdString &name)
Definition: DbSymUtl.h:253
OdDbSymUtil::linetypeContinuousName
const OdString & linetypeContinuousName()
Definition: DbSymUtl.h:220
OdString.h
OdDbSymUtil::MLineStyleStandardName
const OdString & MLineStyleStandardName()
Definition: DbSymUtl.h:241
OdDbSymUtil::textStyleStandardId
TOOLKIT_EXPORT const OdDbObjectId & textStyleStandardId(OdDbDatabase *pDb)
OdDbSymUtil::DetailViewStyleStandardName
const OdString & DetailViewStyleStandardName(OdDbDatabase *pDb)
Definition: DbSymUtl.h:290
OdSmartPtr
Definition: SmartPtr.h:58
OdDbDatabase::getTableStyleDictionaryId
OdDbObjectId getTableStyleDictionaryId(bool createIfNotFound=true) const
DbDatabase.h
OdDbSymUtil::linetypeByLayerName
const OdString & linetypeByLayerName()
Definition: DbSymUtl.h:208
DbObjectId.h
OdDbSymUtil::isLinetypeContinuousName
bool isLinetypeContinuousName(const OdString &name)
Definition: DbSymUtl.h:223
OdDbSymUtil::layerZeroName
const OdString & layerZeroName()
Definition: DbSymUtl.h:226
DbDictionary.h
OdDbSymUtil::plotStyleNormalName
const OdString & plotStyleNormalName()
Definition: DbSymUtl.h:275
OdSmartPtr::get
const T * get() const
Definition: SmartPtr.h:326
OdDb::vAC12
@ vAC12
Definition: OdaDefs.h:68
OdDbObjectId::kNull
static TOOLKIT_EXPORT_STATIC const OdDbObjectId kNull
Definition: DbObjectId.h:118
OdChar
wchar_t OdChar
Definition: OdPlatformSettings.h:745
TD_PackPush.h
OdDbSymUtil::linetypeByBlockName
const OdString & linetypeByBlockName()
Definition: DbSymUtl.h:214
OdDbSymUtil::SectionViewStyleStandardName
const OdString & SectionViewStyleStandardName(OdDbDatabase *pDb)
Definition: DbSymUtl.h:301
OdDbSymUtil::repairSymbolName
TOOLKIT_EXPORT OdResult repairSymbolName(OdString &newName, const OdString &oldName, const OdDbDatabase *pDb, bool allowVerticalBar=false, const OdChar symSubst=L '_', bool insertPrefix=true)
OdDbSymUtil::isLayerZeroName
bool isLayerZeroName(const OdString &name)
Definition: DbSymUtl.h:229
OdRxObject::cast
static OdRxObjectPtr cast(const OdRxObject *pointer)
Definition: RxObject.h:640
OdDbSymUtil::viewportActiveName
const OdString & viewportActiveName()
Definition: DbSymUtl.h:250
OdDbObjectId::openObject
OdResult openObject(OdDbObjectPtr &pObj, OdDb::OpenMode openMode=OdDb::kForRead, bool openErasedOne=false) const
OdDbSymUtil::getPlotstyleId
OdDbObjectId getPlotstyleId(const OdString &name, const OdDbDatabase *pDb)
Definition: DbSymUtl.h:148
ODA_ASSERT
#define ODA_ASSERT(exp)
Definition: DebugStuff.h:49
OdDbSymUtil::validateSymbolName
TOOLKIT_EXPORT OdResult validateSymbolName(const OdString &name, const OdDbDatabase *pDb, bool allowVerticalBar=false)
DbSymbolTable.h
DBSYMUTL_MAKE_GETSYMBOLID_FUNC
#define DBSYMUTL_MAKE_GETSYMBOLID_FUNC(T_TABLE)
Definition: DbSymUtl.h:114
OdDbSymUtil::getMLStyleId
OdDbObjectId getMLStyleId(const OdString &name, const OdDbDatabase *pDb)
Definition: DbSymUtl.h:160
StdStrings.h
OdDbSymUtil::dimStyleStandardName
const OdString & dimStyleStandardName(OdDb::MeasurementValue measurement)
Definition: DbSymUtl.h:247
OdDbDatabase::getPlotStyleNameDictionaryId
OdDbObjectId getPlotStyleNameDictionaryId(bool createIfNotFound=true) const
OdDbSymUtil::layerDefpointsName
const OdString & layerDefpointsName()
Definition: DbSymUtl.h:232
odStrICmp
#define odStrICmp
Definition: OdPlatform.h:369
OdDbSymUtil::TableStyleStandardName
const OdString & TableStyleStandardName()
Definition: DbSymUtl.h:278
DbSymbolTableRecord.h
OdDbSymUtil::repairPreExtendedSymbolName
TOOLKIT_EXPORT OdResult repairPreExtendedSymbolName(OdString &newName, const OdString &oldName, const OdDbDatabase *pDb, bool allowVerticalBar=false, const OdChar symSubst=L '_', bool insertPrefix=true)
OdString::kEmpty
FIRSTDLL_EXPORT_STATIC static const OdString kEmpty
Definition: OdString.h:98
TOOLKIT_EXPORT
#define TOOLKIT_EXPORT
Definition: DbExport.h:40
OdDbSymUtil::isLayerDefpointsName
bool isLayerDefpointsName(const OdString &name)
Definition: DbSymUtl.h:235
OdDbSymUtil::getTextStyleId
OdDbObjectId getTextStyleId(const OdString &name, const OdDbDatabase *pDb)
Definition: DbSymUtl.h:131
OdDbSymUtil::isBlockPaperSpaceName
bool isBlockPaperSpaceName(const OdString &pN, OdDb::DwgVersion version=OdDb::kDHL_CURRENT)
Definition: DbSymUtl.h:272
OdDbSymUtil::isMLeaderStandardName
bool isMLeaderStandardName(const OdString &name)
Definition: DbSymUtl.h:287
DbTextStyleTableRecord.h
OdDbSymUtil::getSymbolName
OdString getSymbolName(const OdDbObjectId &objId)
Definition: DbSymUtl.h:103
OdDbSymUtil::MLineStyleStandardId
TOOLKIT_EXPORT const OdDbObjectId MLineStyleStandardId(OdDbDatabase *pDb)
OdDbSymUtil::isTableStandardName
bool isTableStandardName(const OdString &name)
Definition: DbSymUtl.h:281
OdDbSymUtil::MLeaderStyleStandardName
const OdString & MLeaderStyleStandardName()
Definition: DbSymUtl.h:284