serialize-xml.C

Go to the documentation of this file.
00001 /*
00002  * See the dyninst/COPYRIGHT file for copyright information.
00003  * 
00004  * We provide the Paradyn Tools (below described as "Paradyn")
00005  * on an AS IS basis, and do not warrant its validity or performance.
00006  * We reserve the right to update, modify, or discontinue this
00007  * software at any time.  We shall have no obligation to supply such
00008  * updates or modifications or any other form of support to you.
00009  * 
00010  * By your use of Paradyn, you understand and agree that we (or any
00011  * other person or entity with proprietary rights in Paradyn) are
00012  * under no obligation to provide either maintenance services,
00013  * update services, notices of latent defects, or correction of
00014  * defects for Paradyn.
00015  * 
00016  * This library is free software; you can redistribute it and/or
00017  * modify it under the terms of the GNU Lesser General Public
00018  * License as published by the Free Software Foundation; either
00019  * version 2.1 of the License, or (at your option) any later version.
00020  * 
00021  * This library is distributed in the hope that it will be useful,
00022  * but WITHOUT ANY WARRANTY; without even the implied warranty of
00023  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
00024  * Lesser General Public License for more details.
00025  * 
00026  * You should have received a copy of the GNU Lesser General Public
00027  * License along with this library; if not, write to the Free Software
00028  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
00029  */
00030 
00031 #include "common/h/serialize.h"
00032 
00033 #if !defined(SERIALIZATION_DISABLED)
00034 
00035 #if !defined(os_windows)
00036 #include "common/h/pathName.h"
00037 #include <dlfcn.h>
00038 #if defined (cap_have_libxml)
00039 //libxml2 functions
00040 void *hXML;
00041 #endif
00042 #else
00043 #include "windows.h"
00044 #if defined (cap_have_libxml)
00045 #include <libxml/xmlversion.h>
00046 #undef LIBXML_ICONV_ENABLED
00047 HINSTANCE hXML;
00048 #endif
00049 #endif
00050 
00051 #if defined (cap_have_libxml)
00052 #if defined (os_linux) || defined (os_aix)
00053 //  gcc is complaining about the constness of the library-provided
00054 //  typecast (BAD_CAST) (which is defined in xmlstring.h), so we make our own
00055 #define XMLCHAR_CAST (const xmlChar *)
00056 #else
00057 #define XMLCHAR_CAST BAD_CAST
00058 #endif
00059 
00060 #else
00061 #define XMLCHAR_CAST (const char *)
00062 #endif
00063 
00064 #if 0
00065 SerDesXML &SerializerXML::getSD_xml()
00066 {
00067    SerDes &sd = getSD();
00068    SerDesXML *sdxml = dynamic_cast<SerDesXML *> (&sd);
00069    assert(sdxml);
00070    return *sdxml;
00071 }
00072 #endif
00073 
00074 
00075 #if 0
00076 bool end_xml_element(SerializerBase *, const char *);
00077 #endif
00078 
00079 
00080 
00081 // DLLEXPORT SerDesXML(xmlTextWriterPtr w, iomode_t mode)  : SerDes(mode), writer(w) { }
00082 // DLLEXPORT static xmlTextWriterPtr init(std::string fname, iomode_t mode, bool verbose);
00083 
00084 #if defined (cap_have_libxml)
00085 xmlTextWriterPtr(*my_xmlNewTextWriterFilename)(const char *,int) = NULL;
00086 
00087 int (*my_xmlTextWriterStartDocument)(xmlTextWriterPtr, 
00088       const char *, const char *, const char * ) = NULL;
00089 
00090 int (*my_xmlTextWriterStartElement)(xmlTextWriterPtr, 
00091       const xmlChar *) = NULL;
00092 
00093 int (*my_xmlTextWriterWriteFormatElement)(xmlTextWriterPtr,
00094       const xmlChar *,const char *,...) = NULL;
00095 
00096 int (*my_xmlTextWriterEndDocument)(xmlTextWriterPtr) = NULL;
00097 
00098 void (*my_xmlFreeTextWriter)(xmlTextWriterPtr) = NULL;
00099 
00100 int (*my_xmlTextWriterWriteFormatAttribute)(xmlTextWriterPtr, 
00101       const xmlChar *,const char *,...) = NULL;
00102 
00103 int (*my_xmlTextWriterEndElement)(xmlTextWriterPtr) = NULL;
00104 
00105 xmlTextWriterPtr SerDesXML::init(std::string fname, iomode_t /*mode*/, bool /*verbose*/) 
00106 {
00107 #if defined(_MSC_VER)
00108    hXML = LoadLibrary(LPCSTR("../../../i386-unknown-nt4.0/lib/libxml2.dll"));
00109    if (hXML == NULL)
00110    {
00111       char buf[1000];
00112       DWORD result = FormatMessage(FORMAT_MESSAGE_FROM_SYSTEM, NULL, GetLastError(),
00113         MAKELANGID(LANG_NEUTRAL, SUBLANG_DEFAULT),
00114         buf, 1000, NULL);
00115       SER_ERR(buf);
00116    }
00117 
00118     my_xmlNewTextWriterFilename = 
00119        (xmlTextWriterPtr (*)(const char *,int)) GetProcAddress(hXML,"xmlNewTextWriterFilename");
00120     
00121     my_xmlTextWriterStartDocument = 
00122        (int (*)(xmlTextWriterPtr, const char *, const char *, const char * ))GetProcAddress(hXML,"xmlTextWriterStartDocument");
00123     
00124     my_xmlTextWriterStartElement = 
00125        (int (*)(xmlTextWriterPtr, const xmlChar *))GetProcAddress(hXML,"xmlTextWriterStartElement");
00126 
00127     my_xmlTextWriterWriteFormatElement = 
00128        (int (*)(xmlTextWriterPtr,const xmlChar *,const char *,...))GetProcAddress(hXML,"xmlTextWriterWriteFormatElement");
00129 
00130     my_xmlTextWriterEndDocument = 
00131        (int (*)(xmlTextWriterPtr))GetProcAddress(hXML,"xmlTextWriterEndDocument");
00132 
00133     my_xmlFreeTextWriter = 
00134        (void (*)(xmlTextWriterPtr))GetProcAddress(hXML,"xmlFreeTextWriter");
00135 
00136     my_xmlTextWriterWriteFormatAttribute = 
00137        (int (*)(xmlTextWriterPtr, const xmlChar *,const char *,...))GetProcAddress(hXML,"xmlTextWriterWriteFormatAttribute");
00138     
00139     my_xmlTextWriterEndElement = 
00140        (int (*)(xmlTextWriterPtr))GetProcAddress(hXML,"xmlTextWriterEndElement");
00141 
00142 #else
00143 
00144     hXML = dlopen("libxml2.so", RTLD_LAZY);
00145 
00146     if (hXML == NULL)
00147     {
00148       SER_ERR("Unable to find libxml2");
00149       return NULL;
00150     }
00151 
00152     my_xmlNewTextWriterFilename = (xmlTextWriterPtr(*)(const char *,int))dlsym(hXML,"xmlNewTextWriterFilename");
00153     my_xmlTextWriterStartDocument = (int(*)(xmlTextWriterPtr, const char *, const char *, const char * ))dlsym(hXML,"xmlTextWriterStartDocument");
00154     my_xmlTextWriterStartElement = (int(*)(xmlTextWriterPtr, const xmlChar *))dlsym(hXML,"xmlTextWriterStartElement");
00155     my_xmlTextWriterWriteFormatElement = (int(*)(xmlTextWriterPtr,const xmlChar *,const char *,...))dlsym(hXML,"xmlTextWriterWriteFormatElement");
00156     my_xmlTextWriterEndDocument = (int(*)(xmlTextWriterPtr))dlsym(hXML,"xmlTextWriterEndDocument");
00157     my_xmlFreeTextWriter = (void(*)(xmlTextWriterPtr))dlsym(hXML,"xmlFreeTextWriter");
00158     my_xmlTextWriterWriteFormatAttribute = (int(*)(xmlTextWriterPtr, const xmlChar *,const char *,...))dlsym(hXML,"xmlTextWriterWriteFormatAttribute");
00159     my_xmlTextWriterEndElement = (int(*)(xmlTextWriterPtr))dlsym(hXML,"xmlTextWriterEndElement");
00160 
00161 #endif
00162 
00163     /* Create a new XmlWriter for DOM */
00164 
00165     xmlTextWriterPtr writer = my_xmlNewTextWriterFilename(fname.c_str(), 0);
00166 
00167     if (writer == NULL) 
00168     {
00169         SER_ERR("testXmlwriterDoc: Error creating the xml writer");
00170       return NULL;
00171     }
00172 
00173     int rc = my_xmlTextWriterStartDocument(writer, NULL, "ISO-8859-1", NULL);
00174 
00175     if (rc < 0) 
00176     {
00177         SER_ERR("testXmlwriterDoc: Error at my_xmlTextWriterStartDocument");
00178     return NULL;
00179     }
00180 
00181     return writer;
00182 }
00183 
00184 #endif // defined (cap_have_libxml)
00185 
00186 
00187 namespace Dyninst {
00188 #if defined (cap_have_libxml)
00189 //int (*my_xmlTextWriterStartElement)(xmlTextWriterPtr, 
00190 //      const xmlChar *) = NULL;
00191 bool start_xml_elem(void *writer, const char *tag)
00192 {
00193     int rc = my_xmlTextWriterStartElement((xmlTextWriterPtr) writer, XMLCHAR_CAST tag);
00194     return (rc >= 0);
00195 }
00196 //    my_xmlTextWriterEndElement(writer);
00197 
00198 bool end_xml_elem(void *writer)
00199 {
00200     int rc = my_xmlTextWriterEndElement((xmlTextWriterPtr) writer);
00201     return (rc >= 0);
00202 }
00203 
00204 bool write_xml_elem(void *writer, const char *tag, const char *fmt, ...)
00205 {
00206    va_list ap;
00207    va_start(ap, fmt);
00208 
00209    int rc = my_xmlTextWriterWriteFormatElement((xmlTextWriterPtr) writer, XMLCHAR_CAST tag, fmt, ap);
00210 
00211    if (rc < 0) 
00212    {
00213       SER_ERR("testXmlwriterDoc: Error at my_xmlTextWriterStartElement");
00214    }
00215 
00216    va_end(ap);
00217 
00218    return (rc >= 0);
00219 }
00220 #else
00221 
00222 bool start_xml_elem(void * /*writer*/, const char * /*xmlChar*/)
00223 {
00224    fprintf(stderr, "%s[%d]:  xml output is disabled\n", FILE__, __LINE__);
00225    return false;
00226 }
00227 
00228 bool end_xml_elem(void * /*writer*/)
00229 {
00230    fprintf(stderr, "%s[%d]:  xml output is disabled\n", FILE__, __LINE__);
00231    return false;
00232 }
00233 
00234 bool write_xml_elem(void * /*writer*/, const char * /*tag*/, const char * /*fmt*/, ...)
00235 {
00236    fprintf(stderr, "%s[%d]:  xml output is disabled\n", FILE__, __LINE__);
00237    return false;
00238 }
00239 #endif
00240 }
00241 
00242 namespace Dyninst {
00243 bool start_xml_elem(SerDesXML &s, const char *tag)
00244 {
00245     return start_xml_elem(s.writer, tag);
00246 }
00247 bool end_xml_elem(SerDesXML &s)
00248 {
00249     return end_xml_elem(s.writer);
00250 }
00251 }
00252 
00253 namespace Dyninst {
00254 bool ifxml_start_element(SerializerBase *sb, const char *tag)
00255 {
00256 #if 0
00257    SerializerXML *sxml = dynamic_cast<SerializerXML *>(sb);
00258    if (!sxml) 
00259    {
00260       return false;
00261    }
00262 
00263    if (sxml->iomode() == sd_deserialize) 
00264    {
00265       fprintf(stderr, "%s[%d]:  ERROR:  request to deserialize xml\n", FILE__, __LINE__);
00266       return false;
00267    }
00268 #endif
00269    if (!sb->isXML())
00270        return false;
00271    if (!sb->isOutput())
00272    {
00273       fprintf(stderr, "%s[%d]:  ERROR:  request to deserialize xml\n", FILE__, __LINE__);
00274       return false;
00275    }
00276 
00277    SerDes &sd = sb->getSD();
00278    SerDesXML *sdxml = dynamic_cast<SerDesXML *>(&sd);
00279    assert(sdxml);
00280    ::start_xml_elem(sdxml->writer, tag);
00281 
00282 #if 0
00283    sxml->getSD_xml().start_element(tag);
00284 #endif
00285 
00286    return true;
00287 }
00288 }
00289 
00290 namespace Dyninst {
00291 COMMON_EXPORT bool ifxml_end_element(SerializerBase *sb, const char * /*tag*/)
00292 {
00293 #if 0
00294    SerializerXML *sxml = dynamic_cast<SerializerXML *>(sb);
00295 
00296    if (!sxml) 
00297    {
00298       return false;
00299    }
00300 
00301    if (sxml->iomode() == sd_deserialize) 
00302    {
00303       fprintf(stderr, "%s[%d]:  ERROR:  request to deserialize xml\n", FILE__, __LINE__);
00304       return false;
00305    }
00306 #endif
00307    if (!sb->isXML())
00308        return false;
00309    if (!sb->isOutput())
00310    {
00311       fprintf(stderr, "%s[%d]:  ERROR:  request to deserialize xml\n", FILE__, __LINE__);
00312       return false;
00313    }
00314 
00315    SerDes &sd = sb->getSD();
00316    SerDesXML *sdxml = dynamic_cast<SerDesXML *>(&sd);
00317    assert(sdxml);
00318    ::end_xml_elem(sdxml->writer);
00319    
00320 #if 0
00321    sxml->getSD_xml().end_element();
00322 #endif
00323 
00324    return true;
00325 }
00326 }
00327 
00328 bool SerializerXML::start_xml_element(SerializerBase *sb, const char *tag)
00329 {
00330     SerializerXML *sxml = dynamic_cast<SerializerXML *>(sb);
00331 
00332     if (!sxml)
00333     {
00334         fprintf(stderr, "%s[%d]:  FIXME:  called xml function with non xml serializer\n",
00335                 FILE__, __LINE__);
00336         return false;
00337     }
00338 
00339     SerDesXML sdxml = sxml->getSD_xml();
00340     start_xml_elem(sdxml, tag);
00341     return true;
00342 
00343 }
00344 #if 0
00345 bool SerializerXML::start_xml_element(SerializerBase *sb, const char *tag)
00346 {
00347     SerializerXML *sxml = dynamic_cast<SerializerXML *>(sb);
00348 
00349     if (!sxml) 
00350     {
00351       fprintf(stderr, "%s[%d]:  FIXME:  called xml function with non xml serializer\n", 
00352             FILE__, __LINE__);
00353       return false;
00354    }
00355 
00356    SerDesXML sdxml = sxml->getSD_xml();
00357    start_xml_elem(sdxml.writer, tag);
00358 
00359 #if 0
00360    sdxml.start_element(tag); 
00361 #endif
00362 
00363    return true;
00364 }
00365 #endif
00366 
00367 SerDesXML &SerializerXML::getSD_xml()
00368 {
00369     SerializerBase *sb = this;
00370     SerDes &sd = sb->getSD();
00371     SerDesXML *sdxml = dynamic_cast<SerDesXML *> (&sd);
00372     assert(sdxml);
00373     return *sdxml;
00374 }
00375 
00376 bool SerializerXML::end_xml_element(SerializerBase * sb, const char  * /*tag*/)
00377 {
00378    SerializerXML *sxml = dynamic_cast<SerializerXML *>(sb);
00379 
00380    if (!sxml) 
00381    {
00382       fprintf(stderr, "%s[%d]:  FIXME:  called xml function with non xml serializer\n", 
00383             FILE__, __LINE__);
00384       return false;
00385    }
00386 
00387    SerDesXML sdxml = sxml->getSD_xml();
00388    end_xml_elem(sdxml);
00389 
00390 #if 0
00391    sdxml.end_element(); 
00392 #endif
00393    return true;
00394 }
00395 
00396 SerDesXML::~SerDesXML()
00397 {
00398 #if defined (cap_have_libxml)
00399     my_xmlFreeTextWriter(writer);
00400 #endif
00401 
00402 }
00403 
00404 void SerDesXML::vector_start(unsigned long &/*size*/, const char *tag) DECLTHROW(SerializerError)
00405 {
00406    bool rc = ::start_xml_elem(writer, tag);
00407 
00408    if (!rc)
00409    {
00410         SER_ERR("testXmlwriterDoc: Error at my_xmlTextWriterStartElement");
00411    }
00412 
00413 #if 0
00414     int rc = my_xmlTextWriterStartElement(writer, XMLCHAR_CAST tag);
00415     if (rc < 0) {
00416         SER_ERR("testXmlwriterDoc: Error at my_xmlTextWriterStartElement");
00417     }
00418 #endif
00419 }
00420 
00421 void SerDesXML::vector_end()
00422 {
00423    bool rc = ::end_xml_elem(writer);
00424    if (!rc) 
00425    {
00426       SER_ERR("testXmlwriterDoc: Error at my_xmlTextWriterStartElement");
00427    }
00428 
00429 #if 0
00430     int rc = my_xmlTextWriterEndElement(writer);
00431     if (rc < 0) {
00432         SER_ERR("testXmlwriterDoc: Error at my_xmlTextWriterStartElement");
00433     }
00434 #endif
00435 }
00436 
00437 void SerDesXML::multimap_start(unsigned long &/*size*/, const char *tag) DECLTHROW(SerializerError)
00438 {
00439    bool rc = ::start_xml_elem(writer, tag);
00440 
00441    if (!rc)
00442    {
00443         SER_ERR("testXmlwriterDoc: Error at my_xmlTextWriterStartElement");
00444    }
00445 #if 0
00446     int rc = my_xmlTextWriterStartElement(writer, XMLCHAR_CAST tag);
00447     if (rc < 0) {
00448         SER_ERR("testXmlwriterDoc: Error at my_xmlTextWriterStartElement");
00449     }
00450 #endif
00451 }
00452 
00453 void SerDesXML::multimap_end()
00454 {
00455    bool rc = ::end_xml_elem(writer);
00456    if (!rc) 
00457    {
00458       SER_ERR("testXmlwriterDoc: Error at my_xmlTextWriterStartElement");
00459    }
00460 
00461 #if 0
00462     int rc = my_xmlTextWriterEndElement(writer);
00463     if (rc < 0) {
00464         SER_ERR("testXmlwriterDoc: Error at my_xmlTextWriterStartElement");
00465     }
00466 #endif
00467 }
00468 
00469 void SerDesXML::pair_start(const char *tag) DECLTHROW(SerializerError)
00470 {
00471    bool rc = ::start_xml_elem(writer, tag);
00472 
00473    if (!rc)
00474    {
00475         SER_ERR("testXmlwriterDoc: Error at my_xmlTextWriterStartElement");
00476    }
00477 #if 0
00478     int rc = my_xmlTextWriterStartElement(writer, XMLCHAR_CAST tag);
00479     if (rc < 0) {
00480         SER_ERR("testXmlwriterDoc: Error at my_xmlTextWriterStartElement");
00481     }
00482 #endif
00483 }
00484 
00485 void SerDesXML::pair_end()
00486 {
00487    bool rc = ::end_xml_elem(writer);
00488    if (!rc) 
00489    {
00490       SER_ERR("testXmlwriterDoc: Error at my_xmlTextWriterStartElement");
00491    }
00492 
00493 #if 0
00494     int rc = my_xmlTextWriterEndElement(writer);
00495     if (rc < 0) {
00496         SER_ERR("testXmlwriterDoc: Error at my_xmlTextWriterStartElement");
00497     }
00498 #endif
00499 }
00500 void SerDesXML::hash_map_start(unsigned long &/*size*/, const char *tag) DECLTHROW(SerializerError)
00501 {
00502    bool rc = ::start_xml_elem(writer,  tag);
00503 
00504    if (!rc)
00505    {
00506         SER_ERR("testXmlwriterDoc: Error at my_xmlTextWriterStartElement");
00507    }
00508 #if 0
00509     int rc = my_xmlTextWriterStartElement(writer, XMLCHAR_CAST tag);
00510     if (rc < 0) {
00511         SER_ERR("testXmlwriterDoc: Error at my_xmlTextWriterStartElement");
00512     }
00513 #endif
00514 }
00515 
00516 void SerDesXML::hash_map_end()
00517 {
00518    bool rc = ::end_xml_elem(writer);
00519    if (!rc) 
00520    {
00521       SER_ERR("testXmlwriterDoc: Error at my_xmlTextWriterStartElement");
00522    }
00523 
00524 #if 0
00525     int rc = my_xmlTextWriterEndElement(writer);
00526     if (rc < 0) {
00527         SER_ERR("testXmlwriterDoc: Error at my_xmlTextWriterStartElement");
00528     }
00529 #endif
00530 }
00531 
00532 void SerDesXML::annotation_start(Dyninst::AnnotationClassID &a_id, void *& parent_id, sparse_or_dense_anno_t &sod, const char * /*id*/, const char * tag) 
00533 {
00534    bool rc = ::start_xml_elem(writer, tag);
00535 
00536    if (!rc)
00537    {
00538         SER_ERR("testXmlwriterDoc: Error at my_xmlTextWriterStartElement");
00539    }
00540    translate(a_id, "annotationID");
00541    translate((Address &)parent_id, "annotatableID");
00542    translate((int &) sod, "SparseOrDense");
00543    //char sodstr[12];
00544    //sprintf(sodstr, "%s", sod == sparse ? "sparse" : "dense");
00545    //const char *sodstr = (sod == sparse) ? "sparse" : "dense";
00546    //translate((const char *&)const_cast<const char *>(sodstr), 12, "SparseOrDense");
00547 }
00548 
00549 void SerDesXML::annotation_end()
00550 {
00551    bool rc = ::end_xml_elem(writer);
00552    if (!rc) 
00553    {
00554       SER_ERR("testXmlwriterDoc: Error at my_xmlTextWriterStartElement");
00555    }
00556 
00557 }
00558 
00559 void SerDesXML::annotation_container_start(void *& id) 
00560 {
00561    bool rc = ::start_xml_elem(writer, "AnnotationContainer");
00562 
00563    if (!rc)
00564    {
00565         SER_ERR("testXmlwriterDoc: Error at my_xmlTextWriterStartElement");
00566    }
00567    translate((Address &)id, "containerID");
00568 }
00569 
00570 void SerDesXML::annotation_container_end()
00571 {
00572    bool rc = ::end_xml_elem(writer);
00573    if (!rc) 
00574    {
00575       SER_ERR("testXmlwriterDoc: Error at my_xmlTextWriterStartElement");
00576    }
00577 
00578 }
00579 
00580 void SerDesXML::annotation_container_item_start(void *& id) 
00581 {
00582    bool rc = ::start_xml_elem(writer, "AnnotationContainerItem");
00583 
00584    if (!rc)
00585    {
00586         SER_ERR("testXmlwriterDoc: Error at my_xmlTextWriterStartElement");
00587    }
00588    translate((Address &)id, "containerID");
00589 }
00590 
00591 void SerDesXML::annotation_container_item_end()
00592 {
00593    bool rc = ::end_xml_elem(writer);
00594    if (!rc) 
00595    {
00596       SER_ERR("testXmlwriterDoc: Error at my_xmlTextWriterStartElement");
00597    }
00598 
00599 }
00600 void SerDesXML::annotation_list_start(Address &/*id*/, unsigned long &/*nelem*/, const char * tag) 
00601 {
00602    bool rc = ::start_xml_elem(writer, tag);
00603 
00604    if (!rc)
00605    {
00606         SER_ERR("testXmlwriterDoc: Error at my_xmlTextWriterStartElement");
00607    }
00608 }
00609 
00610 void SerDesXML::annotation_list_end()
00611 {
00612    bool rc = ::end_xml_elem(writer);
00613    if (!rc) 
00614    {
00615       SER_ERR("testXmlwriterDoc: Error at my_xmlTextWriterStartElement");
00616    }
00617 
00618 }
00619 void SerDesXML::translate(bool &param, const char *tag)
00620 {       
00621    bool rc = write_xml_elem(writer, tag,
00622          "%s", param ? "true" : "false");
00623 
00624    if (!rc) 
00625    {
00626       SER_ERR("testXmlwriterDoc: Error at my_xmlTextWriterStartElement");
00627    }
00628 
00629 #if 0
00630     int rc = my_xmlTextWriterWriteFormatElement(writer, XMLCHAR_CAST tag,
00631                                                 "%s", param ? "true" : "false");
00632     if (rc < 0) {
00633         SER_ERR("testXmlwriterDoc: Error at my_xmlTextWriterStartElement");
00634     }
00635 #endif
00636     
00637 }     
00638 
00639 void SerDesXML::translate(char &param, const char *tag)
00640 {       
00641    bool rc = write_xml_elem(writer, tag,
00642          "%c", param);
00643 
00644    if (!rc) 
00645    {
00646       SER_ERR("testXmlwriterDoc: Error at my_xmlTextWriterStartElement");
00647    }
00648 
00649 #if 0
00650     int rc = my_xmlTextWriterWriteFormatElement(writer, XMLCHAR_CAST tag,
00651                                                 "%c", param);
00652     if (rc < 0) {
00653         SER_ERR("testXmlwriterDoc: Error at my_xmlTextWriterStartElement");
00654     }
00655 #endif
00656     
00657 }     
00658 
00659 void SerDesXML::translate(int &param, const char *tag)
00660 {   
00661    bool rc = write_xml_elem(writer, tag,
00662          "%d", param);
00663 
00664    if (!rc) 
00665    {
00666       SER_ERR("testXmlwriterDoc: Error at my_xmlTextWriterStartElement");
00667    }
00668     
00669 #if 0
00670     int rc = my_xmlTextWriterWriteFormatElement(writer, XMLCHAR_CAST tag,
00671                                                  "%d", param);
00672     if (rc < 0) {
00673         SER_ERR("testXmlwriterDoc: Error at my_xmlTextWriterStartElement");
00674     }
00675 #endif
00676 }
00677 
00678 void SerDesXML::translate(long &param, const char *tag)
00679 {   
00680    bool rc = write_xml_elem(writer, tag,
00681          "%l", param);
00682 
00683    if (!rc) 
00684    {
00685       SER_ERR("testXmlwriterDoc: Error at my_xmlTextWriterStartElement");
00686    }
00687     
00688 #if 0
00689     int rc = my_xmlTextWriterWriteFormatElement(writer, XMLCHAR_CAST tag,
00690                                                  "%l", param);
00691     if (rc < 0) {
00692         SER_ERR("testXmlwriterDoc: Error at my_xmlTextWriterStartElement");
00693     }
00694 #endif
00695 }
00696 
00697 void SerDesXML::translate(short &param, const char *tag)
00698 {   
00699    bool rc = write_xml_elem(writer, tag,
00700          "%h", param);
00701 
00702    if (!rc) 
00703    {
00704       SER_ERR("testXmlwriterDoc: Error at my_xmlTextWriterStartElement");
00705    }
00706     
00707 #if 0
00708     int rc = my_xmlTextWriterWriteFormatElement(writer, XMLCHAR_CAST tag,
00709                                                  "%h", param);
00710     if (rc < 0) {
00711         SER_ERR("testXmlwriterDoc: Error at my_xmlTextWriterStartElement");
00712     }
00713 #endif
00714 }
00715 
00716 void SerDesXML::translate(unsigned short &param, const char *tag)
00717 {   
00718    bool rc = write_xml_elem(writer, tag,
00719          "%h", param);
00720 
00721    if (!rc) 
00722    {
00723       SER_ERR("testXmlwriterDoc: Error at my_xmlTextWriterStartElement");
00724    }
00725     
00726 #if 0
00727     int rc = my_xmlTextWriterWriteFormatElement(writer, XMLCHAR_CAST tag,
00728                                                  "%h", param);
00729     if (rc < 0) {
00730         SER_ERR("testXmlwriterDoc: Error at my_xmlTextWriterStartElement");
00731     }
00732 #endif
00733 }
00734 void SerDesXML::translate(unsigned int &param, const char *tag)
00735 {   
00736   translate( param, tag);
00737 }
00738 
00739 #if 0
00740 void SerDesXML::translate(OFFSET &param, const char *tag)
00741 {
00742 
00743     int rc = my_xmlTextWriterWriteFormatElement(writer, XMLCHAR_CAST tag,
00744                                                  "%lx", param);
00745     if (rc < 0) {
00746         SER_ERR("testXmlwriterDoc: Error at my_xmlTextWriterStartElement");
00747     }
00748 }
00749 #endif
00750 
00751 void SerDesXML::translate(float &param, const char *tag)
00752 {
00753    bool rc = write_xml_elem(writer, tag,
00754          "%e", param);
00755 
00756    if (!rc) 
00757    {
00758       SER_ERR("testXmlwriterDoc: Error at my_xmlTextWriterStartElement");
00759    }
00760 
00761 #if 0
00762     int rc = my_xmlTextWriterWriteFormatElement(writer, XMLCHAR_CAST tag,
00763                                                  "%e", param);
00764     if (rc < 0) {
00765         SER_ERR("testXmlwriterDoc: Error at my_xmlTextWriterStartElement");
00766     }
00767 #endif
00768 }
00769 
00770 void SerDesXML::translate(double &param, const char *tag)
00771 {
00772    bool rc = write_xml_elem(writer, tag,
00773          "%g", param);
00774 
00775    if (!rc) 
00776    {
00777       SER_ERR("testXmlwriterDoc: Error at my_xmlTextWriterStartElement");
00778    }
00779 
00780 #if 0
00781     int rc = my_xmlTextWriterWriteFormatElement(writer, XMLCHAR_CAST tag,
00782                                                  "%g", param);
00783     if (rc < 0) {
00784         SER_ERR("testXmlwriterDoc: Error at my_xmlTextWriterStartElement");
00785     }
00786 #endif
00787 }
00788 
00789 void SerDesXML::translate(Address &param, const char *tag)
00790 {
00791    bool rc = write_xml_elem(writer, tag,
00792          "%p", param);
00793 
00794    if (!rc) 
00795    {
00796       SER_ERR("testXmlwriterDoc: Error at my_xmlTextWriterStartElement");
00797    }
00798 
00799 #if 0
00800     int rc = my_xmlTextWriterWriteFormatElement(writer, XMLCHAR_CAST tag,
00801                                                  "%p", param);
00802     if (rc < 0) {
00803         SER_ERR("testXmlwriterDoc: Error at my_xmlTextWriterStartElement");
00804     }
00805 #endif
00806 }
00807 
00808 void SerDesXML::translate(void * &param, const char *tag)
00809 {
00810    bool rc = write_xml_elem(writer, tag,
00811          "%p", param);
00812 
00813    if (!rc) 
00814    {
00815       SER_ERR("testXmlwriterDoc: Error at my_xmlTextWriterStartElement");
00816    }
00817 
00818 #if 0
00819     int rc = my_xmlTextWriterWriteFormatElement(writer, XMLCHAR_CAST tag,
00820                                                  "%p", param);
00821     if (rc < 0) {
00822         SER_ERR("testXmlwriterDoc: Error at my_xmlTextWriterStartElement");
00823     }
00824 #endif
00825 }
00826 void SerDesXML::translate(const char * &param, int /*bufsize*/, const char *tag)
00827 {
00828    bool rc = write_xml_elem(writer, tag,
00829          "%s", param);
00830 
00831    if (!rc) 
00832    {
00833       SER_ERR("testXmlwriterDoc: Error at my_xmlTextWriterStartElement");
00834    }
00835 #if 0
00836     int rc = my_xmlTextWriterWriteFormatElement(writer, XMLCHAR_CAST tag,
00837                                                  "%s", param);
00838     if (rc < 0) {
00839         SER_ERR("testXmlwriterDoc: Error at my_xmlTextWriterStartElement");
00840     }
00841 #endif
00842 }
00843 
00844 void SerDesXML::translate(char * &param, int /*bufsize*/, const char *tag)
00845 {
00846    bool rc = write_xml_elem(writer, tag,
00847          "%s", param);
00848 
00849    if (!rc) 
00850    {
00851       SER_ERR("testXmlwriterDoc: Error at my_xmlTextWriterStartElement");
00852    }
00853 
00854 #if 0
00855     int rc = my_xmlTextWriterWriteFormatElement(writer, XMLCHAR_CAST tag,
00856                                                  "%s", param);
00857     if (rc < 0) {
00858         SER_ERR("testXmlwriterDoc: Error at my_xmlTextWriterStartElement");
00859     }
00860 #endif
00861 }
00862 
00863 void SerDesXML::translate(std::string &param, const char *tag)
00864 {
00865    assert(tag);
00866    assert(param.c_str());
00867 
00868    bool rc = write_xml_elem(writer, tag,
00869          "%s", param.c_str());
00870 
00871    if (!rc) 
00872    {
00873       SER_ERR("testXmlwriterDoc: Error at my_xmlTextWriterStartElement");
00874    }
00875 
00876 #if 0
00877     int rc = my_xmlTextWriterWriteFormatElement(writer, XMLCHAR_CAST tag,
00878                                                  "%s", param.c_str());
00879     if (rc < 0) {
00880         SER_ERR("testXmlwriterDoc: Error at my_xmlTextWriterStartElement");
00881     }
00882 #endif
00883 }
00884 
00885 #if 0
00886 void SerDesXML::translate(pdstring &param, const char *tag)
00887 {
00888     int rc = my_xmlTextWriterWriteFormatElement(writer, XMLCHAR_CAST tag,
00889                                                  "%s", param.c_str());
00890     if (rc < 0) {
00891         SER_ERR("testXmlwriterDoc: Error at my_xmlTextWriterStartElement");
00892     }
00893 }
00894 #endif
00895 
00896 void SerDesXML::translate(std::vector<std::string> &param, const char *tag,
00897                           const char *elem_tag)
00898 {
00899    bool rc = ::start_xml_elem(writer, tag);
00900    if (!rc)
00901    {
00902       SER_ERR("testXmlwriterDoc: Error at my_xmlTextWriterStartElement");
00903    }
00904 
00905 #if 0
00906     int rc = my_xmlTextWriterStartElement(writer, XMLCHAR_CAST tag) ;
00907     if (rc < 0) {
00908         SER_ERR("testXmlwriterDoc: Error at my_xmlTextWriterStartElement");
00909     }
00910 #endif
00911 
00912     for (unsigned int i = 0; i < param.size(); ++i) 
00913       translate(param[i], elem_tag);
00914     
00915 
00916    rc = ::end_xml_elem(writer);
00917    if (!rc)
00918    {
00919       SER_ERR("testXmlwriterDoc: Error at my_xmlTextWriterEndElement");
00920    }
00921 
00922 #if 0
00923     rc = my_xmlTextWriterEndElement(writer);
00924     if (rc < 0) {
00925         SER_ERR("testXmlwriterDoc: Error at my_xmlTextWriterStartElement");
00926     }
00927 #endif
00928 }
00929 
00930 #if 0
00931 void SerDesXML::start_element(const char *tag)
00932 {
00933    int rc = my_xmlTextWriterStartElement(writer, XMLCHAR_CAST tag) ;
00934    if (rc < 0) {
00935       SER_ERR("testXmlwriterDoc: Error at my_xmlTextWriterStartElement");
00936    }
00937 }
00938 
00939 void SerDesXML::end_element()
00940 {
00941    int rc = my_xmlTextWriterEndElement(writer);
00942    if (rc < 0) {
00943       SER_ERR("testXmlwriterDoc: Error at my_xmlTextWriterStartElement");
00944    }
00945 }
00946 
00947 void SerDesXML::xml_value(const char *s, const char *tag)
00948 {
00949     int rc = my_xmlTextWriterWriteFormatElement(writer, XMLCHAR_CAST tag,
00950                                                  "%s", s);
00951     if (rc < 0) {
00952         SER_ERR("testXmlwriterDoc: Error at my_xmlTextWriterStartElement");
00953     }
00954 }
00955 #endif
00956 
00957 #endif
 All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Defines

Generated on 12 Jul 2013 for SymtabAPI by  doxygen 1.6.1