Beispiel #1
0
void STObject::add (Serializer& s, bool withSigningFields) const
{
    std::map<int, STBase const*> fields;
    for (auto const& e : v_)
    {
        // pick out the fields and sort them
        if ((e->getSType() != STI_NOTPRESENT) &&
            e->getFName().shouldInclude (withSigningFields))
        {
            fields.insert (std::make_pair (
                e->getFName().fieldCode, &e.get()));
        }
    }

    // insert sorted
    for (auto const& e : fields)
    {
        auto const field = e.second;

        // When we serialize an object inside another object,
        // the type associated by rule with this field name
        // must be OBJECT, or the object cannot be deserialized
        assert ((field->getSType() != STI_OBJECT) ||
            (field->getFName().fieldType == STI_OBJECT));
        field->addFieldID (s);
        field->add (s);
        if (dynamic_cast<const STArray*> (field) != nullptr)
            s.addFieldID (STI_ARRAY, 1);
        else if (dynamic_cast<const STObject*> (field) != nullptr)
            s.addFieldID (STI_OBJECT, 1);
    }
}
bool SerializedType::isEquivalent (const SerializedType& t) const
{
    assert (getSType () == STI_NOTPRESENT);
    if (t.getSType () == STI_NOTPRESENT)
        return true;
    WriteLog (lsDEBUG, SerializedType) << "notEquiv " << getFullText() << " not STI_NOTPRESENT";
    return false;
}
std::string SerializedType::getFullText() const
{
	std::string ret;
	if (getSType() != STI_NOTPRESENT)
	{
		if(fName->hasName())
		{
			ret = fName->fieldName;
			ret += " = ";
		}
		ret += getText();
	}
	return ret;
}
Beispiel #4
0
AccountID STObject::getAccountID (SField const& field) const
{
    auto rf = peekAtPField (field);
    if (!rf)
        throw std::runtime_error ("Field not found");

    AccountID account;
    if (rf->getSType () != STI_NOTPRESENT)
    {
        const STAccount* cf = dynamic_cast<const STAccount*> (rf);

        if (!cf)
            throw std::runtime_error ("Wrong field type");

        cf->getValueH160 (account);
    }

    return account;
}