44 | | CHECK_UITYPE ( S,TypeArray ); |
45 | | vec tmp; |
46 | | tmp.set_size ( S.getLength() ); |
47 | | for ( int i=0;i<S.getLength();i++ ) { |
48 | | switch ( S[i].getType() ) { |
49 | | case Setting::TypeFloat : |
50 | | tmp[i]=double ( S[i] );break; |
51 | | case Setting::TypeInt : |
52 | | tmp[i]=int ( S[i] );break; |
53 | | case Setting::TypeBoolean : |
54 | | tmp[i]=bool ( S[i] );break; |
55 | | default: it_error ( "libconfig error?" ); |
56 | | } |
57 | | } |
58 | | return tmp; |
| 44 | vec vector; |
| 45 | if (S.getType() == Setting::TypeArray) { |
| 46 | vector.set_size ( S.getLength() ); |
| 47 | for ( int i=0;i<S.getLength();i++ ) { |
| 48 | switch ( S[i].getType() ) { |
| 49 | case Setting::TypeFloat : |
| 50 | vector[i]=double ( S[i] );break; |
| 51 | case Setting::TypeInt : |
| 52 | vector[i]=int ( S[i] );break; |
| 53 | case Setting::TypeBoolean : |
| 54 | vector[i]=bool ( S[i] );break; |
| 55 | default: it_error ( "libconfig error?" ); |
| 56 | } |
| 57 | } |
| 58 | } else if (S.getType() == Setting::TypeGroup) { |
| 59 | vector = getvec(S["elements"]); |
| 60 | int cols = S["cols"]; |
| 61 | if (vector.length() != cols) { |
| 62 | it_error("requested vector is a matrix"); |
| 63 | } |
| 64 | } else { |
| 65 | it_error("requested vector has invalid type"); |
| 66 | } |
| 67 | return vector; |