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


C++ TiXmlPrinter::Size方法代码示例

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


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

示例1: OnEditCopy

void CUIDesignerView::OnEditCopy()
{
	ASSERT(m_cfUI != NULL);

	TiXmlDocument xmlDoc;
	TiXmlDeclaration Declaration("1.0","utf-8","yes");
	xmlDoc.InsertEndChild(Declaration);
	TiXmlElement* pCopyElm = new TiXmlElement("UICopy");
	CopyUI(pCopyElm);
	xmlDoc.InsertEndChild(*pCopyElm);
	TiXmlPrinter printer;
	xmlDoc.Accept(&printer);
	delete pCopyElm;
	CSharedFile file(GMEM_MOVEABLE, printer.Size() + 1);
	file.Write(printer.CStr(), printer.Size());
	file.Write("\0", 1);
	COleDataSource* pDataSource = NULL;
	TRY
	{
		pDataSource = new COleDataSource;
		pDataSource->CacheGlobalData(m_cfUI, file.Detach());
		pDataSource->SetClipboard();
	}
	CATCH_ALL(e)
	{
		delete pDataSource;
		THROW_LAST();
	}
	END_CATCH_ALL
}
开发者ID:pyq881120,项目名称:urltraveler,代码行数:30,代码来源:UIDesignerView.cpp

示例2: SaveFile

bool CXBMCTinyXML::SaveFile(const std::string& filename) const
{
  XFILE::CFile file;
  if (file.OpenForWrite(filename, true))
  {
    TiXmlPrinter printer;
    Accept(&printer);
    return file.Write(printer.CStr(), printer.Size()) == static_cast<ssize_t>(printer.Size());
  }
  return false;
}
开发者ID:0xheart0,项目名称:xbmc,代码行数:11,代码来源:XBMCTinyXML.cpp

示例3: CombineMasterSlaveXmlParam

HRESULT CombineMasterSlaveXmlParam(
    const char* szXmlParamMaster,
    const char* szXmlParamSlave,
    char* szXmlParamAll,
    DWORD32& dwLen
)
{
    TiXmlElement* pMasterRootElement = NULL;
    TiXmlDocument cXmlDocMaster;
    if ( szXmlParamMaster && cXmlDocMaster.Parse(szXmlParamMaster) )
    {
        pMasterRootElement = cXmlDocMaster.RootElement();
    }

    TiXmlElement* pSlaveRootElement = NULL;
    TiXmlDocument cXmlDocSlave;
    if ( szXmlParamSlave && cXmlDocSlave.Parse(szXmlParamSlave) )
    {
        pSlaveRootElement = cXmlDocSlave.RootElement();
    }

    if ( NULL == pMasterRootElement || NULL == pSlaveRootElement )
    {
        dwLen = 0;
        return E_FAIL;
    }
    else
    {
        // 将主CPU参数内的所有Section结点插入到从CPU参数内的HvParam结点下。
        TiXmlElement* pMasterHvParamElement = NULL;
        TiXmlElement* pSlaveHvParamElement = NULL;
        pMasterHvParamElement = pMasterRootElement->FirstChildElement("HvParam");
        pSlaveHvParamElement = pSlaveRootElement->FirstChildElement("HvParam");
        if ( pMasterHvParamElement && pSlaveHvParamElement)
        {
            TiXmlElement* pMasterSectionElement = NULL;
            pMasterSectionElement = pMasterHvParamElement->FirstChildElement();
            while (pMasterSectionElement)
            {
                pSlaveHvParamElement->LinkEndChild(pMasterSectionElement->Clone());
                pMasterSectionElement = pMasterSectionElement->NextSiblingElement();
            }
        }

        TiXmlPrinter cTxPr;
        cXmlDocSlave.Accept(&cTxPr);
        DWORD32 dwXmlLen = (DWORD32)cTxPr.Size();
        if ( dwLen > dwXmlLen )
        {
            dwLen = dwXmlLen;
            memcpy(szXmlParamAll, cTxPr.CStr(), dwXmlLen);
            return S_OK;
        }
        else
        {
            dwLen = 0;
            return E_FAIL;
        }
    }
}
开发者ID:fangbaolei,项目名称:EC700IR,代码行数:60,代码来源:HvParamIO.cpp

示例4: getText

