Пример #1
0
   PrimitiveValue ^ DataObjectToPrimitiveValue (DataObject theDO)
     {
	  CLIPSType theType = theDO.GetCLIPSType();
	  List<PrimitiveValue ^> ^ theList;
	  CLIPS::MultifieldValue *theMultifieldValue;
	  std::vector<Value *> *theMultifield;
	  Value *theValue;
	  PrimitiveValue ^ rv = nullptr;

     switch (theType)
	    {
		 case STRING_TYPE:
		 case SYMBOL_TYPE:
		 case INSTANCE_NAME_TYPE:
		 case INTEGER_TYPE:
		 case FLOAT_TYPE:
		 case FACT_ADDRESS_TYPE:
		 case INSTANCE_ADDRESS_TYPE:
		 case VOID_TYPE:
		   rv = SingleFieldToPrimitiveValue(theType,theDO.GetCLIPSValue());
		   break;

		 case MULTIFIELD_TYPE:
		   theList = gcnew List<PrimitiveValue ^>;
		   theMultifieldValue = (CLIPS::MultifieldValue *) theDO.GetCLIPSValue();
		   theMultifield = theMultifieldValue->GetMultifieldValue();	
		   for (std::vector<Value *>::size_type i = 0; i != theMultifield->size(); i++) 
           {
            theValue = theMultifield->at(i);
            theList->Add(SingleFieldToPrimitiveValue(theValue->GetCLIPSType(),theValue));
           }
		   rv = gcnew MultifieldValue(theList);
         break;
	    }

	  return rv;
	 }