MCPcopy Create free account
hub / github.com/OpenDungeons/OpenDungeons / readFileWithoutComments

Function readFileWithoutComments

source/utils/Helper.cpp:164–189  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

162 }
163
164 bool readFileWithoutComments(const std::string& fileName, std::stringstream& stream)
165 {
166 // Try to open the input file for reading and throw an error if we can't.
167 std::ifstream baseLevelFile(fileName.c_str(), std::ifstream::in);
168 if (!baseLevelFile.good())
169 {
170 OD_LOG_WRN("File not found=" + fileName);
171 return false;
172 }
173
174 // Read in the whole baseLevelFile, strip it of comments and feed it into
175 // the stream.
176 std::string nextParam;
177 while (baseLevelFile.good())
178 {
179 std::getline(baseLevelFile, nextParam);
180 /* Find the first occurrence of the comment symbol on the
181 * line and return everything before that character.
182 */
183 stream << nextParam.substr(0, nextParam.find('#')) << "\n";
184 }
185
186 baseLevelFile.close();
187
188 return true;
189 }
190
191 bool readNextLineNotEmpty(std::istream& is, std::string& line)
192 {

Callers 14

loadGlobalConfigMethod · 0.85
loadEquipementsMethod · 0.85
loadSpawnConditionsMethod · 0.85
loadFactionsMethod · 0.85
loadRoomsMethod · 0.85
loadTrapsMethod · 0.85
loadSpellConfigMethod · 0.85
loadSkillsMethod · 0.85
loadTilesetsMethod · 0.85
loadUserConfigMethod · 0.85
readSceneMenuMethod · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected