Esempio n. 1
0
VError VJSONObject::CloneProperties( VJSONCloner& inCloner, VJSONObject *inDestination) const
{
	VError err = VE_OK;
	if (inDestination != NULL)
	{
		MapType clonedMap( fMap);

		for( MapType::iterator i = clonedMap.begin() ; (i != clonedMap.end()) && (err == VE_OK) ; ++i)
		{
			if (i->second.first.IsObject())
			{
				VJSONObject *theOriginalObject = RetainRefCountable( i->second.first.GetObject());
				err = inCloner.CloneObject( theOriginalObject, i->second.first);
				VJSONGraph::Connect( &inDestination->fGraph, i->second.first);
				ReleaseRefCountable( &theOriginalObject);
			}
			else if (i->second.first.IsArray())
			{
				VJSONArray *theOriginalArray = RetainRefCountable( i->second.first.GetArray());
				err = theOriginalArray->Clone( i->second.first, inCloner);
				VJSONGraph::Connect( &inDestination->fGraph, i->second.first);
				ReleaseRefCountable( &theOriginalArray);
			}
		}
		
		if (err == VE_OK)
			inDestination->fMap.swap( clonedMap);
	}
	return err;
}
Esempio n. 2
0
VError VJSONArray::Clone( VJSONValue& outValue, VJSONCloner& inCloner) const
{
    VError err = VE_OK;

    VJSONArray *clone = new VJSONArray;
    if (clone != NULL)
    {
        VectorType clonedVector = fVector;

        for( VectorType::iterator i = clonedVector.begin() ; (i != clonedVector.end()) && (err == VE_OK) ; ++i)
        {
            if (i->IsObject())
            {
                VJSONObject *theOriginalObject = RetainRefCountable( i->GetObject());
                err = inCloner.CloneObject( theOriginalObject, *i);
                VJSONGraph::Connect( &clone->fGraph, *i);
                ReleaseRefCountable( &theOriginalObject);
            }
            else if (i->IsArray())
            {
                VJSONArray *theOriginalArray = RetainRefCountable( i->GetArray());
                err = theOriginalArray->Clone( *i, inCloner);
                VJSONGraph::Connect( &clone->fGraph, *i);
                ReleaseRefCountable( &theOriginalArray);
            }
        }

        if (err == VE_OK)
            clone->fVector.swap( clonedVector);
    }
    else
    {
        err = VE_MEMORY_FULL;
    }
    outValue.SetArray( clone);
    ReleaseRefCountable( &clone);

    return err;
}
Esempio n. 3
0
VError VJSONObject::Clone( VJSONValue& outValue, VJSONCloner& inCloner) const
{
    VError err = VE_OK;

    VJSONObject *clone = new VJSONObject;
    if (clone != NULL)
    {
        MapType clonedMap = fMap;

        for( MapType::iterator i = clonedMap.begin() ; (i != clonedMap.end()) && (err == VE_OK) ; ++i)
        {
            if (i->second.IsObject())
            {
                VJSONObject *theOriginalObject = RetainRefCountable( i->second.GetObject());
                err = inCloner.CloneObject( theOriginalObject, i->second);
                VJSONGraph::Connect( &clone->fGraph, i->second);
                ReleaseRefCountable( &theOriginalObject);
            }
            else if (i->second.IsArray())
            {
                VJSONArray *theOriginalArray = RetainRefCountable( i->second.GetArray());
                err = theOriginalArray->Clone( i->second, inCloner);
                VJSONGraph::Connect( &clone->fGraph, i->second);
                ReleaseRefCountable( &theOriginalArray);
            }
        }

        if (err == VE_OK)
            clone->fMap.swap( clonedMap);
    }
    else
    {
        err = VE_MEMORY_FULL;
    }
    outValue.SetObject( clone);
    ReleaseRefCountable( &clone);

    return err;
}