当前位置: 首页>>代码示例>>C++>>正文


C++ VValueBag类代码示例

本文整理汇总了C++中VValueBag的典型用法代码示例。如果您正苦于以下问题:C++ VValueBag类的具体用法?C++ VValueBag怎么用?C++ VValueBag使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


在下文中一共展示了VValueBag类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: father

bool VValueBag::ReplaceElementByPath( const VValueBag::StKeyPath& inPath, VValueBag *inBag)
{
	if (!testAssert( !inPath.empty()))
		return false;
	
	bool ok;
	if (inPath.size() > 1)
	{
		VValueBag::StKeyPath father( inPath);
		father.pop_back();
		if (inBag == NULL)
		{
			// removing
			VValueBag *fatherBag = GetUniqueElementByPath( father);
			if (fatherBag != NULL)
				fatherBag->RemoveElements( inPath.back());
			ok = true;
		}
		else
		{
			VValueBag *fatherBag = GetElementByPathAndCreateIfDontExists( father);
			if (fatherBag != NULL)
				ok = fatherBag->ReplaceElement( inPath.back(), inBag);
			else
				ok = false;
		}
	}
	else
	{
		ok = ReplaceElement( inPath.back(), inBag);
	}
	
	return ok;
}
开发者ID:StephaneH,项目名称:core-XToolbox,代码行数:34,代码来源:VValueBag.cpp

示例2: VValueBag

void VJSImage::_save(XBOX::VJSParms_callStaticFunction& ioParms, VJSPictureContainer* inPict)
{
	VPictureCodecFactoryRef fact;
	const VPictureCodec* encoder = nil;
	bool ok = false;

	VPicture* pic = inPict->GetPict();
	if (pic != nil)
	{
		VFile* file = ioParms.RetainFileParam(1);
		if (file != nil)
		{
			VString mimetype;
			ioParms.GetStringParam(2, mimetype);
			if (mimetype.IsEmpty())
			{
				VString extension;
				file->GetExtension(extension);
				if (extension.IsEmpty())
					extension = L"pic";
				encoder = fact->RetainEncoderForExtension(extension);
			}
			else
				encoder = fact->RetainEncoderByIdentifier(mimetype);

			if (encoder != nil)
			{
				VError err = VE_OK;
				if (file->Exists())
					err = file->Delete();
				if (err == VE_OK)
				{
					VValueBag *pictureSettings = nil;

					VValueBag *bagMetas = (VValueBag*)inPict->RetainMetaBag();
					if (bagMetas != nil)
					{
						pictureSettings = new VValueBag();
						ImageEncoding::stWriter settingsWriter(pictureSettings);
						VValueBag *bagRetained = settingsWriter.CreateOrRetainMetadatas( bagMetas);
						if (bagRetained) 
							bagRetained->Release(); 
					}
					err=encoder->Encode(*pic, pictureSettings, *file);

					QuickReleaseRefCountable(bagMetas);
					QuickReleaseRefCountable(pictureSettings);

					if (err == VE_OK)
						ok = true;
				}
				encoder->Release();
			}
			file->Release();
		}
		else
			vThrowError(VE_JVSC_WRONG_PARAMETER_TYPE_FILE, "1");
	}
	ioParms.ReturnBool(ok);
}
开发者ID:sanyaade-mobiledev,项目名称:core-XToolbox,代码行数:60,代码来源:VJSRuntime_Image.cpp

示例3: keyName

void VValueBag::_SortElements( const StBagElementsOrdering *inElementRule, const StBagElementsOrdering inRules[])
{
	VIndex count = fElements->GetCount();
	if (count > 1)
	{
		bool need_sort = false;
		VIndex currentPosition = 0;
		VectorOfPositions positions;
		for( VIndex i = 1 ; i <= count ; ++i)
		{
			VIndex position = fElements->GetNthKeyPosition( i, inElementRule->fChildren, MAX_BAG_ELEMENTS_ORDERING);
			positions.push_back( VectorOfPositions::value_type( i, position));

			if ( (position != 0) && (position < currentPosition) )
			{
				need_sort = true;
			}
			currentPosition = position;
		}
		
		if (need_sort)
		{
			std::sort( positions.begin(), positions.end(), PositionComparatorStrict);
			VPackedVBagArrayDictionary *newElements = new VPackedVBagArrayDictionary;
			for( VectorOfPositions::const_iterator i = positions.begin() ; i != positions.end() ; ++i)
			{
				VBagArray *elements;
				VIndex position = i->second;
				if (position > 0)
				{
					elements = fElements->GetNthValue( i->first, NULL);
					newElements->Append( *inElementRule->fChildren[position-1], elements);
				}
				else
				{
					VString name;
					elements = fElements->GetNthValue( i->first, &name);
					newElements->Append( name, elements);
				}
			}
			delete fElements;
			fElements = newElements;
		}
	}
	
	// sort children
	for( VIndex i = 1 ; i <= count ; ++i)
	{
		VString name;
		VBagArray *elements = fElements->GetNthValue( i, &name);
		StKey keyName( name);
		VIndex bagArrayCount = elements->GetCount();
		for( VIndex j = 1 ; j <= bagArrayCount ; ++j)
		{
			VValueBag *elem = elements->GetNth( j);
			elem->SortElements( keyName, inRules);
		}
	}
}
开发者ID:StephaneH,项目名称:core-XToolbox,代码行数:59,代码来源:VValueBag.cpp

