MCPcopy Create free account
hub / github.com/NatLabRockies/SAM / Parse

Method Parse

src/variables.cpp:2175–2260  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

2173
2174
2175bool VarValue::Parse( int type, const wxString &str, VarValue &value )
2176{
2177 switch(type)
2178 {
2179 case VV_STRING:
2180 {
2181 value.m_type = VV_STRING;
2182 value.m_str = str;
2183 return true;
2184 }
2185 case VV_NUMBER:
2186 {
2187 value.m_type = VV_NUMBER;
2188 value.m_val = wxAtof( str );
2189 return true;
2190 }
2191 case VV_ARRAY:
2192 {
2193 wxArrayString tokens = wxStringTokenize(str," ,;|", wxTOKEN_STRTOK );
2194 value.m_type = VV_ARRAY;
2195 value.m_val.resize_fill( tokens.size(), 0.0 );
2196 for (size_t i=0; i<tokens.size(); i++)
2197 value.m_val[i] = wxAtof( tokens[i] );
2198
2199 return true;
2200 }
2201 case VV_MATRIX:
2202 {
2203 wxArrayString rows = wxStringTokenize(str," []", wxTOKEN_STRTOK );
2204 if (rows.size() < 1) return false;
2205 wxArrayString cols = wxStringTokenize(rows[0], " ,;|", wxTOKEN_STRTOK );
2206 if (cols.size() < 1) return false;
2207
2208 size_t nrows = rows.size();
2209 size_t ncols = cols.size();
2210
2211 value.m_type = VV_MATRIX;
2212 value.m_val.resize_fill( nrows, ncols, 0.0 );
2213
2214 for (size_t r=0; r < nrows; r++)
2215 {
2216 cols = wxStringTokenize(rows[r], " ,;|");
2217 for (size_t c=0; c<cols.size() && c<ncols; c++)
2218 value.m_val(r,c) = wxAtof( cols[c] );
2219 }
2220 return true;
2221 }
2222 case VV_TABLE:
2223 {
2224 value.m_type = VV_TABLE;
2225 VarTable vt;
2226 wxArrayString hash = wxStringTokenize(str, "|", wxTOKEN_STRTOK);
2227 if (hash.size() < 1) return false;
2228 for (size_t i = 0; i < hash.size(); i++)
2229 {
2230 wxArrayString name_value = wxStringTokenize(hash[i], "=", wxTOKEN_STRTOK);
2231 if (name_value.Count() != 2) return false;
2232 wxArrayString name_type = wxStringTokenize(name_value[0], ":", wxTOKEN_STRTOK);

Callers 13

OnNativeEventMethod · 0.45
SaveAsSSCJSONMethod · 0.45
GeocodeGoogleMethod · 0.45
GeocodeDeveloperMethod · 0.45
StaticMapMethod · 0.45
GetResourcesMethod · 0.45
GetResourcesMethod · 0.45
QueryUtilityCompaniesMethod · 0.45
QueryUtilityRatesMethod · 0.45
ReadPythonConfigFunction · 0.45

Calls 6

hexstrtobinFunction · 0.85
resize_fillMethod · 0.80
sizeMethod · 0.80
CountMethod · 0.80
SetMethod · 0.45
ClearMethod · 0.45

Tested by

no test coverage detected