diff options
| author | Mike Buland <eichlan@xagasoft.com> | 2012-11-05 22:41:51 +0000 |
|---|---|---|
| committer | Mike Buland <eichlan@xagasoft.com> | 2012-11-05 22:41:51 +0000 |
| commit | ec05778d5718a7912e506764d443a78d6a6179e3 (patch) | |
| tree | 78a9a01532180030c095acefc45763f07c14edb8 /src/stable/variant.cpp | |
| parent | b20414ac1fe80a71a90601f4cd1767fa7014a9ba (diff) | |
| download | libbu++-ec05778d5718a7912e506764d443a78d6a6179e3.tar.gz libbu++-ec05778d5718a7912e506764d443a78d6a6179e3.tar.bz2 libbu++-ec05778d5718a7912e506764d443a78d6a6179e3.tar.xz libbu++-ec05778d5718a7912e506764d443a78d6a6179e3.zip | |
Converted tabs to spaces with tabconv.
Diffstat (limited to '')
| -rw-r--r-- | src/stable/variant.cpp | 92 |
1 files changed, 46 insertions, 46 deletions
diff --git a/src/stable/variant.cpp b/src/stable/variant.cpp index 674ae04..d724fa7 100644 --- a/src/stable/variant.cpp +++ b/src/stable/variant.cpp | |||
| @@ -11,7 +11,7 @@ | |||
| 11 | 11 | ||
| 12 | namespace Bu | 12 | namespace Bu |
| 13 | { | 13 | { |
| 14 | Formatter &operator<<( Formatter &f, const String &s ); | 14 | Formatter &operator<<( Formatter &f, const String &s ); |
| 15 | }; | 15 | }; |
| 16 | 16 | ||
| 17 | Bu::VariantTypeRoot::VariantTypeRoot() | 17 | Bu::VariantTypeRoot::VariantTypeRoot() |
| @@ -23,84 +23,84 @@ Bu::VariantTypeRoot::~VariantTypeRoot() | |||
| 23 | } | 23 | } |
| 24 | 24 | ||
| 25 | Bu::Variant::Variant() : | 25 | Bu::Variant::Variant() : |
| 26 | pCore( NULL ) | 26 | pCore( NULL ) |
| 27 | { | 27 | { |
| 28 | } | 28 | } |
| 29 | 29 | ||
| 30 | Bu::Variant::Variant( const Variant &v ) : | 30 | Bu::Variant::Variant( const Variant &v ) : |
| 31 | pCore( NULL ) | 31 | pCore( NULL ) |
| 32 | { | 32 | { |
| 33 | if( v.pCore ) | 33 | if( v.pCore ) |
| 34 | { | 34 | { |
| 35 | pCore = v.pCore->clone(); | 35 | pCore = v.pCore->clone(); |
| 36 | } | 36 | } |
| 37 | } | 37 | } |
| 38 | 38 | ||
| 39 | Bu::Variant::Variant( const char *t ) : | 39 | Bu::Variant::Variant( const char *t ) : |
| 40 | pCore( NULL ) | 40 | pCore( NULL ) |
| 41 | { | 41 | { |
| 42 | set( Bu::String( t ) ); | 42 | set( Bu::String( t ) ); |
| 43 | } | 43 | } |
| 44 | 44 | ||
| 45 | Bu::Variant::~Variant() | 45 | Bu::Variant::~Variant() |
| 46 | { | 46 | { |
| 47 | if( pCore ) | 47 | if( pCore ) |
| 48 | { | 48 | { |
| 49 | delete pCore; | 49 | delete pCore; |
| 50 | pCore = NULL; | 50 | pCore = NULL; |
| 51 | } | 51 | } |
| 52 | } | 52 | } |
| 53 | 53 | ||
| 54 | Bu::String Bu::Variant::toString() const | 54 | Bu::String Bu::Variant::toString() const |
| 55 | { | 55 | { |
| 56 | if( getType() == typeid( Bu::String ) ) | 56 | if( getType() == typeid( Bu::String ) ) |
| 57 | { | 57 | { |
| 58 | return get<Bu::String>(); | 58 | return get<Bu::String>(); |
| 59 | } | 59 | } |
| 60 | else | 60 | else |
| 61 | { | 61 | { |
| 62 | Bu::MemBuf mb; | 62 | Bu::MemBuf mb; |
| 63 | Bu::Formatter f( mb ); | 63 | Bu::Formatter f( mb ); |
| 64 | f << *this; | 64 | f << *this; |
| 65 | return mb.getString(); | 65 | return mb.getString(); |
| 66 | } | 66 | } |
| 67 | } | 67 | } |
| 68 | 68 | ||
| 69 | bool Bu::Variant::isSet() const | 69 | bool Bu::Variant::isSet() const |
| 70 | { | 70 | { |
| 71 | return pCore != NULL; | 71 | return pCore != NULL; |
| 72 | } | 72 | } |
| 73 | 73 | ||
| 74 | const std::type_info &Bu::Variant::getType() const | 74 | const std::type_info &Bu::Variant::getType() const |
| 75 | { | 75 | { |
| 76 | if( !pCore ) | 76 | if( !pCore ) |
| 77 | { | 77 | { |
| 78 | throw Bu::ExceptionBase("No data!"); | 78 | throw Bu::ExceptionBase("No data!"); |
| 79 | } | 79 | } |
| 80 | return pCore->getType(); | 80 | return pCore->getType(); |
| 81 | } | 81 | } |
| 82 | 82 | ||
| 83 | Bu::Variant &Bu::Variant::operator=( const Bu::Variant &rhs ) | 83 | Bu::Variant &Bu::Variant::operator=( const Bu::Variant &rhs ) |
| 84 | { | 84 | { |
| 85 | if( pCore ) | 85 | if( pCore ) |
| 86 | { | 86 | { |
| 87 | delete pCore; | 87 | delete pCore; |
| 88 | pCore = NULL; | 88 | pCore = NULL; |
| 89 | } | 89 | } |
| 90 | if( rhs.pCore ) | 90 | if( rhs.pCore ) |
| 91 | { | 91 | { |
| 92 | pCore = rhs.pCore->clone(); | 92 | pCore = rhs.pCore->clone(); |
| 93 | } | 93 | } |
| 94 | 94 | ||
| 95 | return *this; | 95 | return *this; |
| 96 | } | 96 | } |
| 97 | 97 | ||
| 98 | Bu::Formatter &Bu::operator<<( Bu::Formatter &f, const Bu::Variant &v ) | 98 | Bu::Formatter &Bu::operator<<( Bu::Formatter &f, const Bu::Variant &v ) |
| 99 | { | 99 | { |
| 100 | if( !v.pCore ) | 100 | if( !v.pCore ) |
| 101 | return f << "(null)"; | 101 | return f << "(null)"; |
| 102 | 102 | ||
| 103 | v.pCore->format( f ); | 103 | v.pCore->format( f ); |
| 104 | return f; | 104 | return f; |
| 105 | } | 105 | } |
| 106 | 106 | ||
