00001
00002
00003
00004
00005
00006
00007
00008
00009 #ifndef __DAE_ATOMIC_TYPE_H__
00010 #define __DAE_ATOMIC_TYPE_H__
00011
00012 #include <sstream>
00013 #include <dae/daeTypes.h>
00014 #include <dae/daeStringRef.h>
00015 #include <dae/daeArray.h>
00016 #include <dae/daeElement.h>
00017
00018 #ifndef _WIN32
00019 #include <stdint.h>
00020 #endif
00021
00022 class DAE;
00023 class daeAtomicType;
00024 class daeMetaElement;
00025
00026 typedef daeTArray<daeAtomicType*> daeAtomicTypeArray;
00027 class daeMetaAttribute;
00028 typedef daeSmartRef<daeMetaAttribute> daeMetaAttributeRef;
00029
00048 class DLLSPEC daeAtomicType
00049 {
00050 public:
00054 virtual ~daeAtomicType() {}
00055
00059 daeAtomicType(DAE& dae);
00060
00061 public:
00068 virtual daeBool memoryToString(daeChar* src, std::ostringstream& dst) = 0;
00069
00076 virtual daeBool stringToMemory(daeChar* src, daeChar* dst);
00077
00083 virtual void arrayToString(daeArray& array, std::ostringstream& buffer);
00084
00092 virtual daeBool stringToArray(daeChar* src, daeArray& array);
00093
00099 virtual daeMemoryRef create() = 0;
00100
00105 virtual void destroy(daeMemoryRef obj) = 0;
00106
00113 virtual daeArray* createArray() = 0;
00114
00122 virtual daeInt compare(daeChar* value1, daeChar* value2);
00123
00131 virtual daeInt compareArray(daeArray& value1, daeArray& value2);
00132
00138 virtual void copy(daeChar* src, daeChar* dst) = 0;
00139
00145 virtual void copyArray(daeArray& src, daeArray& dst);
00146
00151 daeStringRefArray& getNameBindings() { return _nameBindings; }
00152
00158 daeEnum getTypeEnum() { return _typeEnum; }
00159
00164 daeInt getSize() { return _size; }
00165
00174 daeStringRef getScanFormat() { return _scanFormat; }
00175
00184 daeStringRef getPrintFormat() { return _printFormat; }
00185
00191 daeInt getAlignment() { return _alignment; }
00192
00197 daeStringRef getTypeString() { return _typeString; }
00198
00206 daeChar* align(daeChar* ptr) {
00207 return (daeChar*)(((intptr_t)(ptr+_alignment-1))&(~(_alignment - 1))); }
00208
00214 virtual void setDocument(daeChar* value, daeDocument* doc) { }
00215
00221 virtual void setDocument(daeArray& array, daeDocument* doc) { }
00222
00223 protected:
00224 DAE* _dae;
00225 daeInt _size;
00226 daeInt _alignment;
00227 daeEnum _typeEnum;
00228 daeStringRef _typeString;
00229 daeStringRef _printFormat;
00230 daeStringRef _scanFormat;
00231 daeInt _maxStringLength;
00232
00233 public:
00237 daeStringRefArray _nameBindings;
00238
00239 public:
00241 enum daeAtomicTypes {
00243 BoolType,
00245 EnumType,
00247 CharType,
00249 ShortType,
00251 IntType,
00253 UIntType,
00255 LongType,
00257 ULongType,
00259 FloatType,
00261 DoubleType,
00263 StringRefType,
00265 ElementRefType,
00267 MemoryRefType,
00269 RawRefType,
00271 ResolverType,
00273 IDResolverType,
00275 TokenType,
00277 ExtensionType
00278 };
00279 };
00280
00281
00282
00283 class DLLSPEC daeAtomicTypeList {
00284 public:
00285 daeAtomicTypeList(DAE& dae);
00286 ~daeAtomicTypeList();
00287
00293 daeInt append(daeAtomicType* t);
00294
00300 const daeAtomicType* getByIndex(daeInt index);
00301
00306 daeInt getCount();
00307
00313 daeAtomicType* get(daeStringRef type);
00314
00320 daeAtomicType* get(daeEnum type);
00321
00322 private:
00323 daeAtomicTypeArray types;
00324 };
00325
00326
00331 class DLLSPEC daeBoolType : public daeAtomicType
00332 {
00333 public:
00337 daeBoolType(DAE& dae);
00338 public:
00339 virtual daeBool memoryToString(daeChar* src, std::ostringstream& dst);
00340
00341 virtual daeBool stringToMemory(daeChar* src, daeChar* dst);
00342
00343 virtual daeMemoryRef create();
00344
00345 virtual void destroy(daeMemoryRef obj);
00346
00347 virtual void copy(daeChar* src, daeChar* dst);
00348
00349 virtual daeArray* createArray();
00350 };
00351
00356 class DLLSPEC daeIntType : public daeAtomicType
00357 {
00358 public:
00362 daeIntType(DAE& dae);
00363 public:
00364 virtual daeBool memoryToString(daeChar* src, std::ostringstream& dst);
00365
00366 virtual daeMemoryRef create();
00367
00368 virtual void destroy(daeMemoryRef obj);
00369
00370 virtual void copy(daeChar* src, daeChar* dst);
00371
00372 virtual daeArray* createArray();
00373 };
00374
00379 class DLLSPEC daeLongType : public daeAtomicType
00380 {
00381 public:
00385 daeLongType(DAE& dae);
00386 public:
00387 virtual daeBool memoryToString(daeChar* src, std::ostringstream& dst);
00388
00389 virtual daeMemoryRef create();
00390
00391 virtual void destroy(daeMemoryRef obj);
00392
00393 virtual void copy(daeChar* src, daeChar* dst);
00394
00395 virtual daeArray* createArray();
00396 };
00397
00402 class DLLSPEC daeUIntType : public daeAtomicType
00403 {
00404 public:
00408 daeUIntType(DAE& dae);
00409 public:
00410 virtual daeBool memoryToString(daeChar* src, std::ostringstream& dst);
00411
00412 virtual daeMemoryRef create();
00413
00414 virtual void destroy(daeMemoryRef obj);
00415
00416 virtual void copy(daeChar* src, daeChar* dst);
00417
00418 virtual daeArray* createArray();
00419 };
00420
00425 class DLLSPEC daeULongType : public daeAtomicType
00426 {
00427 public:
00431 daeULongType(DAE& dae);
00432 public:
00433 virtual daeBool memoryToString(daeChar* src, std::ostringstream& dst);
00434
00435 virtual daeMemoryRef create();
00436
00437 virtual void destroy(daeMemoryRef obj);
00438
00439 virtual void copy(daeChar* src, daeChar* dst);
00440
00441 virtual daeArray* createArray();
00442 };
00443
00448 class DLLSPEC daeShortType : public daeAtomicType
00449 {
00450 public:
00454 daeShortType(DAE& dae);
00455 public:
00456 virtual daeBool memoryToString(daeChar* src, std::ostringstream& dst);
00457
00458 virtual daeMemoryRef create();
00459
00460 virtual void destroy(daeMemoryRef obj);
00461
00462 virtual void copy(daeChar* src, daeChar* dst);
00463
00464 virtual daeArray* createArray();
00465 };
00466
00471 class DLLSPEC daeFloatType : public daeAtomicType
00472 {
00473 public:
00477 daeFloatType(DAE& dae);
00478 public:
00479 virtual daeBool memoryToString(daeChar* src, std::ostringstream& dst);
00480
00481 virtual daeBool stringToMemory(daeChar* src, daeChar* dst);
00482
00483 virtual daeMemoryRef create();
00484
00485 virtual void destroy(daeMemoryRef obj);
00486
00487 virtual void copy(daeChar* src, daeChar* dst);
00488
00489 virtual daeArray* createArray();
00490 };
00491
00496 class DLLSPEC daeDoubleType : public daeAtomicType
00497 {
00498 public:
00502 daeDoubleType(DAE& dae);
00503 public:
00504 virtual daeBool memoryToString(daeChar* src, std::ostringstream& dst);
00505
00506 virtual daeBool stringToMemory(daeChar* src, daeChar* dst);
00507
00508 virtual daeMemoryRef create();
00509
00510 virtual void destroy(daeMemoryRef obj);
00511
00512 virtual void copy(daeChar* src, daeChar* dst);
00513
00514 virtual daeArray* createArray();
00515 };
00516
00521 class DLLSPEC daeStringRefType : public daeAtomicType
00522 {
00523 public:
00527 daeStringRefType(DAE& dae);
00528 public:
00529 virtual daeBool memoryToString(daeChar* src, std::ostringstream& dst);
00530
00531 virtual daeBool stringToMemory(daeChar* src, daeChar* dst);
00532
00533 virtual daeInt compare(daeChar* value1, daeChar* value2);
00534
00535 virtual daeMemoryRef create();
00536
00537 virtual void destroy(daeMemoryRef obj);
00538
00539 virtual void copy(daeChar* src, daeChar* dst);
00540
00541 virtual daeArray* createArray();
00542 };
00543
00549 class DLLSPEC daeTokenType : public daeStringRefType
00550 {
00551 public:
00555 daeTokenType(DAE& dae);
00556
00557 public:
00558 virtual daeBool stringToMemory(daeChar* src, daeChar* dst);
00559
00560 virtual daeMemoryRef create();
00561
00562 virtual void destroy(daeMemoryRef obj);
00563
00564 virtual void copy(daeChar* src, daeChar* dst);
00565
00566 virtual daeArray* createArray();
00567 };
00568
00573 class DLLSPEC daeElementRefType : public daeAtomicType
00574 {
00575 public:
00579 daeMetaElement* _elementType;
00580
00581 public:
00585 daeElementRefType(DAE& dae);
00586 public:
00587 virtual daeBool memoryToString(daeChar* src, std::ostringstream& dst);
00588
00589 virtual daeMemoryRef create();
00590
00591 virtual void destroy(daeMemoryRef obj);
00592
00593 virtual void copy(daeChar* src, daeChar* dst);
00594
00595 virtual daeArray* createArray();
00596 };
00597
00602 class DLLSPEC daeEnumType: public daeAtomicType
00603 {
00604 public:
00608 daeEnumArray* _values;
00612 daeStringRefArray* _strings;
00613
00614 public:
00618 daeEnumType(DAE& dae);
00619
00623 ~daeEnumType();
00624
00625 public:
00626 virtual daeBool memoryToString(daeChar* src, std::ostringstream& dst);
00627
00628 virtual daeBool stringToMemory(daeChar* src, daeChar* dst);
00629
00630 virtual daeMemoryRef create();
00631
00632 virtual void destroy(daeMemoryRef obj);
00633
00634 virtual void copy(daeChar* src, daeChar* dst);
00635
00636 virtual daeArray* createArray();
00637 };
00638
00643 class DLLSPEC daeRawRefType: public daeAtomicType
00644 {
00645 public:
00649 daeRawRefType(DAE& dae);
00650
00651 public:
00652 virtual daeBool memoryToString(daeChar* src, std::ostringstream& dst);
00653
00654 virtual daeMemoryRef create();
00655
00656 virtual void destroy(daeMemoryRef obj);
00657
00658 virtual void copy(daeChar* src, daeChar* dst);
00659
00660 virtual daeArray* createArray();
00661 };
00662
00667 class DLLSPEC daeResolverType : public daeAtomicType
00668 {
00669 public:
00673 daeResolverType(DAE& dae);
00674 public:
00675 virtual daeBool memoryToString(daeChar* src, std::ostringstream& dst);
00676
00677 virtual daeBool stringToMemory(daeChar* src, daeChar* dst);
00678
00679 virtual daeInt compare(daeChar* value1, daeChar* value2);
00680
00681 virtual daeMemoryRef create();
00682
00683 virtual void destroy(daeMemoryRef obj);
00684
00685 virtual void copy(daeChar* src, daeChar* dst);
00686
00687 virtual daeArray* createArray();
00688
00689 virtual void setDocument(daeChar* value, daeDocument* doc);
00690
00691 virtual void setDocument(daeArray& array, daeDocument* doc);
00692 };
00693
00698 class DLLSPEC daeIDResolverType : public daeAtomicType
00699 {
00700 public:
00704 daeIDResolverType(DAE& dae);
00705 public:
00706 virtual daeBool memoryToString(daeChar* src, std::ostringstream& dst);
00707
00708 virtual daeBool stringToMemory(daeChar* src, daeChar* dst);
00709
00710 virtual daeInt compare(daeChar* value1, daeChar* value2);
00711
00712 virtual daeMemoryRef create();
00713
00714 virtual void destroy(daeMemoryRef obj);
00715
00716 virtual void copy(daeChar* src, daeChar* dst);
00717
00718 virtual daeArray* createArray();
00719 };
00720
00721
00722
00723 #endif // __DAE_ATOMIC_TYPE_H__
00724
00725
00726