Пример #1
0
ff::ComPtr<ff::IData> ff::Dict::GetData(ff::StringRef name) const
{
	Value *value = GetValue(name);
	ValuePtr dataValue;

	if (value && value->Convert(Value::Type::Data, &dataValue))
	{
		return dataValue->AsData();
	}

	return nullptr;
}
Пример #2
0
void ff::DumpDict(ff::StringRef name, const Dict &dict, Log *log, bool chain, bool debugOnly)
{
	if (debugOnly && !GetThisModule().IsDebugBuild())
	{
		return;
	}

	Log extraLog;
	Log &realLog = log ? *log : extraLog;

	realLog.TraceF(L"+- Options for: %s --\r\n", name.c_str());

	Vector<String> names = dict.GetAllNames(chain, true, false);
	for (const String &key: names)
	{
		Value *value = dict.GetValue(key, chain);
		assert(value);

		String valueString;
		ValuePtr convertedValue;

		if (value->Convert(ff::Value::Type::String, &convertedValue))
		{
			valueString = convertedValue->AsString();
		}
		else if (value->Convert(ff::Value::Type::StringVector, &convertedValue))
		{
			Vector<String> &strs = convertedValue->AsStringVector();

			for (size_t i = 0; i < strs.Size(); i++)
			{
				valueString += String::format_new(L"\r\n|    [%lu]: %s", i, strs[i].c_str());
			}
		}
		else if (value->Convert(ff::Value::Type::Data, &convertedValue))
		{
			valueString.format(L"<data[%lu]>", convertedValue->AsData()->GetSize());
		}
		else
		{
			valueString = L"<data>";
		}

		realLog.TraceF(L"| %s: %s\r\n", key.c_str(), valueString.c_str());
	}

	realLog.Trace(L"+- Done --\r\n");
}