MCPcopy Create free account
hub / github.com/FreeCAD/FreeCAD / getLineDefinitions

Method getLineDefinitions

src/Mod/TechDraw/App/LineGenerator.cpp:237–269  ·  view source on GitHub ↗

load the line definition file into memory

Source from the content-addressed store, hash-verified

235
236//! load the line definition file into memory
237std::vector< std::vector<std::string> > LineGenerator::getLineDefinitions()
238{
239 std::vector< std::vector<std::string> > lineDefs;
240 std::string record;
241 Base::FileInfo fi(Preferences::currentLineDefFile());
242 Base::ifstream inFile(fi, std::ifstream::in);
243 if(!inFile.is_open()) {
244 Base::Console().message( "Cannot open line def file: %s\n", fi.filePath().c_str());
245 return lineDefs;
246 }
247
248 std::string line;
249 while ( std::getline(inFile, line) ) {
250 if (line.empty() ||
251 line.at(0) == '#') {
252 // this is a comment or a blank line, ignore it
253 continue;
254 }
255 // strip out any null tokens that may be caused by trailing ',' in the input
256 std::vector<std::string> validTokens;
257 for (auto& token : DU::tokenize(line, ",")) {
258 if (!token.empty()) {
259 validTokens.emplace_back(token);
260 }
261 }
262 std::vector<std::string> lineDefRow;
263 lineDefRow.insert(lineDefRow.end(), validTokens.begin()+2, validTokens.end());
264 lineDefs.push_back(lineDefRow);
265 }
266
267 inFile.close();
268 return lineDefs;
269}
270
271//! retrieve a sorted list of available line definition files.
272std::vector<std::string> LineGenerator::getAvailableLineStandards()

Callers

nothing calls this directly

Calls 12

getlineFunction · 0.85
tokenizeFunction · 0.85
atMethod · 0.80
messageMethod · 0.45
c_strMethod · 0.45
filePathMethod · 0.45
emptyMethod · 0.45
insertMethod · 0.45
endMethod · 0.45
beginMethod · 0.45
push_backMethod · 0.45
closeMethod · 0.45

Tested by

no test coverage detected