4 * \date 2012-08-18 19:25GMT
5 * \author Jan Boon (Kaetemi)
10 * Copyright (C) 2012 by authors
12 * This file is part of RYZOM CORE PIPELINE.
13 * RYZOM CORE PIPELINE is free software: you can redistribute it
14 * and/or modify it under the terms of the GNU Affero General Public
15 * License as published by the Free Software Foundation, either
16 * version 3 of the License, or (at your option) any later version.
18 * RYZOM CORE PIPELINE is distributed in the hope that it will be
19 * useful, but WITHOUT ANY WARRANTY; without even the implied warranty
20 * of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
21 * GNU Affero General Public License for more details.
23 * You should have received a copy of the GNU Affero General Public
24 * License along with RYZOM CORE PIPELINE. If not, see
25 * <http://www.gnu.org/licenses/>.
28 #include <nel/misc/types_nl.h>
34 // #include <nel/misc/debug.h>
35 #include <nel/misc/vector.h>
40 // using namespace NLMISC;
45 ////////////////////////////////////////////////////////////////////////
46 ////////////////////////////////////////////////////////////////////////
47 ////////////////////////////////////////////////////////////////////////
59 std::string
CConfig::className() const
64 void CConfig::toString(std::ostream
&ostream
, const std::string
&pad
) const
66 CStorageContainer::toString(ostream
, pad
);
69 void CConfig::parse(uint16 version
, uint filter
)
71 CStorageContainer::parse(version
);
76 CStorageContainer::clean();
79 void CConfig::build(uint16 version
, uint filter
)
81 CStorageContainer::build(version
);
84 void CConfig::disown()
86 CStorageContainer::disown();
89 IStorageObject
*CConfig::createChunkById(uint16 id
, bool container
)
95 case 0x20a0: // unknown
96 return new CConfig20a0();
97 case 0x2180: // CConfigScript
98 return new CConfigScript();
105 case 0x2090: // unknown; known values: 1 (m3), 0 (m9, m2008, m2010)
106 return new CStorageValue
<sint32
>();
109 return CStorageContainer::createChunkById(id
, container
);
112 ////////////////////////////////////////////////////////////////////////
113 ////////////////////////////////////////////////////////////////////////
114 ////////////////////////////////////////////////////////////////////////
116 CConfig20a0::CConfig20a0()
121 CConfig20a0::~CConfig20a0()
126 std::string
CConfig20a0::className() const
131 void CConfig20a0::toString(std::ostream
&ostream
, const std::string
&pad
) const
133 CStorageContainer::toString(ostream
, pad
);
136 void CConfig20a0::parse(uint16 version
, uint filter
)
138 CStorageContainer::parse(version
);
141 void CConfig20a0::clean()
143 CStorageContainer::clean();
146 void CConfig20a0::build(uint16 version
, uint filter
)
148 CStorageContainer::build(version
);
151 void CConfig20a0::disown()
153 CStorageContainer::disown();
156 IStorageObject
*CConfig20a0::createChunkById(uint16 id
, bool container
)
162 case 0x0110: // CConfig20a0Entry
163 return new CConfig20a0Entry();
170 case 0x0100: // CConfig20a0Header: Number of entries
171 return new CStorageValue
<sint32
>();
174 return CStorageContainer::createChunkById(id
, container
);
177 ////////////////////////////////////////////////////////////////////////
178 ////////////////////////////////////////////////////////////////////////
179 ////////////////////////////////////////////////////////////////////////
181 CConfig20a0Entry::CConfig20a0Entry()
186 CConfig20a0Entry::~CConfig20a0Entry()
191 std::string
CConfig20a0Entry::className() const
193 return "Config20a0Entry";
196 void CConfig20a0Entry::toString(std::ostream
&ostream
, const std::string
&pad
) const
198 CStorageContainer::toString(ostream
, pad
);
201 void CConfig20a0Entry::parse(uint16 version
, uint filter
)
203 CStorageContainer::parse(version
);
206 void CConfig20a0Entry::clean()
208 CStorageContainer::clean();
211 void CConfig20a0Entry::build(uint16 version
, uint filter
)
213 CStorageContainer::build(version
);
216 void CConfig20a0Entry::disown()
218 CStorageContainer::disown();
221 IStorageObject
*CConfig20a0Entry::createChunkById(uint16 id
, bool container
)
227 case 0x0300: // unknown, contains 0x0100 with 4 bytes int value
228 return CStorageContainer::createChunkById(id
, container
);
235 case 0x0100: // unknown
236 case 0x0110: // unknown
237 case 0x0120: // unknown
238 case 0x0130: // unknown
239 case 0x0140: // unknown
240 case 0x0150: // unknown
241 case 0x0160: // unknown
242 case 0x0161: // unknown
243 case 0x0170: // unknown
244 case 0x0180: // unknown
245 case 0x0190: // unknown
246 case 0x0200: // unknown
247 case 0x0210: // unknown
248 case 0x0220: // unknown
249 case 0x0230: // unknown
250 case 0x0240: // unknown
251 case 0x0250: // unknown
252 case 0x0270: // unknown
253 case 0x0280: // unknown
254 case 0x0310: // unknown
255 case 0x0320: // unknown
256 return new CStorageValue
<sint32
>();
257 case 0x0260: // unknown
258 return new CStorageValue
<sint64
>();
259 case 0x0330: // unknown, 16 bytes
260 return CStorageContainer::createChunkById(id
, container
);
261 case 0x0290: // unknown
262 case 0x0390: // unknown
263 return new CStorageValue
<ucstring
>();
266 return CStorageContainer::createChunkById(id
, container
);
269 ////////////////////////////////////////////////////////////////////////
270 ////////////////////////////////////////////////////////////////////////
271 ////////////////////////////////////////////////////////////////////////
273 CConfigScript::CConfigScript()
278 CConfigScript::~CConfigScript()
283 std::string
CConfigScript::className() const
285 return "ConfigScript";
288 void CConfigScript::toString(std::ostream
&ostream
, const std::string
&pad
) const
290 CStorageContainer::toString(ostream
, pad
);
293 void CConfigScript::parse(uint16 version
, uint filter
)
295 CStorageContainer::parse(version
);
298 void CConfigScript::clean()
300 CStorageContainer::clean();
303 void CConfigScript::build(uint16 version
, uint filter
)
305 CStorageContainer::build(version
);
308 void CConfigScript::disown()
310 CStorageContainer::disown();
313 IStorageObject
*CConfigScript::createChunkById(uint16 id
, bool container
)
319 case 0x0040: // ConfigScriptEntry
320 return new CConfigScriptEntry();
323 return CStorageContainer::createChunkById(id
, container
);
326 ////////////////////////////////////////////////////////////////////////
327 ////////////////////////////////////////////////////////////////////////
328 ////////////////////////////////////////////////////////////////////////
330 CConfigScriptEntry::CConfigScriptEntry()
335 CConfigScriptEntry::~CConfigScriptEntry()
340 std::string
CConfigScriptEntry::className() const
342 return "ConfigScriptEntry";
345 void CConfigScriptEntry::toString(std::ostream
&ostream
, const std::string
&pad
) const
347 CStorageContainer::toString(ostream
, pad
);
350 void CConfigScriptEntry::parse(uint16 version
, uint filter
)
352 CStorageContainer::parse(version
);
355 void CConfigScriptEntry::clean()
357 CStorageContainer::clean();
360 void CConfigScriptEntry::build(uint16 version
, uint filter
)
362 CStorageContainer::build(version
);
365 void CConfigScriptEntry::disown()
367 CStorageContainer::disown();
370 IStorageObject
*CConfigScriptEntry::createChunkById(uint16 id
, bool container
)
376 case 0x0007: // ConfigScriptMetaContainer
377 return new CConfigScriptMetaContainer();
384 case 0x0050: // ConfigScriptHeader
385 return new CConfigScriptHeader();
388 return CStorageContainer::createChunkById(id
, container
);
391 ////////////////////////////////////////////////////////////////////////
392 ////////////////////////////////////////////////////////////////////////
393 ////////////////////////////////////////////////////////////////////////
395 CConfigScriptHeader::CConfigScriptHeader()
400 CConfigScriptHeader::~CConfigScriptHeader()
405 std::string
CConfigScriptHeader::className() const
407 return "ConfigScriptHeader";
410 void CConfigScriptHeader::serial(NLMISC::IStream
&stream
)
412 stream
.serial(SuperClassID
);
413 stream
.serial(ClassID
);
416 void CConfigScriptHeader::toString(std::ostream
&ostream
, const std::string
&pad
) const
418 ostream
<< "(" << className() << ") { ";
419 ostream
<< "\n" << pad
<< "SuperClassID: " << SuperClassID
;
420 ostream
<< "\n" << pad
<< "ClassID: " << NLMISC::toString(ClassID
);
424 ////////////////////////////////////////////////////////////////////////
425 ////////////////////////////////////////////////////////////////////////
426 ////////////////////////////////////////////////////////////////////////
428 CConfigScriptMetaContainer::CConfigScriptMetaContainer()
433 CConfigScriptMetaContainer::~CConfigScriptMetaContainer()
438 std::string
CConfigScriptMetaContainer::className() const
440 return "ConfigScriptMetaContainer";
443 void CConfigScriptMetaContainer::toString(std::ostream
&ostream
, const std::string
&pad
) const
445 CStorageContainer::toString(ostream
, pad
);
448 void CConfigScriptMetaContainer::parse(uint16 version
, uint filter
)
450 CStorageContainer::parse(version
);
453 void CConfigScriptMetaContainer::clean()
455 CStorageContainer::clean();
458 void CConfigScriptMetaContainer::build(uint16 version
, uint filter
)
460 CStorageContainer::build(version
);
463 void CConfigScriptMetaContainer::disown()
465 CStorageContainer::disown();
468 IStorageObject
*CConfigScriptMetaContainer::createChunkById(uint16 id
, bool container
)
474 case 0x0007: // ConfigScriptMetaContainer
475 return new CConfigScriptMetaContainer();
482 case 0x0001: // type: boolean (stored in four bytes, yes)
483 return new CStorageValue
<uint32
>();
485 nlerror("0x0002 found, please implement");
487 case 0x0003: // type: integer (not sure if signed)
488 return new CStorageValue
<sint32
>();
489 case 0x0004: // type: float
490 return new CStorageValue
<float>();
491 case 0x0005: // type: string (same format as the meta string)
492 case 0x0006: // ConfigScriptMetaString
493 return new CConfigScriptMetaString();
494 case 0x0008: // type: color (stored as 3 float vector)
495 return new CStorageValue
<NLMISC::CVector
>;
496 case 0x0060: // ConfigScriptMetaContainerHeader (contains the number of entries, amusingly)
497 return new CStorageValue
<uint32
>();
500 return CStorageContainer::createChunkById(id
, container
);
503 ////////////////////////////////////////////////////////////////////////
504 ////////////////////////////////////////////////////////////////////////
505 ////////////////////////////////////////////////////////////////////////
507 CConfigScriptMetaString::CConfigScriptMetaString()
512 CConfigScriptMetaString::~CConfigScriptMetaString()
517 std::string
CConfigScriptMetaString::className() const
519 return "ConfigScriptMetaString";
522 void CConfigScriptMetaString::serial(NLMISC::IStream
&stream
)
524 if (stream
.isReading())
528 Value
.resize(size
- 1);
532 uint32 size
= Value
.size() + 1;
535 stream
.serialBuffer(static_cast<uint8
*>(static_cast<void *>(&Value
[0])), Value
.size());
537 stream
.serial(endByte
);
538 nlassert(endByte
== 0);
541 void CConfigScriptMetaString::toString(std::ostream
&ostream
, const std::string
&pad
) const
543 ostream
<< "(" << className() << ") { " << Value
<< " } ";
546 ////////////////////////////////////////////////////////////////////////
547 ////////////////////////////////////////////////////////////////////////
548 ////////////////////////////////////////////////////////////////////////
550 } /* namespace MAX */
551 } /* namespace PIPELINE */