summaryrefslogtreecommitdiff
path: root/src/variable.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'src/variable.cpp')
-rw-r--r--src/variable.cpp35
1 files changed, 33 insertions, 2 deletions
diff --git a/src/variable.cpp b/src/variable.cpp
index 1e5cc9b..1100c84 100644
--- a/src/variable.cpp
+++ b/src/variable.cpp
@@ -55,6 +55,12 @@ Variable::Variable( const Bu::String &sValue ) :
55 this->sValue = new Bu::String( sValue ); 55 this->sValue = new Bu::String( sValue );
56} 56}
57 57
58Variable::Variable( Variable *pValue ) :
59 eType( tVarPtr ),
60 pValue( pValue )
61{
62}
63
58Variable::~Variable() 64Variable::~Variable()
59{ 65{
60 deinitType(); 66 deinitType();
@@ -102,6 +108,16 @@ VariableRef Variable::getVariableRef() const
102 return *rValue; 108 return *rValue;
103} 109}
104 110
111Variable *Variable::getVariablePtr() const
112{
113 return pValue;
114}
115
116const Variable::VariableHash &Variable::getHash() const
117{
118 return *hValue;
119}
120
105Variable Variable::to( Type e ) const 121Variable Variable::to( Type e ) const
106{ 122{
107 if( e == eType ) 123 if( e == eType )
@@ -227,6 +243,14 @@ bool Variable::has( const Variable &vKey )
227 throw Bu::ExceptionBase("Insert on non-dictionary."); 243 throw Bu::ExceptionBase("Insert on non-dictionary.");
228} 244}
229 245
246Variable &Variable::get( const Variable &vKey )
247{
248 if( eType == tDictionary )
249 return hValue->get( vKey );
250 else
251 throw Bu::ExceptionBase("Insert on non-dictionary.");
252}
253
230Variable &Variable::operator=( const Variable &rhs ) 254Variable &Variable::operator=( const Variable &rhs )
231{ 255{
232 deinitType(); 256 deinitType();
@@ -266,6 +290,10 @@ Variable &Variable::operator=( const Variable &rhs )
266 case tDictionary: 290 case tDictionary:
267 (*hValue) = *rhs.hValue; 291 (*hValue) = *rhs.hValue;
268 break; 292 break;
293
294 case tVarPtr:
295 pValue = rhs.pValue;
296 break;
269 } 297 }
270} 298}
271 299
@@ -725,11 +753,11 @@ void Variable::initType()
725 break; 753 break;
726 754
727 case tList: 755 case tList:
728 lValue = new VList(); 756 lValue = new VariableList();
729 break; 757 break;
730 758
731 case tDictionary: 759 case tDictionary:
732 hValue = new VHash(); 760 hValue = new VariableHash();
733 break; 761 break;
734 } 762 }
735} 763}
@@ -821,6 +849,9 @@ Bu::Formatter &operator<<( Bu::Formatter &f, const Variable &v )
821 849
822 case Variable::tDictionary: 850 case Variable::tDictionary:
823 return f << *v.hValue; 851 return f << *v.hValue;
852
853 case Variable::tVarPtr:
854 return f << "(varptr:" << *v.pValue << ")";
824 } 855 }
825 856
826 return f << "ERROR"; 857 return f << "ERROR";