}\r
shared_ptr<ItemGO> FileItemDAO::CreatePotionFromLine(const string &line) const\r
{\r
+ assert(!line.empty());\r
shared_ptr<PotionGO> spPotion = shared_ptr<PotionGO>(new PotionGO());\r
+ map<Modifiers::Modifier, Range> modifiers;\r
+ boost::char_separator<char> sep("~", 0, boost::keep_empty_tokens);\r
+ tokenizer tokens(line, sep);\r
+ tokenizer::iterator tok_iter = tokens.begin();\r
+\r
+ tok_iter++;\r
+ if (tok_iter == tokens.end())\r
+ {\r
+ throw DataLayerException(str(format("Corrupt %1% file. Missing information on line %2%") %\r
+ mFilename % line), __FILE__, __LINE__);\r
+ }\r
+ spPotion->Id(FileId::CreateItemId((*tok_iter)));\r
+\r
+ tok_iter++;\r
+ if (tok_iter == tokens.end())\r
+ {\r
+ throw DataLayerException(str(format("Corrupt %1% file. Missing information on line %2%") %\r
+ mFilename % line), __FILE__, __LINE__);\r
+ }\r
+\r
+ spPotion->Name((*tok_iter));\r
+\r
+ tok_iter++;\r
+ if (tok_iter == tokens.end())\r
+ {\r
+ throw DataLayerException(str(format("Corrupt %1% file. Missing information on line %2%") %\r
+ mFilename % line), __FILE__, __LINE__);\r
+ }\r
+ spPotion->Price(lexical_cast<unsigned long int>((*tok_iter)));\r
+\r
+ tok_iter++;\r
+ if (tok_iter == tokens.end())\r
+ {\r
+ throw DataLayerException(str(format("Corrupt %1% file. Missing information on line %2%") %\r
+ mFilename % line), __FILE__, __LINE__);\r
+ }\r
+ spPotion->Uses(lexical_cast<int>((*tok_iter)));\r
+\r
+ tok_iter++;\r
+ if (tok_iter == tokens.end())\r
+ {\r
+ throw DataLayerException(str(format("Corrupt %1% file. Missing information on line %2%") %\r
+ mFilename % line), __FILE__, __LINE__);\r
+ }\r
+ int low = lexical_cast<int>((*tok_iter));\r
+ tok_iter++;\r
+ if (tok_iter == tokens.end())\r
+ {\r
+ throw DataLayerException(str(format("Corrupt %1% file. Missing information on line %2%") %\r
+ mFilename % line), __FILE__, __LINE__);\r
+ }\r
+ int high = lexical_cast<int>((*tok_iter));\r
+ modifiers[Modifiers::strength] = Range(high, low);\r
+ tok_iter++;\r
+ if (tok_iter == tokens.end())\r
+ {\r
+ throw DataLayerException(str(format("Corrupt %1% file. Missing information on line %2%") %\r
+ mFilename % line), __FILE__, __LINE__);\r
+ }\r
+ low = lexical_cast<int>((*tok_iter));\r
+ tok_iter++;\r
+ if (tok_iter == tokens.end())\r
+ {\r
+ throw DataLayerException(str(format("Corrupt %1% file. Missing information on line %2%") %\r
+ mFilename % line), __FILE__, __LINE__);\r
+ }\r
+ high = lexical_cast<int>((*tok_iter));\r
+ modifiers[Modifiers::defense] = Range(high, low);\r
+\r
+ tok_iter++;\r
+ if (tok_iter == tokens.end())\r
+ {\r
+ throw DataLayerException(str(format("Corrupt %1% file. Missing information on line %2%") %\r
+ mFilename % line), __FILE__, __LINE__);\r
+ }\r
+ low = lexical_cast<int>((*tok_iter));\r
+ tok_iter++;\r
+ if (tok_iter == tokens.end())\r
+ {\r
+ throw DataLayerException(str(format("Corrupt %1% file. Missing information on line %2%") %\r
+ mFilename % line), __FILE__, __LINE__);\r
+ }\r
+ high = lexical_cast<int>((*tok_iter));\r
+ modifiers[Modifiers::maxhealth] = Range(high, low);\r
+\r
+ tok_iter++;\r
+ if (tok_iter == tokens.end())\r
+ {\r
+ throw DataLayerException(str(format("Corrupt %1% file. Missing information on line %2%") %\r
+ mFilename % line), __FILE__, __LINE__);\r
+ }\r
+ low = lexical_cast<int>((*tok_iter));\r
+ tok_iter++;\r
+ if (tok_iter == tokens.end())\r
+ {\r
+ throw DataLayerException(str(format("Corrupt %1% file. Missing information on line %2%") %\r
+ mFilename % line), __FILE__, __LINE__);\r
+ }\r
+ high = lexical_cast<int>((*tok_iter));\r
+ modifiers[Modifiers::health] = Range(high, low);\r
+\r
+ tok_iter++;\r
+ if (tok_iter == tokens.end())\r
+ {\r
+ throw DataLayerException(str(format("Corrupt %1% file. Missing information on line %2%") %\r
+ mFilename % line), __FILE__, __LINE__);\r
+ }\r
+ low = lexical_cast<int>((*tok_iter));\r
+ tok_iter++;\r
+ if (tok_iter == tokens.end())\r
+ {\r
+ throw DataLayerException(str(format("Corrupt %1% file. Missing information on line %2%") %\r
+ mFilename % line), __FILE__, __LINE__);\r
+ }\r
+ high = lexical_cast<int>((*tok_iter));\r
+ modifiers[Modifiers::forestfights] = Range(high, low);\r
+\r
+ tok_iter++;\r
+ if (tok_iter == tokens.end())\r
+ {\r
+ throw DataLayerException(str(format("Corrupt %1% file. Missing information on line %2%") %\r
+ mFilename % line), __FILE__, __LINE__);\r
+ }\r
+ low = lexical_cast<int>((*tok_iter));\r
+ tok_iter++;\r
+ if (tok_iter == tokens.end())\r
+ {\r
+ throw DataLayerException(str(format("Corrupt %1% file. Missing information on line %2%") %\r
+ mFilename % line), __FILE__, __LINE__);\r
+ }\r
+ high = lexical_cast<int>((*tok_iter));\r
+ modifiers[Modifiers::playerfights] = Range(high, low);\r
+\r
+ tok_iter++;\r
+ if (tok_iter == tokens.end())\r
+ {\r
+ throw DataLayerException(str(format("Corrupt %1% file. Missing information on line %2%") %\r
+ mFilename % line), __FILE__, __LINE__);\r
+ }\r
+ low = lexical_cast<int>((*tok_iter));\r
+ tok_iter++;\r
+ if (tok_iter == tokens.end())\r
+ {\r
+ throw DataLayerException(str(format("Corrupt %1% file. Missing information on line %2%") %\r
+ mFilename % line), __FILE__, __LINE__);\r
+ }\r
+ high = lexical_cast<int>((*tok_iter));\r
+ modifiers[Modifiers::gold] = Range(high, low);\r
+\r
+ tok_iter++;\r
+ if (tok_iter == tokens.end())\r
+ {\r
+ throw DataLayerException(str(format("Corrupt %1% file. Missing information on line %2%") %\r
+ mFilename % line), __FILE__, __LINE__);\r
+ }\r
+ low = lexical_cast<int>((*tok_iter));\r
+ tok_iter++;\r
+ if (tok_iter == tokens.end())\r
+ {\r
+ throw DataLayerException(str(format("Corrupt %1% file. Missing information on line %2%") %\r
+ mFilename % line), __FILE__, __LINE__);\r
+ }\r
+ high = lexical_cast<int>((*tok_iter));\r
+ modifiers[Modifiers::bank] = Range(high, low);\r
\r
return spPotion;\r
}\r