98 template <
class _ForeignId,
99 class _Compare = std::less<_ForeignId>,
100 class _ForeignIdIO = FixedSizeForeignIdIO <_ForeignId> >
105 bmap <_ForeignId, T_AUInt64,_Compare> m_idMap;
106 T_AUInt64 m_highestId;
107 mutable _ForeignIdIO m_io;
120 T_AUInt64
GetId (_ForeignId
const& foreignId)
122 bmap <_ForeignId, T_AUInt64, _Compare>::const_iterator found = m_idMap.find (foreignId);
124 if (found != m_idMap.end())
125 return found->second;
127 return m_idMap[foreignId] = ++m_highestId;
137 for (bmap <_ForeignId, T_AUInt64, _Compare>::const_iterator curr = m_idMap.begin(); curr != m_idMap.end(); curr++)
139 sink.put (curr->second);
140 m_io.Store (curr->first, sink);
152 size_t minimumIdSize = 2;
153 size_t minimumEntrySize =
sizeof (T_AUInt64) + minimumIdSize;
159 while (
SUCCESS == status && source.getRemainingSize () >
sizeof (
UInt32) + minimumEntrySize)
161 _ForeignId foreignId;
164 source.get (&elementId);
166 if (
SUCCESS == (status = m_io.Load (foreignId, source)))
167 m_idMap[foreignId] = elementId;
169 if (elementId > m_highestId)
170 m_highestId = m_highestId;
184 WString device, dir, name, extension;
185 BeFileName mapFileName;
187 BeFileName::ParseName (&device, &dir, &name, &extension, baseName.c_str());
188 extension = extension + L
".DgnIdMap";
189 mapFileName.BuildName (device.c_str(), dir.c_str(), name.c_str(), extension.c_str());
203 if (
NULL == (mapFile = _wfopen (GetMapFileName (baseFileName), L
"rb")))
207 size_t mapFileSize = ftell (mapFile);
209 bvector<byte> fileBuffer (mapFileSize);
212 size_t count = fread (&fileBuffer.front(), 1, mapFileSize, mapFile);
216 DataInternalizer source (&fileBuffer.front(), mapFileSize);
231 DataExternalizer sink;
233 if (
SUCCESS != (status = Store (sink)))
236 if (sink.getBytesWritten() == 0)
240 if (
NULL == (mapFile = _wfopen (GetMapFileName (baseFileName), L
"wb")))
246 fwrite (sink.getBuf(), 1, sink.getBytesWritten(), mapFile);
Definition: Bentley.h:212
struct Bentley::WString const & WStringCR
Definition: Bentley.h:239
#define SEEK_END
Definition: mdlio.h:20
size_type count(const key_type &__x) const
Definition: stdcxx/bstdmap.h:277
uint8_t UInt8
Definition: Bentley.r.h:116
uint32_t UInt32
Definition: Bentley.r.h:128
#define NULL
Definition: Bentley.h:157
#define fwrite
Definition: BeConsole.h:94
int StatusInt
Definition: Bentley.h:222
Definition: Bentley.h:210
#define BeAssert(_Expression)
BeAssert performs the same function as the standard assert, plus it prevents the most common cases of...
Definition: BeAssert.h:56
#define SEEK_SET
Definition: mdlio.h:18
A string class that has many of the same capabilities as std::string, plus additional functions such ...
Definition: WString.h:51