void XMLNodeImpl::printNode( std::ostream& ostr ) const { String name = getName(); XMLAttributeArray aa = getAttrs(); ostr << '<' << name; for ( XMLAttributeArray::const_iterator aiter = aa.begin(); aiter != aa.end(); ++aiter ) { ostr << ' ' << aiter->getName() << "=\"" << XMLEscape(aiter->getValue()) << '"'; } if (getText().empty() && !getChild()) { ostr << "/>"; } else { ostr << '>'; ostr << XMLEscape(getText()); XMLNode curChild = getChild(); while (curChild) { curChild.printNode(ostr); curChild = curChild.getNext(); } ostr << "</" << name << '>'; } }
void printParam( const char * name, const std::string & value ) { std::string name_str( name ); std::string value_str( value ); XMLEscape( name_str ); XMLEscape( value_str ); std::cout << "<Param name=\"" << name_str << "\">" << value_str << "</Param>\n"; }
DECLARE_EXPORT void SetupMatrix::writeElement(XMLOutput *o, const Keyword& tag, mode m) const { // Writing a reference if (m == REFERENCE) { o->writeElement (tag, Tags::tag_name, getName(), Tags::tag_type, getType().type); return; } // Write the head if (m != NOHEAD && m != NOHEADTAIL) o->BeginObject (tag, Tags::tag_name, XMLEscape(getName()), Tags::tag_type, getType().type); // Write all rules o->BeginObject (Tags::tag_rules); for (RuleIterator i = beginRules(); i != endRules(); ++i) // We use the FULL mode, to force the rules being written regardless // of the depth in the XML tree. o->writeElement(Tags::tag_rule, *i, FULL); o->EndObject(Tags::tag_rules); // Write the tail if (m != NOHEADTAIL && m != NOTAIL) o->EndObject(tag); }
void printTeam( char side, const TeamT & team ) { std::cout << "<Team side=\"" << side << "\">"; std::string name( team.name_ ); XMLEscape( name ); std::cout << "<Name>" << name << "</Name>"; if ( team.score_ ) { std::cout << "<Score>" << team.score_ << "</Score>"; } std::cout << "</Team>\n"; }
void doHandleMsgInfo( const int, const int board, const std::string & msg ) { // format the string std::string msgcopy( msg ); XMLEscape( msgcopy ); std::cout << "<MsgInfo"; if ( board != 1 ) { std::cout << " board=\"" << board << "\""; } std::cout << ">" << msgcopy << "</MsgInfo>\n"; }
DECLARE_EXPORT void Location::writeElement(XMLOutput* o, const Keyword& tag, mode m) const { // Writing a reference if (m == REFERENCE) { o->writeElement(tag, Tags::tag_name, getName()); return; } // Write the head if (m != NOHEAD && m != NOHEADTAIL) o->BeginObject(tag, Tags::tag_name, XMLEscape(getName())); // Write the fields HasDescription::writeElement(o, tag); HasHierarchy<Location>::writeElement(o, tag); o->writeElement(Tags::tag_available, available); // Write the tail if (m != NOHEADTAIL && m != NOTAIL) o->EndObject(tag); }
DECLARE_EXPORT void Skill::writeElement(XMLOutput *o, const Keyword& tag, mode m) const { // Write a reference if (m == REFERENCE) { o->writeElement(tag, Tags::tag_name, getName()); return; } // Write the head if (m != NOHEAD && m != NOHEADTAIL) o->BeginObject(tag, Tags::tag_name, XMLEscape(getName())); // Write source field o->writeElement(Tags::tag_source, getSource()); // Write the custom fields PythonDictionary::write(o, getDict()); // Write the tail if (m != NOHEADTAIL && m != NOTAIL) o->EndObject(tag); }
DECLARE_EXPORT void SolverMRP::writeElement(XMLOutput *o, const Keyword& tag, mode m) const { // Writing a reference if (m == REFERENCE) { o->writeElement (tag, Tags::tag_name, getName(), Tags::tag_type, getType().type); return; } // Write the complete object if (m != NOHEAD && m != NOHEADTAIL) o->BeginObject (tag, Tags::tag_name, XMLEscape(getName()), Tags::tag_type, getType().type); // Write the fields if (constrts != 15) o->writeElement(Tags::tag_constraints, constrts); if (plantype != 1) o->writeElement(Tags::tag_plantype, plantype); // Parameters o->writeElement(tag_iterationthreshold, iteration_threshold); o->writeElement(tag_iterationaccuracy, iteration_accuracy); o->writeElement(tag_lazydelay, lazydelay); o->writeElement(Tags::tag_autocommit, autocommit); // User exit if (userexit_flow) o->writeElement(Tags::tag_userexit_flow, static_cast<string>(userexit_flow)); if (userexit_demand) o->writeElement(Tags::tag_userexit_demand, static_cast<string>(userexit_demand)); if (userexit_buffer) o->writeElement(Tags::tag_userexit_buffer, static_cast<string>(userexit_buffer)); if (userexit_resource) o->writeElement(Tags::tag_userexit_resource, static_cast<string>(userexit_resource)); if (userexit_operation) o->writeElement(Tags::tag_userexit_operation, static_cast<string>(userexit_operation)); // Write the parent class Solver::writeElement(o, tag, NOHEAD); }
DECLARE_EXPORT void Item::writeElement(XMLOutput *o, const Keyword& tag, mode m) const { // Writing a reference if (m == REFERENCE) { o->writeElement(tag, Tags::tag_name, getName()); return; } // Write the head if (m != NOHEAD && m != NOHEADTAIL) o->BeginObject(tag, Tags::tag_name, XMLEscape(getName())); // Write the fields HasDescription::writeElement(o, tag); HasHierarchy<Item>::writeElement(o, tag); o->writeElement(Tags::tag_operation, deliveryOperation); if (getPrice() != 0.0) o->writeElement(Tags::tag_price, getPrice()); // Write the tail if (m != NOHEADTAIL && m != NOTAIL) o->EndObject(tag); }
//-------------------------------------------------------------- /// Generates XML that describes the injected processes and which /// plugins were injected. /// \return string containing the XML //-------------------------------------------------------------- gtASCIIString ProcessTracker::GetProcessesXML() { std::unordered_map< DWORD, gtASCIIString > procXMLMap; this->UpdateListOfInjectedProcesses(); ProcessInfoList injectedProcesses = this->GetListOfInjectedProcesses(); WrapperMap wrappers = GetWrapperMap(); // the strPlatform is named this way to match options in the client. #ifdef X64 gtASCIIString strPlatform = "Win64"; #else gtASCIIString strPlatform = "Win32"; #endif #ifndef CODEXL_GRAPHICS if (injectedProcesses.empty() == true) { LogConsole(logERROR, "There are no processes running which have been injected with the GPU PerfStudio server plugin\n"); LogConsole(logERROR, "Please ensure that the server has the same bitness as the target application\n"); LogConsole(logERROR, "For example, use the 64-bit GPU PerfStudio server with a 64-bit application\n"); } #endif for (ProcessInfoList::iterator procIter = injectedProcesses.begin(); procIter != injectedProcesses.end(); ++procIter) { DWORD pid = procIter->th32ProcessID; // only add the process info if it wasn't already found. if (procXMLMap.find(pid) == procXMLMap.end()) { // insert new process and the process info gtASCIIString tmpString = XML("Name", XMLEscape(procIter->szExeFile).asCharArray()); tmpString += XML("PID", pid); tmpString += XML("Path", XMLEscape(procIter->szPath).asCharArray()); tmpString += XML("Platform", strPlatform.asCharArray()); procXMLMap[ pid ] = tmpString; // if this process is the one that was launched, then we know what the args and working directory were. // we could probably get the actual args and working dir from MicroDLL if it is a different app though, which // would be the case if this app uses a launcher app. if (m_injectedAppName.compare(procIter->szPath) == 0) { tmpString = XML("Args", XMLEscape(m_injectedAppArgs.c_str()).asCharArray()); tmpString += XML("WDir", XMLEscape(m_injectedAppDir.c_str()).asCharArray()); procXMLMap[ pid ] += tmpString.asCharArray(); } } // add an API node for each of the wrappers that are injected into the app for (WrapperMap::const_iterator wrapperIter = wrappers.begin(); wrapperIter != wrappers.end(); ++wrapperIter) { // List of plugin extensions to check for. On Windows, test for 32 and 64 bit plugins. // On linux, just check for the plugin corresponding to the server bitness static const char* pluginExtensions[] = { #ifdef WIN32 GDT_DEBUG_SUFFIX GDT_BUILD_SUFFIX "." DLL_EXTENSION, "-x64" GDT_DEBUG_SUFFIX GDT_BUILD_SUFFIX "." DLL_EXTENSION #else GDT_PROJECT_SUFFIX "." DLL_EXTENSION #endif }; int numPlugins = sizeof(pluginExtensions) / sizeof(pluginExtensions[0]); for (int loop = 0; loop < numPlugins; loop++) { // check to see if this wrapper is in the application gtASCIIString strPluginName = wrapperIter->second.strPluginName; if (SG_GET_BOOL(OptionDllReplacement) == false) { strPluginName += pluginExtensions[loop]; } if (IsLibraryLoadedInProcess(pid, strPluginName.asCharArray(), NULL)) { bool attached = false; if (g_activeWrappersMap.find(FormatText("%lu/%s", pid, wrapperIter->first.c_str()).asCharArray()) != g_activeWrappersMap.end()) { // the pid/plugin string was listed in the active wrappers map, so the plugin must be active. attached = true; } procXMLMap[pid] += XMLAttrib("API", FormatText("attached='%s'", attached ? "TRUE" : "FALSE").asCharArray(), wrapperIter->second.strPluginShortDesc.asCharArray()); } } } } // concatenate the process XML and additional info gtASCIIString xml; for (std::unordered_map< DWORD, gtASCIIString >::iterator iterP = procXMLMap.begin(); iterP != procXMLMap.end(); iterP++) { xml += XML("Process", (iterP->second).asCharArray()); } gtASCIIString out = XMLHeader(); out += XML("ProcessList", xml.asCharArray()); return out; }
int value2xml(CMPIData d, UtilStringBuffer * sb, int wv) { char str[256]; char *sp = str; int splen = 0; int freesp = 0; if (d.type & CMPI_ARRAY) { sb->ft->appendChars(sb, "**[]**"); return 1; } else { if (wv) SFCB_APPENDCHARS_BLOCK(sb, "<VALUE>"); if ((d.type & (CMPI_UINT | CMPI_SINT)) == CMPI_UINT) { unsigned long long ul = 0LL; switch (d.type) { case CMPI_uint8: ul = d.value.uint8; break; case CMPI_uint16: ul = d.value.uint16; break; case CMPI_uint32: ul = d.value.uint32; break; case CMPI_uint64: ul = d.value.uint64; break; } splen = sprintf(str, "%llu", ul); } else if (d.type & CMPI_SINT) { long long sl = 0LL; switch (d.type) { case CMPI_sint8: sl = d.value.sint8; break; case CMPI_sint16: sl = d.value.sint16; break; case CMPI_sint32: sl = d.value.sint32; break; case CMPI_sint64: sl = d.value.sint64; break; } splen = sprintf(str, "%lld", sl); } else if (d.type == CMPI_real32) { splen = sprintf(str, "%.7e", d.value.real32); } else if (d.type == CMPI_real64) { splen = sprintf(str, "%.16e", d.value.real64); } else if (d.type == CMPI_boolean) splen = sprintf(str, "%s", d.value.boolean ? "TRUE" : "FALSE"); else if (d.type == CMPI_char16) /* To support wide charset/unicode charset, review this line */ splen = sprintf(str, "%c", (CMPIChar16)d.value.char16); else if (d.type == CMPI_chars) { sp = XMLEscape(d.value.chars, &splen); if (sp) freesp = 1; } else if (d.type == CMPI_string) { sp = XMLEscape((char *) d.value.string->hdl, &splen); if (sp) freesp = 1; } else if (d.type == CMPI_dateTime) { if (d.value.dateTime) { CMPIString *sdf = CMGetStringFormat(d.value.dateTime, NULL); sp = (char *) sdf->hdl; splen = 25; } else { splen = 0; } } else if (d.type == CMPI_instance) { SFCB_APPENDCHARS_BLOCK(sb, "<![CDATA["); instance2xml(d.value.inst, sb, 0); SFCB_APPENDCHARS_BLOCK(sb, "]]>"); splen = 0; } else { mlogf(M_ERROR, M_SHOW, "%s(%d): invalid value2xml %d-%x\n", __FILE__, __LINE__, (int) d.type, (int) d.type); abort(); } if (splen) { sb->ft->appendBlock(sb, sp, splen); } if (wv) SFCB_APPENDCHARS_BLOCK(sb, "</VALUE>\n"); } if (freesp) free(sp); return 0; }