示例4:

VValueBag *VValueBag::GetUniqueElementByPath( const StKeyPath& inPath)
{
	VValueBag *bag = this;
	for( StKeyPath::const_iterator i = inPath.begin() ; (i != inPath.end()) && (bag != NULL) ; ++i)
	{
		VBagArray* array = bag->GetElements( *i);
		bag = (array != NULL && !array->IsEmpty()) ? array->GetNth(1) : NULL;
	}
	return bag;
}
开发者ID:StephaneH,项目名称:core-XToolbox,代码行数:10,代码来源:VValueBag.cpp

示例5: SaveToBag

VError VRect::SaveToBag(VValueBag& ioBag, VString& outKind) const
{
	ioBag.SetReal(L"left", fX);
	ioBag.SetReal(L"top", fY);
	ioBag.SetReal(L"width", fWidth);
	ioBag.SetReal(L"height", fHeight);
	
	outKind = L"rect";
	return VE_OK;
}
开发者ID:sanyaade-webdev,项目名称:core-XToolbox,代码行数:10,代码来源:VRect.cpp

示例6: UpdateValue

void VCommand::UpdateValue(const VValueSingle& inValue, const ICommandListener* inExcept)
{
	VValueBag* bag = new VValueBag;
	if (bag != NULL)
	{
		bag->SetAttribute(CVSTR("__command_value__"), dynamic_cast<VValueSingle*>(inValue.Clone()));
		
		UpdateValue(bag, inExcept);

		bag->Release();
	}
}
开发者ID:StephaneH,项目名称:core-XToolbox,代码行数:12,代码来源:VCommand.cpp

示例7: Trigger

bool VCommand::Trigger(const VValueSingle& inValue, const ICommandListener* inExcept)
{
	bool called = false;
	VValueBag* bag = new VValueBag;
	if (bag != NULL)
	{
		bag->SetAttribute(CVSTR("__command_value__"), dynamic_cast<VValueSingle*>(inValue.Clone()));
		
		called = Trigger(bag, inExcept);
		
		bag->Release();
	}
	return called;
}
开发者ID:StephaneH,项目名称:core-XToolbox,代码行数:14,代码来源:VCommand.cpp

示例8: RetainNth

VValueBag* VBagArray::RetainNth( VIndex inIndex)
{
	VValueBag* bag = NULL;
	
	if (testAssert(inIndex >= 1 && inIndex <= GetCount()))
		bag = fArray[inIndex-1];
	
	if (bag == NULL)
		bag = new VValueBag;
	else	
		bag->Retain();

	return bag;
}
开发者ID:StephaneH,项目名称:core-XToolbox,代码行数:14,代码来源:VValueBag.cpp

示例9: SaveToBag

VError VCommand::SaveToBag(VValueBag& ioBag, VString& outKind) const
{
	ioBag.SetString(L"id", fID);
	ioBag.SetString(L"name", fName);
	
	if (fTriggerSignal.IsAllwaysAsynchronous())
		ioBag.SetBoolean(L"asynchronous", true);
	else if (fTriggerSignal.IsAllwaysSynchronous())
		ioBag.SetBoolean(L"synchronous", true);
	
	ioBag.SetBoolean(L"enabled", IsEnabled());
	
	outKind = "command";
	return vGetLastError();
}
开发者ID:StephaneH,项目名称:core-XToolbox,代码行数:15,代码来源:VCommand.cpp

示例10: iterator

VError VCommandList::SaveToBag(VValueBag& ioBag, VString& outKind) const
{
	VStr31	kind;
	VCommand*	command;
	VArrayIteratorOf<VCommand*>	iterator(fCmdArray);
	while ((command = iterator.Next()) != NULL)
	{
		VValueBag*	bagCommand = new VValueBag;
		command->SaveToBag(*bagCommand, kind);
		ioBag.AddElement(kind, bagCommand);
		bagCommand->Release();
	}
	
	outKind = "command";
	return vGetLastError();
}
开发者ID:StephaneH,项目名称:core-XToolbox,代码行数:16,代码来源:VCommand.cpp

示例11: GetUUID

bool VBagLoader::GetUUID( const VValueBag& inBag, VUUID& outUUID)
{
	bool ok;
	if (fRegenerateUUIDs)
	{
		VUUID bag_uuid;
		ok = inBag.GetVUUID( BagLoaderKeys::uuid, bag_uuid);
		if (ok && !bag_uuid.IsNull())
		{
			try
			{
				MapVUUID::const_iterator i = fUUIDs.find( bag_uuid);
				if (i != fUUIDs.end())
				{
					outUUID = i->second;
				}
				else
				{
					outUUID.Regenerate();
					fUUIDs[bag_uuid] = outUUID;
				}
			}
			catch(...)
			{
				ok = false;
			}
		}
		else
		{
			outUUID.Regenerate();
		}
	}
	else
	{
		ok = inBag.GetVUUID( BagLoaderKeys::uuid, outUUID);
		if (!ok)
		{
			outUUID.Regenerate();
		}
	}
	
	return ok;
}
开发者ID:StephaneH,项目名称:core-XToolbox,代码行数:43,代码来源:VValueBag.cpp

示例12: LoadFromBag

VError VCommandList::LoadFromBag(const VValueBag& inBag)
{
	const VBagArray*	bagCommands = inBag.RetainElements(L"command");
	if (bagCommands != NULL)
	{
		LoadCommands(*bagCommands);
		bagCommands->Release();
	}
	
	return vGetLastError();
}
开发者ID:StephaneH,项目名称:core-XToolbox,代码行数:11,代码来源:VCommand.cpp

示例13: ThrowError

VError ThrowError( VError inError, const VString *inParam, ...)
{
	VErrorBase *errBase = new VErrorBase( inError, 0);
	if (errBase != NULL)
	{
		VValueBag *bag = errBase->GetBag();
		if (bag != NULL)
		{
			VIndex paramNum = 1;
			
			va_list argList;
			va_start( argList, inParam);
			
			for (const VString *param = inParam ; param != NULL ; param = va_arg( argList, const VString*), ++paramNum)
			{
				VString attName( "param");
				attName.AppendLong( paramNum);
				bag->SetString( attName, *param);
			}
			
			va_end( argList);
		}
开发者ID:sanyaade-teachings,项目名称:core-Wakanda,代码行数:22,代码来源:VRIAServerTools.cpp

示例14: ReadFromStreamMinimal

VError VBagArray::ReadFromStreamMinimal( VStream* inStream)
{
	VError err = inStream->GetLastError();
	if (err == VE_OK)
	{
		try
		{
			VIndex max_bag = inStream->GetLong();
			fArray.reserve( max_bag);
			for( VIndex i = 1 ; (i <= max_bag) && (err == VE_OK) ; i++)
			{
				VValueBag* bag = new VValueBag;
				if (bag != NULL)
				{
					err = bag->ReadFromStreamMinimal( inStream);
					if (err == VE_OK)
					{
						fArray.push_back( bag);
					}
					else
					{
						bag->Release();
					}
				}
				else
				{
					err = VE_MEMORY_FULL;
				}
			}
		}
		catch(...)
		{
			err = VE_MEMORY_FULL;
		}
	}
	
	return err;
}
开发者ID:StephaneH,项目名称:core-XToolbox,代码行数:38,代码来源:VValueBag.cpp

示例15: AddElement

VError VValueBag::AddElement(const IBaggable* inObject)
{
	VError err = VE_OK;

	if (inObject != NULL)
	{
		VValueBag* bag = new VValueBag;
		if (bag != NULL)
		{
			VStr31 kind;
			err = inObject->SaveToBag(*bag, kind);
			if (err == VE_OK)
				AddElement(kind, bag);
			bag->Release();
		}
		else
		{
			err = vThrowError(VE_MEMORY_FULL);
		}
	}

	return err;
}
开发者ID:StephaneH,项目名称:core-XToolbox,代码行数:23,代码来源:VValueBag.cpp


注:本文中的VValueBag类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。