CFx SDK Documentation  2023 SP0
BcfUnset.h
Go to the documentation of this file.
1 // Copyright (C) 2002-2020, 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 valueuable
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-2020 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 #ifndef _BCF_UNSET_H
25 #define _BCF_UNSET_H
26 
27 #include "OdaCommon.h"
28 #include "SmartPtr.h"
29 
30 #define STL_USING_MAP
31 #include "OdaSTL.h"
32 
33 #include "OdGUID.h"
34 #include "OdString.h"
35 #include "BcfConsts.h"
36 
37 namespace OdBcf
38 {
39  namespace Utils
40  {
41  template <class TUnsetable>
42  const TUnsetable& getUnset() { ODA_ASSERT(0 && "Unknown type. Add getUnset for it."); static TUnsetable unsettled = 0; return unsettled; }
43 
44  template <> inline const double& getUnset<double>() { return Consts::OdNan; }
45  template <> inline const long& getUnset<long>() { return Consts::OdLongUnset; }
46  template <> inline const int& getUnset<int>() { return Consts::OdIntUnset; }
47  template <> inline const OdString& getUnset<OdString>() { static OdString stringUnset = Consts::OdStringUnset; return stringUnset; }
48  template <> inline const OdAnsiString& getUnset<OdAnsiString>() { static OdAnsiString stringUnset = Consts::OdStringUnset; return stringUnset; }
49  template <> inline const OdGUID& getUnset<OdGUID>() { return OdGUID::kNull; }
50 
51  inline bool isUnset(const bool & value) { return false; }
52  inline bool isUnset(const float & value) { return value != value; }
53  inline bool isUnset(const double & value) { return value != value; }
54  inline bool isUnset(const long value) { return value == Consts::OdLongUnset; }
55  inline bool isUnset(const int value) { return value == Consts::OdIntUnset; }
56  inline bool isUnset(const OdString & value) { return value.getLength() == Consts::OdStringUnsetLength && value.compare(Consts::OdStringUnset) == 0; }
57  inline bool isUnset(const OdAnsiString & value) { return value.getLength() == Consts::OdStringUnsetLength && value.compare(Consts::OdStringUnset) == 0; }
58  inline bool isUnset(const char * value) { return strlen(value) == Consts::OdStringUnsetLength && strcmp(value, Consts::OdStringUnset) == 0; }
59  inline bool isUnset(const OdGUID & value) { return value == OdGUID::kNull; }
60  template <class TInner>
61  inline bool isUnset(const OdSmartPtr<TInner> & value) { return value.isNull(); }
62  template <class TInner>
63  inline bool isUnset(const OdArray<TInner> & value) { return value.empty(); }
64  template <class TKey, class TValue>
65  inline bool isUnset(const std::map<TKey, TValue> & value) { return value.empty(); }
66 
67  template<class TUnsetable>
68  void initUnset(TUnsetable &value) { value = getUnset<TUnsetable>(); }
69  }
70 }
71 
72 #endif // _BCF_UNSET_H
73 
#define ODA_ASSERT(exp)
Definition: DebugStuff.h:49
Definition: OdGUID.h:29
static FIRSTDLL_EXPORT_STATIC const OdGUID kNull
Definition: OdGUID.h:43
GLsizei const GLfloat * value
Definition: gles2_ext.h:302
const OdAnsiString & getUnset< OdAnsiString >()
Definition: BcfUnset.h:48
const OdGUID & getUnset< OdGUID >()
Definition: BcfUnset.h:49
const int & getUnset< int >()
Definition: BcfUnset.h:46
void initUnset(TUnsetable &value)
Definition: BcfUnset.h:68
bool isUnset(const OdBcf::OdBcfFileAttributesGroup &value)
const long & getUnset< long >()
Definition: BcfUnset.h:45
const TUnsetable & getUnset()
Definition: BcfUnset.h:42
const OdString & getUnset< OdString >()
Definition: BcfUnset.h:47
const double & getUnset< double >()
Definition: BcfUnset.h:44