diff options
author | Mike Buland <eichlan@xagasoft.com> | 2012-01-16 22:32:56 -0700 |
---|---|---|
committer | Mike Buland <eichlan@xagasoft.com> | 2012-01-16 22:32:56 -0700 |
commit | 3afa514e11dc16e3a166b39ad411465abd971d8a (patch) | |
tree | 3fc9a9b62682c2905909e749f461034634d78903 /src/variable.cpp | |
parent | 92f50ee62101b67e768b75c9111af3d0258c6ddd (diff) | |
download | stage-17aa6057c23c8cf96136c4e2755198644d743701.tar.gz stage-17aa6057c23c8cf96136c4e2755198644d743701.tar.bz2 stage-17aa6057c23c8cf96136c4e2755198644d743701.tar.xz stage-17aa6057c23c8cf96136c4e2755198644d743701.zip |
Lists (arrays) are now properly inedxable.0.02
Diffstat (limited to 'src/variable.cpp')
-rw-r--r-- | src/variable.cpp | 20 |
1 files changed, 13 insertions, 7 deletions
diff --git a/src/variable.cpp b/src/variable.cpp index 68a1778..0c83133 100644 --- a/src/variable.cpp +++ b/src/variable.cpp | |||
@@ -113,7 +113,7 @@ Variable *Variable::getVariablePtr() const | |||
113 | return pValue; | 113 | return pValue; |
114 | } | 114 | } |
115 | 115 | ||
116 | const Variable::VariableList &Variable::getList() const | 116 | const Variable::VariableArray &Variable::getList() const |
117 | { | 117 | { |
118 | return *lValue; | 118 | return *lValue; |
119 | } | 119 | } |
@@ -233,9 +233,12 @@ Variable Variable::to( Type e ) const | |||
233 | 233 | ||
234 | void Variable::insert( const Variable &vKey, const Variable &vValue ) | 234 | void Variable::insert( const Variable &vKey, const Variable &vValue ) |
235 | { | 235 | { |
236 | if( eType != tDictionary ) | 236 | if( eType == tDictionary ) |
237 | throw Bu::ExceptionBase("Insert on non-dictionary."); | 237 | hValue->insert( vKey, vValue ); |
238 | hValue->insert( vKey, vValue ); | 238 | else if( eType == tList ) |
239 | lValue->get( vKey.getInt() ) = vValue; | ||
240 | else | ||
241 | throw Bu::ExceptionBase("Insert on non-dictionary and non-list."); | ||
239 | } | 242 | } |
240 | 243 | ||
241 | bool Variable::has( const Variable &vKey ) | 244 | bool Variable::has( const Variable &vKey ) |
@@ -244,7 +247,8 @@ bool Variable::has( const Variable &vKey ) | |||
244 | return hValue->has( vKey ); | 247 | return hValue->has( vKey ); |
245 | else if( eType == tList ) | 248 | else if( eType == tList ) |
246 | { | 249 | { |
247 | for( VariableList::const_iterator i = lValue->begin(); i; i++ ) | 250 | for( VariableArray::const_iterator i = |
251 | const_cast<const VariableArray *>(lValue)->begin(); i; i++ ) | ||
248 | { | 252 | { |
249 | if( (*i) == vKey ) | 253 | if( (*i) == vKey ) |
250 | return true; | 254 | return true; |
@@ -259,8 +263,10 @@ Variable &Variable::get( const Variable &vKey ) | |||
259 | { | 263 | { |
260 | if( eType == tDictionary ) | 264 | if( eType == tDictionary ) |
261 | return hValue->get( vKey ); | 265 | return hValue->get( vKey ); |
266 | else if( eType == tList ) | ||
267 | return lValue->get( vKey.getInt() ); | ||
262 | else | 268 | else |
263 | throw Bu::ExceptionBase("Insert on non-dictionary."); | 269 | throw Bu::ExceptionBase("Index on non-dictionary and non-list."); |
264 | } | 270 | } |
265 | 271 | ||
266 | Variable &Variable::operator=( const Variable &rhs ) | 272 | Variable &Variable::operator=( const Variable &rhs ) |
@@ -1006,7 +1012,7 @@ void Variable::initType() | |||
1006 | break; | 1012 | break; |
1007 | 1013 | ||
1008 | case tList: | 1014 | case tList: |
1009 | lValue = new VariableList(); | 1015 | lValue = new VariableArray(); |
1010 | break; | 1016 | break; |
1011 | 1017 | ||
1012 | case tDictionary: | 1018 | case tDictionary: |