void STObject::set (const SOTemplate& type)
{
    mData.clear ();
    mType = &type;

    BOOST_FOREACH (const SOElement * elem, type.peek ())
    {
        if (elem->flags != SOE_REQUIRED)
            giveObject (makeNonPresentObject (elem->e_field));
        else
            giveObject (makeDefaultObject (elem->e_field));
    }
}
Ejemplo n.º 2
0
void STObject::set (const SOTemplate& type)
{
    mData.clear ();
    mType = &type;

    for (SOTemplate::value_type const& elem : type.peek ())
    {
        if (elem->flags != SOE_REQUIRED)
            giveObject (makeNonPresentObject (elem->e_field));
        else
            giveObject (makeDefaultObject (elem->e_field));
    }
}
Ejemplo n.º 3
0
void STObject::set(const std::vector<SOElement::ref>& type)
{
	mData.clear();
	mType.clear();

	BOOST_FOREACH(SOElement::ref elem, type)
	{
		mType.push_back(elem);
		if (elem->flags != SOE_REQUIRED)
			giveObject(makeNonPresentObject(elem->e_field));
		else
			giveObject(makeDefaultObject(elem->e_field));
	}
SerializedType* STObject::getPField (SField::ref field, bool createOkay)
{
    int index = getFieldIndex (field);

    if (index == -1)
    {
        if (createOkay && isFree ())
            return getPIndex (giveObject (makeDefaultObject (field)));

        return NULL;
    }

    return getPIndex (index);
}
Ejemplo n.º 5
0
// return true = terminated with end-of-object
bool STObject::set (SerializerIterator& sit, int depth)
{
    bool reachedEndOfObject = false;

    // Empty the destination buffer
    //
    mData.clear ();

    // Consume data in the pipe until we run out or reach the end
    //
    while (!reachedEndOfObject && !sit.empty ())
    {
        int type;
        int field;

        // Get the metadata for the next field
        //
        sit.getFieldID (type, field);

        reachedEndOfObject = (type == STI_OBJECT) && (field == 1);

        if ((type == STI_ARRAY) && (field == 1))
        {
            WriteLog (lsWARNING, STObject) << "Encountered object with end of array marker";
            throw std::runtime_error ("Illegal terminator in object");
        }

        if (!reachedEndOfObject)
        {
            // Figure out the field
            //
            SField::ref fn = SField::getField (type, field);

            if (fn.isInvalid ())
            {
                WriteLog (lsWARNING, STObject) << "Unknown field: field_type=" << type << ", field_name=" << field;
                throw std::runtime_error ("Unknown field");
            }

            // Unflatten the field
            //
            giveObject (makeDeserializedObject (fn.fieldType, fn, sit, depth + 1));
        }
    }

    return reachedEndOfObject;
}
SerializedType* STObject::makeFieldPresent (SField::ref field)
{
    int index = getFieldIndex (field);

    if (index == -1)
    {
        if (!isFree ())
            throw std::runtime_error ("Field not found");

        return getPIndex (giveObject (makeNonPresentObject (field)));
    }

    SerializedType* f = getPIndex (index);

    if (f->getSType () != STI_NOTPRESENT)
        return f;

    mData.replace (index, makeDefaultObject (f->getFName ()).release ());
    return getPIndex (index);
}