CFx SDK Documentation 2026 SP0
Loading...
Searching...
No Matches
DbRevisionGuid.h
Go to the documentation of this file.
1
2// Copyright (C) 2002-2023, Open Design Alliance (the "Alliance").
3
4// All rights reserved.
5//
6// This software and its documentation and related materials are owned by
7// the Alliance. The software may only be incorporated into application
8// programs owned by members of the Alliance, subject to a signed
9// Membership Agreement and Supplemental Software License Agreement with the
10// Alliance. The structure and organization of this software are the valuable
11// trade secrets of the Alliance and its suppliers. The software is also
12// protected by copyright law and international treaty provisions. Application
13// programs incorporating this software must include the following statement
14// with their copyright notices:
15//
16// This application incorporates Open Design Alliance software pursuant to a license
17// agreement with Open Design Alliance.
18// Open Design Alliance Copyright (C) 2002-2024 by Open Design Alliance.
19// All rights reserved.
20//
21// By use of this software, its documentation or related materials, you
22// acknowledge and accept the above terms.
24
25#pragma once
26
27#include <OdGUID.h>
28#include "NextCodeDefs.h"
29#include "DbFiler.h"
30
31#include "TD_PackPush.h"
32
40class OdDbRevisionGuid : public OdGUID { // used in Model-Doc feature to reference body geometry revision
41public:
49
57 *this = value;
58 }
59
67 if (str.getLength() != 38 ||
68 !(str[0] == '{' && str[9] == '-' && str[14] == '-' && str[19] == '-' && str[24] == '-' && str[37] == '}'))
69 {
70 throw OdError(eInvalidInput);
71 }
72 OdUInt32 data32 = (OdUInt32)(OdUInt64)OdDbHandle(OdString(&str.c_str()[1], 8));
73 OdUInt16 data16_1 = (OdUInt16)(OdUInt64)OdDbHandle(OdString(&str.c_str()[10], 4));
74 OdUInt16 data16_2 = (OdUInt16)(OdUInt64)OdDbHandle(OdString(&str.c_str()[15], 4));
75 OdUInt8 data8[8];
76 for (int i = 0; i < 8; ++i) {
77 data8[i] = (OdUInt8)(OdUInt64)OdDbHandle(OdString(&str.c_str()[20 + i*2 + (i < 2 ? 0 : 1)], 2));
78 }
79 setGUIDdata(data32, data16_1, data16_2, data8);
80 return *this;
81 }
82
88 static void createGuid(OdDbRevisionGuid &newGuid) {
89 newGuid = odrxSystemServices()->createGuid();
90 }
91
92
98 OdString ascii() const {
99 return toString(StringFormat::Braces);
100 }
101
107 OdResult dxfInRaw(OdDbDxfFiler* pFiler) { // Model-Doc way
108 NEXT_CODE(90);
109 OdUInt32 data32 = pFiler->rdInt32();
110 NEXT_CODE(70);
111 OdUInt16 data16_1 = pFiler->rdInt16();
112 NEXT_CODE(70);
113 OdUInt16 data16_2 = pFiler->rdInt16();
114 OdUInt8 data8[8];
115 for (int i = 0; i < 8; ++i) {
116 NEXT_CODE(280);
117 data8[i] = pFiler->rdInt8();
118 }
119 setGUIDdata(data32, data16_1, data16_2, data8);
120 return eOk;
121 }
122
126 void dxfOutRaw(OdDbDxfFiler* pFiler) const { // Model-Doc way
127 const OdUInt8 *RevGUIDData = data();
128 pFiler->wrInt32(90, *reinterpret_cast<const OdUInt32*>(RevGUIDData));
129 pFiler->wrInt16(70, *reinterpret_cast<const OdUInt16*>(RevGUIDData + 4));
130 pFiler->wrInt16(70, *reinterpret_cast<const OdUInt16*>(RevGUIDData + 6));
131 for (int i = 0; i < 8; ++i)
132 pFiler->wrInt8(280, RevGUIDData[8 + i]);
133 }
134
138 void dwgIn(OdDbDwgFiler* pFiler) {
139 OdUInt32 data32 = pFiler->rdInt32();
140 OdUInt16 data16_1 = pFiler->rdInt16();
141 OdUInt16 data16_2 = pFiler->rdInt16();
142 OdUInt8 data8[8];
143 for (int i = 0; i < 8; ++i)
144 data8[i] = pFiler->rdInt8();
145 setGUIDdata(data32, data16_1, data16_2, data8);
146 }
147
151 void dwgOut(OdDbDwgFiler* pFiler) const {
152 const OdUInt8 *RevGUIDData = data();
153 pFiler->wrInt32(*reinterpret_cast<const OdUInt32*>(RevGUIDData));
154 pFiler->wrInt16(*reinterpret_cast<const OdUInt16*>(RevGUIDData + 4));
155 pFiler->wrInt16(*reinterpret_cast<const OdUInt16*>(RevGUIDData + 6));
156 for (int i = 0; i < 8; ++i)
157 pFiler->wrInt8(RevGUIDData[8 + i]);
158 }
159};
160
170
178
186 *this = value;
187 }
188
194 void dxfIn(OdDbDxfFiler* pFiler) {
195 int nGC = pFiler->nextItem();
196 if (nGC == 290) {
197 m_bIsSet = pFiler->rdBool();
198 }
199 else {
200 m_bIsSet = false;
201 ODA_FAIL_M_ONCE("Unexpected group while reading OdRevisionGuid");
202 }
203 nGC = pFiler->nextItem();
204 if (nGC == 2) {
206 }
207 else {
208 OdUInt8 data8[8] = { 0 };
209 setGUIDdata(0, 0, 0, data8);
210 ODA_FAIL_M_ONCE("Unexpected group while reading OdRevisionGuid");
211 }
212 }
213
217 void dxfOut(OdDbDxfFiler* pFiler) const {
218 pFiler->wrBool(290, m_bIsSet);
219 pFiler->wrString(2, ascii());
220 }
221
225 void dwgIn(OdDbDwgFiler* pFiler) {
226 m_bIsSet = pFiler->rdBool();
228 }
229
233 void dwgOut(OdDbDwgFiler* pFiler) const {
234 pFiler->wrBool(m_bIsSet);
236 }
237
244 void setGuid(const OdRevisionGuid& newGuid, bool bSet) {
245 if (m_bIsSet != bSet || !(*this == newGuid)) {
246 *this = newGuid;
247 m_bIsSet = bSet;
248 }
249 }
250
255 OdRevisionGuid newGuid;
256 createGuid(newGuid);
257 setGuid(newGuid, m_bIsSet);
258 }
259
265 void enable(bool bEnable) {
266 if (bEnable) {
267 OdRevisionGuid newGuid;
268 createGuid(newGuid);
269 setGuid(newGuid, bEnable);
270 }
271 else {
272 setGuid(*this, bEnable);
273 }
274 }
275};
276
277#include "TD_PackPop.h"
#define ODA_FAIL_M_ONCE(message)
Definition DebugStuff.h:98
false
Definition DimVarDefs.h:165
@ eOk
Definition FxBIM.h:41
#define NEXT_CODE(code)
unsigned int OdUInt32
unsigned short OdUInt16
unsigned char OdUInt8
wchar_t OdChar
OdResult
Definition OdResult.h:29
OdString OdString
Definition OdString.h:1258
FIRSTDLL_EXPORT OdRxSystemServices * odrxSystemServices()
virtual void wrInt32(OdInt32 value)=0
virtual OdInt32 rdInt32()=0
virtual OdInt8 rdInt8()=0
virtual void wrInt8(OdInt8 value)=0
virtual void wrBool(bool value)=0
virtual void wrInt16(OdInt16 value)=0
virtual OdInt16 rdInt16()=0
virtual bool rdBool()=0
virtual void wrInt8(int groupCode, OdInt8 value)=0
virtual void wrInt32(int groupCode, OdInt32 value)=0
OdString rdString()
virtual OdInt32 rdInt32()=0
virtual OdInt16 rdInt16()=0
virtual void wrBool(int groupCode, bool value)=0
virtual void wrInt16(int groupCode, OdInt16 value)=0
virtual int nextItem()
virtual bool rdBool()=0
virtual void wrString(int groupCode, const OdString &value)=0
virtual OdInt8 rdInt8()=0
void dwgOut(OdDbDwgFiler *pFiler) const
OdDbRevisionGuid & operator=(const OdString &str)
OdString ascii() const
void dxfOutRaw(OdDbDxfFiler *pFiler) const
void dwgIn(OdDbDwgFiler *pFiler)
OdResult dxfInRaw(OdDbDxfFiler *pFiler)
static void createGuid(OdDbRevisionGuid &newGuid)
OdDbRevisionGuid(const OdString &value)
OdString toString(const StringFormat::Enum format=StringFormat::Hyphenses) const
void setGUIDdata(const OdUInt32, const OdUInt16, const OdUInt16, const Data4Type &)
const DataType & data() const
virtual OdString createGuid()
const OdChar * c_str() const
Definition OdString.h:205
int getLength() const
Definition OdString.h:135
GLsizei const GLfloat * value
Definition gles2_ext.h:302
void dwgIn(OdDbDwgFiler *pFiler)
void dxfOut(OdDbDxfFiler *pFiler) const
OdRevisionGuid(const OdChar *value)
void setGuid(const OdRevisionGuid &newGuid, bool bSet)
void enable(bool bEnable)
void dxfIn(OdDbDxfFiler *pFiler)
void dwgOut(OdDbDwgFiler *pFiler) const