size_t XMLSource::getText(const char*& outputBuffer) {
	TiXmlPrinter printer;
	printer.SetStreamPrinting();
	xassert(doc, "No document to save.");
	doc->Accept(&printer);
	outputBuffer = printer.CStr();
	return printer.Size();
}
开发者ID:Dustpup,项目名称:aurora-game-engine,代码行数:8,代码来源:xml_source.cpp

示例5: SaveDocument

bool TinyXML::SaveDocument(const wxString& filename, TiXmlDocument* doc)
{
    if (!doc)
        return false;

    TiXmlPrinter printer;
    printer.SetIndent("\t");
    doc->Accept(&printer);

    return Manager::Get()->GetFileManager()->SaveUTF8(filename, printer.CStr(), printer.Size());
}
开发者ID:stahta01,项目名称:codeblocks_https_metadata,代码行数:11,代码来源:tinywxuni.cpp

示例6: getAsRawData

//--------------------------------------------------------------------------------------------------
/// 
//--------------------------------------------------------------------------------------------------
void XmlDocumentImpl::getAsRawData(cvf::UByteArray* buffer) const
{
	TiXmlPrinter printer;

	// Use tab as indent marker
	printer.SetIndent( "\t" );

	// Link document to printer
	Accept(&printer);

    buffer->assign((cvf::ubyte*)printer.CStr(), (size_t)printer.Size());
}
开发者ID:CeetronAS,项目名称:CustomVisualizationCore,代码行数:15,代码来源:cvfXml.cpp

示例7: SaveFile

bool CXBMCTinyXML::SaveFile(const CStdString &filename) const
{
  XFILE::CFile file;
  if (file.OpenForWrite(filename, true))
  {
    TiXmlPrinter printer;
    Accept(&printer);
    file.Write(printer.CStr(), printer.Size());
    return true;
  }
  return false;
}
开发者ID:snikhil0,项目名称:xbmc,代码行数:12,代码来源:XBMCTinyXML.cpp

示例8: TiXmlSaveDocument

bool MainFrame::TiXmlSaveDocument(const wxString& filename, TiXmlDocument* doc)
{
  if (!doc)
    return false;

  TiXmlPrinter printer;
  printer.SetIndent("\t");
  doc->Accept(&printer);

  wxTempFile file(filename);
  if(file.IsOpened())
    if(file.Write(printer.CStr(), printer.Size()) && file.Commit())
      return true;

  return false;
}// TiXmlSaveDocument
开发者ID:469306621,项目名称:Languages,代码行数:16,代码来源:mainframe.cpp

示例9: saveAOD

// QC:?
void ScriptableObject::saveAOD(VFS::File* file)
{
	TiXmlDocument* doc = new TiXmlDocument();
	TiXmlElement* xml = aod()->Clone()->ToElement();

	cleanPtrInAOD(xml);
	doc->LinkEndChild(xml);

	TiXmlPrinter printer;
	printer.SetStreamPrinting();
	doc->Accept(&printer);

	file->truncate();
	file->write((char*)printer.CStr(), printer.Size());

	delete doc;
}
开发者ID:Dustpup,项目名称:aurora-game-engine,代码行数:18,代码来源:scriptable_object.cpp

示例10: SaveDocument

bool TinyXML::SaveDocument(const wxString& filename, TiXmlDocument* doc)
{
    if (!doc)
        return false;

    TiXmlPrinter printer;
    printer.SetIndent("\t");
    doc->Accept(&printer);

    return Manager::Get()->GetFileManager()->Save(filename, printer.CStr(), printer.Size());

//    wxTempFile file(filename);
//    if(file.IsOpened())
//        if(file.Write(Printer.CStr(), Printer.Size()) && file.Commit())
//            return true;
//    return false;
}
开发者ID:469306621,项目名称:Languages,代码行数:17,代码来源:tinywxuni.cpp

示例11: ProcessFile

void ProcessFile(const char* fileName)
{
    TiXmlDocument doc;
    doc.LoadFile(fileName);
    if (doc.Error())
    {
        printf("Error in file %s: %s\n", fileName, doc.ErrorDesc());
        return;
    }
    TiXmlPrinter printer;
    printer.SetStreamPrinting();
    doc.Accept(&printer);

    FILE *f = fopen(fileName, "wb");
    if (!f)
        return;

    fwrite(printer.CStr(), printer.Size(), 1, f);
    fclose(f);
}
开发者ID:Distrotech,项目名称:codeblocks,代码行数:20,代码来源:scrooge.cpp

