MCPcopy Create free account
hub / github.com/Illation/ETEngine / ParseLine

Method ParseLine

Engine/source/EtCore/FileSystem/FileUtil.cpp:94–123  ·  view source on GitHub ↗

--------------------------------- FileUtil::ParseLine Removes one line from the input string and places it in the referenced extractedLine - returns false if no line could be extracted

Source from the content-addressed store, hash-verified

92// - returns false if no line could be extracted
93//
94bool FileUtil::ParseLine(std::string &input, std::string &extractedLine)
95{
96 if (input.size() == 0)
97 {
98 return false;
99 }
100
101 int32 closestIdx = std::numeric_limits<int32>::max();
102 uint32 tokenSize = 0;
103 for (auto token : newLineTokens)
104 {
105 int32 index = (int32)input.find(token);
106 if (index != std::string::npos && index < closestIdx)
107 {
108 closestIdx = index;
109 tokenSize = (uint32)token.size();
110 }
111 }
112
113 if (closestIdx != std::string::npos && static_cast<uint32>(closestIdx) < input.size())
114 {
115 extractedLine = input.substr(0, closestIdx);
116 input = input.substr(closestIdx + tokenSize);
117 if (input.size() == 0) input = "";
118 return true;
119 }
120 extractedLine = input;
121 input = "";
122 return true;
123}
124
125//---------------------------------
126// FileUtil::ParseLines

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected