int testEscapedChars() { int out = 0; int lctr; int N = 1000; LOOP { MinVR::VRDataIndex *n = setupIndex(); // Escaping the comma separator between Gamma and Delta. std::string inString = "<mimi type=\"stringarray\" separator=\",\">Alpha,Beta,Gamma\\,Delta,Epsilon</mimi>"; n->addSerializedValue(inString, MinVR::VRDataIndex::rootNameSpace); MinVR::VRStringArray s = n->getValue("/mimi"); out += (s.size() == 4) ? 0 : 1; out += s[0].compare("Alpha"); out += s[1].compare("Beta"); out += s[2].compare("Gamma,Delta"); out += s[3].compare("Epsilon"); // std::cout << inString << std::endl; // std::cout << s[0] << "/" << s[1] << "/" << s[2] << "/" << s[3] << "/" << std::endl; delete n; } return out; }
int doTheRealWork(int argc, char **argv) { MinVR::VRDataIndex *index = new MinVR::VRDataIndex; // These will be extracted from argv. int nth = 0; // Extracting... switch(argc) { case 1: printHelpMessage(); return EXIT_SUCCESS; case 2: if (argv[1][0] == '-') { printHelpMessage(); return EXIT_SUCCESS; } throw std::runtime_error("Need a data name. (Try --usage.)"); break; case 3: // Don't really need to do anything here except avoid throwing error. break; case 4: // If there is a fourth arg, hope it's an integer. sscanf(argv[3], "%d", &nth); break; default: throw std::runtime_error("Too many arguments"); break; } index->processXMLFile(argv[1], std::string("/")); MinVR::VRCORETYPE_ID tp = index->getType(argv[2]); // std::cout << "datumName:" << datumName << " N:" << nth << " tp:" << tp << std::endl; // Now print out the values, according to the data type. switch(tp) { case MinVR::VRCORETYPE_INT: std::cout << (MinVR::VRInt)index->getValue(argv[2]); break; case MinVR::VRCORETYPE_FLOAT: std::cout << (MinVR::VRFloat)index->getValue(argv[2]); break; case MinVR::VRCORETYPE_STRING: std::cout << (MinVR::VRString)index->getValue(argv[2]); break; case MinVR::VRCORETYPE_INTARRAY: { MinVR::VRIntArray ia = index->getValue(argv[2]); if (nth >= (int)ia.size()) throw std::runtime_error("N too large for array"); std::cout << ia[nth]; break; } case MinVR::VRCORETYPE_FLOATARRAY: { MinVR::VRFloatArray ia = index->getValue(argv[2]); if (nth >= (int)ia.size()) throw std::runtime_error("N too large for array"); std::cout << ia[nth]; break; } case MinVR::VRCORETYPE_STRINGARRAY: { MinVR::VRStringArray ia = index->getValue(argv[2]); if (nth >= (int)ia.size()) throw std::runtime_error("N too large for array"); std::cout << ia[nth]; break; } case MinVR::VRCORETYPE_CONTAINER: std::cout << index->serialize(argv[2]); break; default: throw std::runtime_error("Not supported for that type."); return EXIT_FAILURE; } return EXIT_SUCCESS; }