示例12: GetXMLStream

/**************************************************************************
* name       : GetXMLStream
* description: 获取xml流
* input      : NA
* output     : nXMLStreamLength
* return     : const char* xml流
* remark     : NA
**************************************************************************/
const char*  CXml::GetXMLStream(unsigned int &uiXMLStreamLength)
{
	TiXmlPrinter xmlPrinter;
	xmlPrinter.SetStreamPrinting();		

	if (NULL == m_pXMlDoc)
	{
		SAFE_NEW(m_pXMlDoc, TiXmlDocument);//lint !e774
	}

	CHECK_POINTER(m_pXMlDoc, NULL);//lint !e774
	if (!m_pXMlDoc->Accept(&xmlPrinter))
	{
		return NULL;
	}

    uiXMLStreamLength = xmlPrinter.Size();

	m_strStream = xmlPrinter.CStr();
    return m_strStream.c_str();
}
开发者ID:eSDK,项目名称:esdk_elte,代码行数:29,代码来源:eLTE_Xml.cpp

示例13: BuildPlateString

HRESULT CHVC::BuildPlateString(
    char* pszPlateString,
    int* piPlateStringSize,
    CARLEFT_INFO_STRUCT *pCarLeftInfo
)
{
    if (pCarLeftInfo == NULL || pszPlateString == NULL || piPlateStringSize == NULL) return E_INVALIDARG;

    if (!m_pXmlDoc)	//如果文档为空则创建新文档
    {
        m_pXmlDoc = new TiXmlDocument;
        TiXmlDeclaration* pDecl = new TiXmlDeclaration("1.0", "GB2312", "yes");
        TiXmlElement* pRoot = new TiXmlElement("HvcResultDoc");

        if ( !m_pXmlDoc || !pDecl || !pRoot )
        {
            SAFE_DELETE(m_pXmlDoc);
            SAFE_DELETE(pDecl);
            SAFE_DELETE(pRoot);
            return E_OUTOFMEMORY;
        }

        m_pXmlDoc->LinkEndChild(pDecl);
        m_pXmlDoc->LinkEndChild(pRoot);
    }

    //取得ResultSet段
    TiXmlElement* pResultSet = m_pXmlDoc->RootElement()->FirstChildElement("ResultSet");
    if (!pResultSet)
    {
        pResultSet = new TiXmlElement("ResultSet");
        if ( !pResultSet ) return E_OUTOFMEMORY;
        m_pXmlDoc->RootElement()->LinkEndChild(pResultSet);
    }

    //注意:一定要删除已经存在的节
    TiXmlNode* pResultOld = pResultSet->FirstChild("Result");
    if ( pResultOld )
    {
        pResultSet->RemoveChild(pResultOld);
    }

    //写入Result
    TiXmlElement* pResult = new TiXmlElement("Result");
    if (pResult)
    {
        pResultSet->LinkEndChild(pResult);

        //车牌
        char szConf[32] = {0};
        char szPlateName[32] = {0};
        char szFrameName[64] = {0};

        GetPlateNameAlpha(
            (char*)szPlateName,
            ( PLATE_TYPE )pCarLeftInfo->cCoreResult.nType,
            ( PLATE_COLOR )pCarLeftInfo->cCoreResult.nColor,
            pCarLeftInfo->cCoreResult.rgbContent
        );

        if (strstr(szPlateName, "11111") != NULL)
        {
            HV_Trace(5, "M");
            //return S_FALSE;
        }

        HV_Trace(5,"%s\n", szPlateName);  //输出车牌字符串
        TiXmlElement* pValue = new TiXmlElement("PlateName");
        TiXmlText* pText = new TiXmlText(szPlateName);
        if (pValue && pText)
        {
            pValue->LinkEndChild(pText);
            pResult->LinkEndChild(pValue);
        }

        int nColorType = 0;
        if (strncmp(szPlateName, "蓝", 2) == 0)
        {
            nColorType = 1;
        }
        else if (strncmp(szPlateName, "黄", 2) == 0)
        {
            nColorType = 2;
        }
        else if (strncmp(szPlateName, "黑", 2) == 0)
        {
            nColorType = 3;
        }
        else if (strncmp(szPlateName, "白", 2) == 0)
        {
            nColorType = 4;
        }
        else if (strncmp(szPlateName, "绿", 2) == 0)
        {
            nColorType = 5;
        }
        else
        {
            nColorType = 0;
        }
//.........这里部分代码省略.........
开发者ID:fangbaolei,项目名称:EC700IR,代码行数:101,代码来源:DataCtrl.cpp

示例14: GetAutotestStatus

HRESULT CAutotest::GetAutotestStatus(PVOID* ppvOutBuf, DWORD* pdwOutSize)
{
#define HV_XML_CMD_VERSION_NO "3.0"
	
	
#define HVXML_VER 					"Ver"
#define HVXML_HVCMD					"HvCmd"
#define HVXML_HVCMDRESPOND 			"HvCmdRespond"
#define HVXML_RETCODE 				"RetCode"
#define HVXML_RETMSG 				"RetMsg"
#define HVXML_CMDNAME				"CmdName"
#define HVXML_RETURNLEN				"RetLen"

	
	if (NULL == ppvOutBuf || NULL == pdwOutSize)
	{
		SW_TRACE_DEBUG("Err: NULL == ppvOutBuf || NULL == pdwOutSize\n");
		return E_INVALIDARG;
	}
	
	if (!m_fInited)
	{
		SW_TRACE_DEBUG("Err: not inited yet!\n");
		return E_NOTIMPL;
	}

	TiXmlDocument xmlOutDoc;	
	TiXmlDeclaration *pDeclaration = NULL;
	TiXmlElement *pRootEle = NULL;

	pDeclaration = new TiXmlDeclaration("1.0","GB2312","yes");
	if (NULL == pDeclaration)
	{
		SW_TRACE_DEBUG("Err: no memory for pDeclaration\n");
		return E_OUTOFMEMORY;
	}
	xmlOutDoc.LinkEndChild(pDeclaration);

	pRootEle = new TiXmlElement(HVXML_HVCMDRESPOND);
	if (NULL == pRootEle)
	{	
		SW_TRACE_DEBUG("Err: no memory for pRootEle\n");
		return E_OUTOFMEMORY;
	}
	xmlOutDoc.LinkEndChild(pRootEle);
	
	pRootEle->SetAttribute(HVXML_VER, HV_XML_CMD_VERSION_NO);

	TiXmlElement *pReplyEle =  new TiXmlElement(HVXML_CMDNAME);
	if (NULL == pReplyEle)
	{	
		SW_TRACE_DEBUG("Err: no memory for pReplyEle\n");
		return E_OUTOFMEMORY;
	}
	pRootEle->LinkEndChild(pReplyEle);

	
	TiXmlText * pReplyText = new TiXmlText("GetAutotestProgress");
	if (NULL == pReplyText)
	{	
		SW_TRACE_DEBUG("Err: no memory for pReplyText\n");
		return E_OUTOFMEMORY;
	}
	pReplyEle->LinkEndChild(pReplyText);	


	if (0 == m_dwTestProgress)
	{	
		pReplyEle->SetAttribute(HVXML_RETCODE, 0);
		pReplyEle->SetAttribute(HVXML_RETMSG, "TestOK");
	}
	else if (1 == m_dwTestProgress)
	{
		pReplyEle->SetAttribute(HVXML_RETCODE, 0);
		pReplyEle->SetAttribute(HVXML_RETMSG, "Testing");
	}
	else if (2 == m_dwTestProgress)
	{
		pReplyEle->SetAttribute(HVXML_RETCODE, 0);
		pReplyEle->SetAttribute(HVXML_RETMSG, "TestFailed");
	}
	else
	{
		pReplyEle->SetAttribute(HVXML_RETCODE, -1);
		pReplyEle->SetAttribute(HVXML_RETMSG, "GetAutotestProgress Failed");
	}
	
	TiXmlPrinter xmlPrinter;

	xmlOutDoc.Accept(&xmlPrinter);

	*pdwOutSize = xmlPrinter.Size()+1;
	*ppvOutBuf = swpa_mem_alloc(*pdwOutSize);
	if (NULL == *ppvOutBuf)
	{
		SW_TRACE_DEBUG("Err: no memory for *ppvOutBuf!\n");
		return E_OUTOFMEMORY;
	}
	swpa_memset(*ppvOutBuf, 0, *pdwOutSize);

//.........这里部分代码省略.........
开发者ID:fangbaolei,项目名称:EC700IR,代码行数:101,代码来源:Autotest.cpp

示例15: invalid_argument


//.........这里部分代码省略.........
      auto  keyElement = new TiXmlElement( "property" );
      keyElement->SetAttribute( "key", it->first );
      keyElement->SetAttribute( "type", prop->GetNameOfClass() );

        serializer->SetProperty( prop );
      TiXmlElement* valueElement = nullptr;
      try
      {
        valueElement = serializer->Serialize();
      }
      catch (...)
      {
      }

      if ( valueElement == nullptr )
      {
        // Serialization failed; skip this property
        continue;
      }

      // Add value to property element
      keyElement->LinkEndChild( valueElement );

      // Append serialized property to property list
      pfElement->LinkEndChild( keyElement );
    }

    // Serialize control points of PlanarFigure
    auto  controlPointsElement = new TiXmlElement("ControlPoints");
    pfElement->LinkEndChild(controlPointsElement);
    for (unsigned int i = 0; i < pf->GetNumberOfControlPoints(); i++)
    {
      auto  vElement = new TiXmlElement("Vertex");
      vElement->SetAttribute("id", i);
      vElement->SetDoubleAttribute("x", pf->GetControlPoint(i)[0]);
      vElement->SetDoubleAttribute("y", pf->GetControlPoint(i)[1]);
      controlPointsElement->LinkEndChild(vElement);
    }
    auto  geoElement = new TiXmlElement("Geometry");
    const PlaneGeometry* planeGeo = dynamic_cast<const PlaneGeometry*>(pf->GetPlaneGeometry());
    if (planeGeo != nullptr)
    {
      // Write parameters of IndexToWorldTransform of the PlaneGeometry
      typedef mitk::Geometry3D::TransformType TransformType;
      const TransformType* affineGeometry = planeGeo->GetIndexToWorldTransform();
      const TransformType::ParametersType& parameters = affineGeometry->GetParameters();
      auto  vElement = new TiXmlElement( "transformParam" );
      for ( unsigned int i = 0; i < affineGeometry->GetNumberOfParameters(); ++i )
      {
        std::stringstream paramName;
        paramName << "param" << i;
        vElement->SetDoubleAttribute( paramName.str().c_str(), parameters.GetElement( i ) );
      }
      geoElement->LinkEndChild( vElement );

      // Write bounds of the PlaneGeometry
      typedef mitk::Geometry3D::BoundsArrayType BoundsArrayType;
      const BoundsArrayType& bounds = planeGeo->GetBounds();
      vElement = new TiXmlElement( "boundsParam" );
      for ( unsigned int i = 0; i < 6; ++i )
      {
        std::stringstream boundName;
        boundName << "bound" << i;
        vElement->SetDoubleAttribute( boundName.str().c_str(), bounds.GetElement( i ) );
      }
      geoElement->LinkEndChild( vElement );

      // Write spacing and origin of the PlaneGeometry
      Vector3D spacing = planeGeo->GetSpacing();
      Point3D origin = planeGeo->GetOrigin();
      geoElement->LinkEndChild(this->CreateXMLVectorElement("Spacing", spacing));
      geoElement->LinkEndChild(this->CreateXMLVectorElement("Origin", origin));

      pfElement->LinkEndChild(geoElement);
    }
  }


  if(m_WriteToMemory)
  {
    // Declare a printer
    TiXmlPrinter printer;
    // attach it to the document you want to convert in to a std::string
    document.Accept(&printer);

    // Create memory buffer and print tinyxmldocument there...
    m_MemoryBufferSize  = printer.Size() + 1;
    m_MemoryBuffer      = new char[m_MemoryBufferSize];
    strcpy(m_MemoryBuffer,printer.CStr());
  }
  else
  {
    if (document.SaveFile( m_FileName) == false)
    {
      MITK_ERROR << "Could not write planar figures to " << m_FileName << "\nTinyXML reports '" << document.ErrorDesc() << "'";
      throw std::ios_base::failure("Error during writing of planar figure xml file.");
    }
  }
  m_Success = true;
}
开发者ID:151706061,项目名称:MITK,代码行数:101,代码来源:mitkPlanarFigureWriter.cpp


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