MCPcopy Create free account
hub / github.com/assimp/assimp / ReadFile

Method ReadFile

code/AssetLib/STEPParser/STEPFileReader.cpp:165–299  ·  view source on GitHub ↗

------------------------------------------------------------------------------------------------

Source from the content-addressed store, hash-verified

163
164// ------------------------------------------------------------------------------------------------
165void STEP::ReadFile(DB& db,const EXPRESS::ConversionSchema& scheme,
166 const char* const* types_to_track, size_t len,
167 const char* const* inverse_indices_to_track, size_t len2)
168{
169 db.SetSchema(scheme);
170 db.SetTypesToTrack(types_to_track,len);
171 db.SetInverseIndicesToTrack(inverse_indices_to_track,len2);
172
173 const DB::ObjectMap& map = db.GetObjects();
174 LineSplitter& splitter = db.GetSplitter();
175
176 while (splitter) {
177 bool has_next = false;
178 std::string s = *splitter;
179 if (s == "ENDSEC;") {
180 break;
181 }
182 s.erase(std::remove(s.begin(), s.end(), ' '), s.end());
183
184 // want one-based line numbers for human readers, so +1
185 const uint64_t line = splitter.get_index()+1;
186 // LineSplitter already ignores empty lines
187 ai_assert(s.length());
188 if (s[0] != '#') {
189 ASSIMP_LOG_WARN(AddLineNumber("expected token \'#\'",line));
190 ++splitter;
191 continue;
192 }
193 // ---
194 // extract id, entity class name and argument string,
195 // but don't create the actual object yet.
196 // ---
197 const std::string::size_type n0 = s.find_first_of('=');
198 if (n0 == std::string::npos) {
199 ASSIMP_LOG_WARN(AddLineNumber("expected token \'=\'",line));
200 ++splitter;
201 continue;
202 }
203
204 const uint64_t id = strtoul10_64(s.substr(1,n0-1).c_str());
205 if (!id) {
206 ASSIMP_LOG_WARN(AddLineNumber("expected positive, numeric entity id",line));
207 ++splitter;
208 continue;
209 }
210 std::string::size_type n1 = s.find_first_of('(',n0);
211 if (n1 == std::string::npos) {
212 has_next = true;
213 bool ok = false;
214 for( ++splitter; splitter; ++splitter) {
215 const std::string& snext = *splitter;
216 if (snext.empty()) {
217 continue;
218 }
219
220 // the next line doesn't start an entity, so maybe it is
221 // just a continuation for this line, keep going
222 if (!IsEntityDef(snext)) {

Callers

nothing calls this directly

Calls 15

removeFunction · 0.85
AddLineNumberFunction · 0.85
strtoul10_64Function · 0.85
IsEntityDefFunction · 0.85
ai_tolowerFunction · 0.85
SetTypesToTrackMethod · 0.80
eraseMethod · 0.80
get_indexMethod · 0.80
appendMethod · 0.80
atMethod · 0.80

Tested by

no test coverage detected