MCPcopy Create free account
hub / github.com/AcademySoftwareFoundation/OpenColorIO / read

Method read

src/OpenColorIO/fileformats/FileFormat3DL.cpp:236–485  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

234// Raise an exception if it can't be loaded.
235
236CachedFileRcPtr LocalFileFormat::read(std::istream & istream,
237 const std::string & /* fileName unused */,
238 Interpolation interp) const
239{
240 std::vector<int> rawshaper;
241 std::vector<int> raw3d;
242
243 int lut3dmax = 0;
244
245 // Parse the file 3D LUT data to an int array.
246 {
247 const int MAX_LINE_SIZE = 4096;
248 char lineBuffer[MAX_LINE_SIZE];
249
250 StringUtils::StringVec lineParts;
251 std::vector<int> tmpData;
252
253 int lineNumber = 0;
254
255 while(istream.good())
256 {
257 istream.getline(lineBuffer, MAX_LINE_SIZE);
258 ++lineNumber;
259
260 // Strip and split the line.
261 lineParts = StringUtils::SplitByWhiteSpaces(StringUtils::Trim(lineBuffer));
262
263 if(lineParts.empty()) continue;
264 if (lineParts.size() > 0)
265 {
266 if (StringUtils::StartsWith(lineParts[0], '#'))
267 {
268 continue;
269 }
270 if (StringUtils::StartsWith(lineParts[0], '<'))
271 {
272 // Format error: reject files that could be
273 // formatted as xml.
274 std::ostringstream os;
275 os << "Error parsing .3dl file. ";
276 os << "Not expecting a line starting with \"<\".";
277 os << "Line (" << lineNumber << "): '";
278 os << lineBuffer << "'.";
279 throw Exception(os.str().c_str());
280 }
281 }
282
283 // If we haven't found a list of ints, continue.
284 if (!StringVecToIntVec(tmpData, lineParts))
285 {
286 // Some keywords are valid (3DMESH, mesh, gamma, LUT*)
287 // but others could be format error.
288 // To preserve v1 behavior, don't reject them.
289 continue;
290 }
291
292 // If we've found more than 3 ints, and dont have
293 // a shaper LUT yet, we've got it!

Callers

nothing calls this directly

Calls 14

SplitByWhiteSpacesFunction · 0.85
StartsWithFunction · 0.85
StringVecToIntVecFunction · 0.85
GetLikelyLutBitDepthFunction · 0.85
GetOCIOBitdepthFunction · 0.85
GetBitDepthMaxValueFunction · 0.85
IsIdentityFunction · 0.70
TrimFunction · 0.50
emptyMethod · 0.45
sizeMethod · 0.45
push_backMethod · 0.45

Tested by

no test coverage detected