Example #1
0
EntryValue ArrayEntryType::internalizeValue(std::string& key, ComplexData& externalRepresentation, EntryValue currentInteralValue) {
    // TODO: Argument 'key' appears unused.
    ArrayData& externalArrayData = (ArrayData&)externalRepresentation;

    EntryValue eValue = currentInteralValue;
    ArrayEntryData* internalArray = (ArrayEntryData*) currentInteralValue.ptr;
    if(internalArray == NULL) {
        internalArray = (ArrayEntryData*)malloc(sizeof(ArrayEntryData));
        internalArray->length = 0;
        internalArray->array = NULL;
        eValue.ptr = internalArray;
    }

    if(internalArray->length==externalArrayData.size()) {
        for(int i = 0; i<internalArray->length; ++i) {
            deleteElement(internalArray->array[i]);
            internalArray->array[i] = copyElement(externalArrayData._get(i));
        }
    }
    else {
        if(internalArray->array != NULL)
            free(internalArray->array);
        internalArray->length = externalArrayData.size();
        if(internalArray->length == 0)
            internalArray->array = NULL;
        else
            internalArray->array = (EntryValue*)malloc(externalArrayData.size()*sizeof(EntryValue));
        for (int i = 0; i < internalArray->length; ++i) {
            internalArray->array[i] = copyElement(externalArrayData._get(i));
        }
    }
    return eValue;
}
void DataLibrary::appendXmlDate( rapidxml::xml_document<>* currentDoc,std::string fileName, std::string resGroup )
{
	try
	{
		rapidxml::xml_document<> doc;
		Ogre::DataStreamPtr stream = Ogre::ResourceGroupManager::getSingleton().openResource(fileName, resGroup.c_str(), true);
		std::string ss=stream->getAsString();
		int i=ss.size();
		char* s=new char[i+1];
		ss.copy(s,i);
		s[i]='\0';
		doc.parse<0>(s);

		rapidxml::xml_node<>* srcElement=doc.first_node();
		rapidxml::xml_node<>* destElement=currentDoc->last_node();

		copyElement(srcElement,destElement);

		delete []s;
	}
	catch (rapidxml::parse_error& e)
	{
		Ogre::LogManager::getSingletonPtr()->logMessage(e.what(),Ogre::LML_CRITICAL);
	}
}
Example #3
0
void ArrayEntryType::exportValue(std::string& key, EntryValue internalData, ComplexData& externalRepresentation) {
    ArrayEntryData* internalArray = (ArrayEntryData*) internalData.ptr;
    ArrayData& externalArrayData = (ArrayData&)externalRepresentation;
    externalArrayData.setSize(internalArray->length);
    for(int i = 0; i<internalArray->length; ++i) {
        externalArrayData._set(i, copyElement(internalArray->array[i]));
    }
}
Example #4
0
std::vector<MeshLib::Element*> copyElementVector(const std::vector<MeshLib::Element*> &elements, const std::vector<MeshLib::Node*> &nodes)
{
	const std::size_t nElements(elements.size());
	std::vector<MeshLib::Element*> new_elements;
	new_elements.reserve(nElements);
	for (std::size_t k = 0; k < nElements; ++k)
		new_elements.push_back(copyElement(elements[k], nodes));
	return new_elements;
}
void DataLibrary::copyElement(rapidxml::xml_node<>* srcElement,rapidxml::xml_node<>* destElement )
{
	for (rapidxml::xml_attribute<> *attr = srcElement->first_attribute();
		attr; attr = attr->next_attribute())
	{
		rapidxml::xml_attribute<> *oldAttr=destElement->first_attribute(attr->name());
		if(oldAttr!=0)
		{
			char* value=destElement->document()->allocate_string(attr->value());
			oldAttr->value(value);
		}
		else
		{
			char* name=destElement->document()->allocate_string(attr->name());
			char* value=destElement->document()->allocate_string(attr->value());
			rapidxml::xml_attribute<> *newAttr=destElement->document()->allocate_attribute(name,value);
			destElement->append_attribute(newAttr);
		}
	}

	for (rapidxml::xml_node<> *child = srcElement->first_node();
		child; child = child->next_sibling())
	{
		rapidxml::xml_node<> * findElement=destElement->first_node(child->name());
		if(findElement!=NULL)//如果有,就继续递归
		{
			copyElement(&(*child),findElement);
		}
		else//如果没找到,说明目标节点下面没有该源节点
		{
			char* name=destElement->document()->allocate_string(child->name());
			rapidxml::xml_node<> *newNode=destElement->document()->allocate_node(rapidxml::node_element,name);
			destElement->append_node(newNode);

			copyElement(&(*child),newNode);
		}
	}

	
}
Example #6
0
EntryValue ArrayEntryType::copyValue(EntryValue value) {
    ArrayEntryData* otherDataArray = (ArrayEntryData*) value.ptr;

    EntryValue* array = (EntryValue*)malloc(otherDataArray->length*sizeof(EntryValue));
    for (int i = 0; i < otherDataArray->length; ++i) {
        array[i] = copyElement(otherDataArray->array[i]);
    }

    ArrayEntryData* dataArray = (ArrayEntryData*)malloc(sizeof(ArrayEntryData));
    dataArray->length = otherDataArray->length;
    dataArray->array = array;

    EntryValue eValue;
    eValue.ptr = dataArray;
    return eValue;
}
Example #7
0
std::string 
XmlUniformiser::stripped()
{
  while ( isValidIndex() )
  {
    skipSpaces();
    if ( startsWith( "<?" ) )
      skipProcessed();
    else if ( startsWith( "<!--" ) )
      skipComment();
    else if ( startsWith( "<" ) )
      copyElement();
    else
      copyElementContent();
  }
  return m_stripped;
}
bool DataLibrary::copyNode(std::string srcpath, std::string distpath, bool createpath)
{
	rapidxml::xml_node<>* srcnode=getNode(srcpath,false);
	if(!srcnode)
	{
		return false;
	}

	rapidxml::xml_node<>* distnode=getNode(distpath,createpath);
	if(!distnode)
	{
		return false;
	}

	copyElement(srcnode,distnode );

	return true;
}
Example #9
0
 static void copyElementType2(DcmItem& dataset,
                              const DcmTagKey &key,
                              DcmDirectoryRecord& record)
 {
   copyElement(dataset, key, record, OFFalse /*optional*/, OFTrue /*copyEmpty*/);
 }