MCPcopy Create free account
hub / github.com/NatronGitHub/Natron / decodeFromKnobTableFormat

Method decodeFromKnobTableFormat

Engine/KnobTypes.cpp:2374–2461  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

2372}
2373
2374void
2375KnobTable::decodeFromKnobTableFormat(const std::string& value,
2376 std::list<std::vector<std::string> >* table)
2377{
2378 QString raw = QString::fromUtf8( value.c_str() );
2379
2380 if ( raw.isEmpty() ) {
2381 return;
2382 }
2383 const int colsCount = getColumnsCount();
2384 assert(colsCount > 0);
2385
2386
2387 QString startTag = QString::fromUtf8("<%1>");
2388 QString endTag = QString::fromUtf8("</%1>");
2389 int lastFoundIndex = 0;
2390
2391 for (;; ) {
2392 int colIndex = 0;
2393 std::vector<std::string> row;
2394 bool mustStop = false;
2395 while (colIndex < colsCount) {
2396 QString colLabel = QString::fromUtf8( getColumnLabel(colIndex).c_str() );
2397 const QString startToFind = startTag.arg(colLabel);
2398 const QString endToFind = endTag.arg(colLabel);
2399
2400 lastFoundIndex = raw.indexOf(startToFind, lastFoundIndex);
2401 if (lastFoundIndex == -1) {
2402 mustStop = true;
2403 break;
2404 }
2405
2406 lastFoundIndex += startToFind.size();
2407 assert( lastFoundIndex < raw.size() );
2408
2409 int endNamePos = raw.indexOf(endToFind, lastFoundIndex);
2410 assert( endNamePos != -1 && endNamePos < raw.size() );
2411
2412 if ( (endNamePos == -1) || ( endNamePos >= raw.size() ) ) {
2413 KnobHolder* holder = dynamic_cast<KnobHolder*>(getHolder());
2414 QString knobName;
2415 if (holder) {
2416 EffectInstance* effect = dynamic_cast<EffectInstance*>(holder);
2417 if (effect) {
2418 knobName += QString::fromUtf8(effect->getNode()->getFullyQualifiedName().c_str());
2419 knobName += QString::fromUtf8(".");
2420 }
2421 }
2422 knobName += QString::fromUtf8(getName().c_str());
2423 QString err = tr("%1 table is wrongly encoded, check your project file or report an issue to the developers").arg(knobName);
2424 throw std::logic_error(err.toStdString());
2425 }
2426
2427 std::string value = raw.mid(lastFoundIndex, endNamePos - lastFoundIndex).toStdString();
2428 lastFoundIndex += (endNamePos - lastFoundIndex);
2429
2430
2431 // In order to use XML tags, the text inside the tags has to be unescaped.

Callers 4

tableChangedMethod · 0.80
tableChangedMethod · 0.80

Calls 7

getNameFunction · 0.85
toStdStringMethod · 0.80
isEmptyMethod · 0.45
sizeMethod · 0.45
getFullyQualifiedNameMethod · 0.45
getNodeMethod · 0.45
push_backMethod · 0.45

Tested by

no test coverage detected