xmlDocPtr XaLibDom::DomFromFile(const vector<string> XmlFilesPath,const int& AddRootTag) { xmlDocPtr XmlDomDoc; string XmlStringTotal=""; if (AddRootTag==1){ XmlStringTotal.append("<root>"); } //ADDING FILE int XmlFilesSize=XmlFilesPath.size(); if(XmlFilesSize>0) { unique_ptr<XaLibChar> LibChar (new XaLibChar()); for(auto i=0; i<XmlFilesSize; i++) { string XmlFilePath=XmlFilesPath.at(i).c_str(); char* XmlFilePathChar=(char*)XmlFilePath.c_str(); ifstream MyFile; MyFile.open(XmlFilePathChar); if (MyFile.is_open()){ string TmpString; while(getline(MyFile,TmpString) ) { XaLibChar::ClearReturn(TmpString); //string TmpStringCleared=LibChar->ClearReturn(TmpString); XmlStringTotal.append(TmpString); } MyFile.close(); } } } const char *XmlChar = (char*)XmlStringTotal.c_str(); int XmlStringSize=XmlStringTotal.size(); XmlDomDoc = xmlRecoverMemory(XmlChar,XmlStringSize); return XmlDomDoc; };
void XaLibWs::GetEncodedData(){ if (Encoding=="B64") { LOG.Write("INF",__FILE__,__FUNCTION__,__LINE__,"Ws Requested Decode ->" + Encoding); unique_ptr<XaLibChar> LibChar(new XaLibChar()); Data=LibChar->B64Decode(Data); //throw 108 } else { LOG.Write("ERR",__FILE__,__FUNCTION__,__LINE__,"Ws Requested Encoding Is Not Supported ->" + Encoding); Data=""; throw 109; } };
void XaMediaData::Create(){ vector<string> FieldName; vector<string> FieldValue; unique_ptr<XaLibChar> LibChar (new XaLibChar()); string XaMediaId=HTTP.GetHttpParam("XaMedia_ID"); string File=LibChar->B64Decode(HTTP.GetHttpParam("data")); int FileSize=File.size(); double KFileSize = round(FileSize/1024); string KSize = FromDoubleToString(KFileSize); string FileName = ComposeFileName(XaMediaId); FieldName.push_back("file_name"); FieldValue.push_back(FileName); FieldName.push_back("ksize"); FieldValue.push_back(KSize); CreatePrepare({"XaMediaData"},"/XaMediaData/fieldset/field",FieldName,FieldValue); CreateExecute("XaMediaData",FieldName,FieldValue); };
xmlDocPtr XaLibDom::DomFromStringAndFile(const VectorXmlFilePath& XmlFiles,const VectorXmlString& XmlStrings,const int& AddRootTag) { xmlDocPtr XmlDomDoc; string XmlStringTotal=""; if (AddRootTag==1){ XmlStringTotal.append("<root>"); } else if(AddRootTag==2){ XmlStringTotal.append("<?xml version=\"1.0\" encoding=\"UTF-8\"?>"); XmlStringTotal.append("<xsl:stylesheet version=\"1.0\" xmlns:xsl=\"http://www.w3.org/1999/XSL/Transform\">"); XmlStringTotal.append("<xsl:output method=\"html\" encoding=\"UTF-8\"/>"); } //ADDING FILE int XmlFilesSize=XmlFiles.size(); if(XmlFilesSize>0) { unique_ptr<XaLibChar> LibChar (new XaLibChar()); for(int i=0; i<XmlFilesSize; i++) { string XmlFilePath=XmlFiles.at(i).c_str(); char* XmlFilePathChar=(char*)XmlFilePath.c_str(); ifstream MyFile; MyFile.open(XmlFilePathChar); if (MyFile.is_open()){ string TmpString; while(getline(MyFile,TmpString) ) { XaLibChar::ClearReturn(TmpString); //string TmpStringCleared=LibChar->ClearReturn(TmpString); XmlStringTotal.append(TmpString); } MyFile.close(); } } } //ADDING STRINGS int XmlStringsSize=XmlStrings.size(); if(XmlStringsSize>0) { for(int j=0; j<XmlStringsSize; j++) { string XmlString=XmlStrings.at(j).c_str(); XmlStringTotal.append(XmlString); } } if (AddRootTag==1){ XmlStringTotal.append("</root>"); } else if(AddRootTag==2){ XmlStringTotal.append("</xsl:stylesheet>"); } const char *XmlChar = (char*)XmlStringTotal.c_str(); int XmlStringSize=XmlStringTotal.size(); XmlDomDoc = xmlRecoverMemory(XmlChar,XmlStringSize); return XmlDomDoc; };