CFx SDK Documentation 2024 SP0
Loading...
Searching...
No Matches
BcfUtils.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#ifndef _BFC_UTILS_H
25#define _BFC_UTILS_H
26
27#include "BcfCommon.h"
28#include "StringArray.h"
29
30#include <cstdint>
31
32#include "BcfUnset.h"
33
37class TiXmlElement;
38
39namespace OdBcf {
40
41 class OdBcfTimeStamp;
43
44 class OdBcfElement;
45
49 namespace Utils
50 {
51
57 bool parseBool(const OdString &value);
58
65
74
80 BCF_EXPORT int createDir(const OdString &dir);
81
87
95 OdResult createTextChild(TiXmlElement *pParent, const char *name, const char *value);
96
97#define CREATE_TEXT_CHILD(pParent, Name, Value) \
98 \
99if(OdResult pParent##Res = OdBcf::Utils::createTextChild(pParent, Name, Value)) \
100{ \
101 return pParent##Res; \
102}
103
111 OdResult createConstructedChild(TiXmlElement *pParent, const char *name, const OdBcfElement *pValue);
112
113#define CREATE_CONSTRUCTED_CHILD(pParent, Name, Value) \
114 \
115if(OdResult pParent##Res = OdBcf::Utils::createConstructedChild(pParent, Name, Value)) \
116{ \
117 return pParent##Res; \
118}
119
120#define VALIDATE_SIMPLE_FIELD(Field) \
121 \
122if(OdBcf::Utils::isUnset(Field)) \
123{ \
124 return false; \
125}
126
127#define VALIDATE_UNREQUIRED_CONSTRUCTED_FIELD(Field) \
128 \
129if(!OdBcf::Utils::isUnset(Field)) \
130{ \
131 if(Field->validate() == false) \
132 { \
133 return false; \
134 } \
135}
136
137#define VALIDATE_REQUIRED_CONSTRUCTED_FIELD(Field) \
138 \
139if(!OdBcf::Utils::isUnset(Field)) \
140{ \
141 if(Field->validate() == false) \
142 { \
143 return false; \
144 } \
145} \
146else \
147{ \
148 return false; \
149}
150
151#define VALIDATE_UNREQUIRED_CONSTRUCTED_COLLECTION(Collection) \
152 \
153for(const auto& element : Collection) \
154{ \
155 VALIDATE_UNREQUIRED_CONSTRUCTED_FIELD(element); \
156}
157
158#define VALIDATE_REQUIRED_CONSTRUCTED_COLLECTION(Collection) \
159 \
160VALIDATE_UNREQUIRED_CONSTRUCTED_COLLECTION(Collection); \
161if(Collection.size() == 0) \
162{ \
163 return false; \
164}
165
166 } //namespace Utils
167
168} //namespace OdBcf
169
170#endif // _BFC_UTILS_H
#define BCF_EXPORT
OdResult
Definition: OdResult.h:29
GLuint const GLchar * name
Definition: gles2_ext.h:265
GLsizei const GLfloat * value
Definition: gles2_ext.h:302
const OdString & boolToString(bool value)
bool parseBool(const OdString &value)
OdBcfTimeStampPtr getCurrentTime()
BCF_EXPORT int createDir(const OdString &dir)
BCF_EXPORT OdString formatDir(const OdString &dir)
OdResult createConstructedChild(TiXmlElement *pParent, const char *name, const OdBcfElement *pValue)
OdResult createTextChild(TiXmlElement *pParent, const char *name, const char *value)
OdSmartPtr< OdBcfTimeStamp > OdBcfTimeStampPtr
Definition: BcfComment.h:38