Esempio n. 1
0
// *****************************************************************************
std::string PodNode::asString() const
{
    std::ostringstream result;
    if (const StringPodValue* v = dynamic_cast<const StringPodValue*>(m_value))
    {
        result << v->value();
    }
    else if (const IntPodValue* v = dynamic_cast<const IntPodValue*>(m_value))
    {
        result << v->value();
    }
    else if (const FloatPodValue* v = dynamic_cast<const FloatPodValue*>(m_value))
    {
        result << v->value();
    }
    else if (const IdentifierPodValue* v = dynamic_cast<const IdentifierPodValue*>(m_value))
    {
        result << v->value();
    }
    else if (const EmbedPodValue* v = dynamic_cast<const EmbedPodValue*>(m_value))
    {
        result << v->value();
    }
    else if (const BlockPodValue* v = dynamic_cast<const BlockPodValue*>(m_value))
    {
        write(result);
    }
    else
    {
        throw ValueTypeError(__FUNCTION__, this);
    }
    return result.str();
}
Esempio n. 2
0
// *****************************************************************************
void PodNode::setEmbedScriptLanguage(const std::string& language)
{
    if (EmbedPodValue* v = dynamic_cast<EmbedPodValue*>(m_value))
    {
        v->setLanguage(language);
    }
    throw ValueTypeError(__FUNCTION__, this);
}
Esempio n. 3
0
// *****************************************************************************
const std::string& PodNode::embedScriptLanguage() const
{
    if (const EmbedPodValue* v = dynamic_cast<const EmbedPodValue*>(m_value))
    {
        return v->language();
    }
    throw ValueTypeError(__FUNCTION__, this);
}
Esempio n. 4
0
// *****************************************************************************
std::string PodNode::asEmbedScript() const
{
    if (const EmbedPodValue* v = dynamic_cast<const EmbedPodValue*>(m_value))
    {
        return v->value();
    }
    throw ValueTypeError(__FUNCTION__, this);
}
Esempio n. 5
0
// *****************************************************************************
std::string PodNode::asIdentifier() const
{
    if (const IdentifierPodValue* v = dynamic_cast<const IdentifierPodValue*>(m_value))
    {
        return v->value();
    }
    throw ValueTypeError(__FUNCTION__, this);
}
Esempio n. 6
0
// *****************************************************************************
void PodNode::setBlockScopeType(const std::string& blockScopeType)
{
    if (BlockPodValue* v = dynamic_cast<BlockPodValue*>(m_value))
    {
        v->setScopeType(blockScopeType);
    }
    throw ValueTypeError(__FUNCTION__, this);
}
Esempio n. 7
0
// *****************************************************************************
const std::string& PodNode::blockScopeType() const
{
    if (const BlockPodValue* v = dynamic_cast<const BlockPodValue*>(m_value))
    {
        return v->scopeType();
    }
    throw ValueTypeError(__FUNCTION__, this);
}
Esempio n. 8
0
// *****************************************************************************
const PodNodeDeque& PodNode::asBlock() const
{
    if (const BlockPodValue* v = dynamic_cast<const BlockPodValue*>(m_value))
    {
        return v->value();
    }
    throw ValueTypeError(__FUNCTION__, this);
}
Esempio n. 9
0
// *****************************************************************************
PodNodeDeque& PodNode::asBlock()
{
    if (BlockPodValue* v = dynamic_cast<BlockPodValue*>(m_value))
    {
        return v->value();
    }
    else if (!m_value)
    {
        // Special case: User asked for value as a block, but this node has no
        // current value, so set the value to be an empty block and return it.
        m_value = new BlockPodValue;
        return asBlock();
    }
    throw ValueTypeError(__FUNCTION__, this);
}
Esempio n. 10
0
// *****************************************************************************
bool PodNode::asBool() const
{
    if (const BoolPodValue* v = dynamic_cast<const BoolPodValue*>(m_value))
    {
        return v->value();
    }
    else if (const IntPodValue* v = dynamic_cast<const IntPodValue*>(m_value))
    {
        return static_cast<bool>(v->value());
    }
    else if (const FloatPodValue* v = dynamic_cast<const FloatPodValue*>(m_value))
    {
        return static_cast<bool>(v->value());
    }
    throw ValueTypeError(__FUNCTION__, this);
}
Esempio n. 11
0
// *****************************************************************************
float PodNode::asFloat() const
{
    if (const FloatPodValue* v = dynamic_cast<const FloatPodValue*>(m_value))
    {
        return v->value();
    }
    else if (const IntPodValue* v = dynamic_cast<const IntPodValue*>(m_value))
    {
        return static_cast<float>(v->value());
    }
    else if (const StringPodValue* v = dynamic_cast<const StringPodValue*>(m_value))
    {
        float result;
        if (stringToFloat(v->value(), result))
        {
            return result;
        }
    }
    throw ValueTypeError(__FUNCTION__, this);
}
Esempio n. 12
0
ValueArray::ValueArray(const Value& src)
{
	if(!UPP::IsNull(src)) {
		if(IsType<ValueMap>(src)) {
			ValueArray v = ValueMap(src);
			data = v.data;
			data->Retain();
			return;
		}
		else {
			if(src.GetType() != VALUEARRAY_V)
				throw ValueTypeError(String().Cat() << "Invalid value conversion: "
			                         << src.GetTypeName() << " -> ValueArray",
			                         src, VALUEARRAY_V);
			data = (ValueArray::Data *)src.GetVoidPtr();
		}
	}
	else
		data = &Single<NullData>();
	data->Retain();
}
Esempio n. 13
0
ValueMap::ValueMap(const Value& src)
{
	if(!IsNull(src)) {
		if(IsType<ValueArray>(src)) {
			ValueArray va = src;
			Init0();
			for(int i = 0; i < va.GetCount(); i++)
				Add(i, va[i]);
			return;
		}
		else {
			if(src.GetType() != VALUEMAP_V)
				throw ValueTypeError(String().Cat() << "Invalid value conversion: "
			                         << src.GetTypeName() << " -> ValueMap",
			                         src, VALUEMAP_V);
			data = (ValueMap::Data *)src.GetVoidPtr();
		}
	}
	else
		data = &Single<NullData>();
	data->Retain();
}