CFx SDK Documentation  2023 SP0
BcfConsts.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 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-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_CONSTS_H
25 #define _BCF_CONSTS_H
26 
27 #include "BcfCommon.h"
28 
29 #define STL_USING_LIMITS
30 #include "OdaSTL.h"
31 
32 namespace OdBcf
33 {
34  namespace Consts
35  {
36  // This function should be tested on different platform. After successful tests we should move it to OdPlatfrom.h
37  template<class RealType>
38  inline RealType nanIEEERealCreate()
39  {
40  /*
41  int inf = 0x7F800000;
42  int nan = 0x7F800001;
43  */
44  union nanType
45  {
46  RealType nan;
47  unsigned char buf[sizeof(RealType)];
48  };
49 
50  nanType nanGenerator = { 0 };
51 
52 #ifdef ODA_BIGENDIAN
53  nanGenerator.buf[0] = 0x7F;
54  nanGenerator.buf[1] = 0xF0;
55  nanGenerator.buf[sizeof(RealType) - 1] = 0x1;
56 #else
57  nanGenerator.buf[sizeof(RealType) - 1] = 0x7F;
58  nanGenerator.buf[sizeof(RealType) - 2] = 0xF0;
59  nanGenerator.buf[0] = 0x1;
60 #endif
61 
62  return nanGenerator.nan;
63  }
64 
65 #ifdef USE_LIB_NAN
66  static const double OdNan = nan("");
67  static const float OdNanf = nanf("");
68 #else
69  static const double OdNan = nanIEEERealCreate<double>();
70  static const float OdNanf = nanIEEERealCreate<float>();
71 #endif
72 
73  static const long OdLongUnset = std::numeric_limits<long>::max();
74  static const int OdIntUnset = std::numeric_limits<int>::max();
75  static const char OdStringUnset[] = "\xff";
76  static const size_t OdStringUnsetLength = strlen(OdStringUnset);
77 
78  static const OdAnsiString AnsiStringUnset(OdBcf::Consts::OdStringUnset);
79  }
80 }
81 
82 #endif // _BCF_CONSTS_H
const T & max(const T &x, const T &y)
RealType nanIEEERealCreate()
Definition: BcfConsts.h:38