Changeset 26:21e74a83b678 in rrlib_xml


Ignore:
Timestamp:
31.01.2011 10:33:06 (9 years ago)
Author:
Tobias Föhst <foehst@…>
Branch:
default
Phase:
public
Convert:
svn:3219ad6e-c0b7-4ac2-9554-e22e195eef7a/trunk@27
Message:

Reformatting to meet code templates

Files:
5 edited

Legend:

Unmodified
Added
Removed
  • tCleanupHandler.h

    r16 r26  
    3232 */ 
    3333//---------------------------------------------------------------------- 
    34 #ifndef _rrlib_xml2_wrapper_tCleanupHandler_h_ 
    35 #define _rrlib_xml2_wrapper_tCleanupHandler_h_ 
     34#ifndef __rrlib__xml2_wrapper__tCleanupHandler_h__ 
     35#define __rrlib__xml2_wrapper__tCleanupHandler_h__ 
    3636 
    3737//---------------------------------------------------------------------- 
     
    4343} 
    4444 
     45#include "rrlib/util/patterns/singleton.h" 
     46 
    4547//---------------------------------------------------------------------- 
    4648// Internal includes with "" 
    4749//---------------------------------------------------------------------- 
    48 #include "rrlib/util/patterns/singleton.h" 
    4950 
    5051//---------------------------------------------------------------------- 
     
    7576 
    7677//---------------------------------------------------------------------- 
    77 // Public methods 
     78// Public methods and typedefs 
    7879//---------------------------------------------------------------------- 
    7980public: 
     
    9293}; 
    9394 
    94 typedef rrlib::util::tSingletonHolder<tCleanupHandlerImplementation, rrlib::util::CreateStatic, rrlib::util::PhoenixSingleton> tCleanupHandler; 
     95typedef rrlib::util::tSingletonHolder<tCleanupHandlerImplementation, rrlib::util::singleton::CreateStatic, rrlib::util::singleton::PhoenixSingleton> tCleanupHandler; 
    9596 
    9697//---------------------------------------------------------------------- 
  • tXML2WrapperException.h

    r5 r26  
    3939 */ 
    4040//---------------------------------------------------------------------- 
    41 #ifndef _rrlib_xml2_wrapper_tXML2WrapperException_h_ 
    42 #define _rrlib_xml2_wrapper_tXML2WrapperException_h_ 
     41#ifndef __rrlib__xml2_wrapper__tXML2WrapperException_h__ 
     42#define __rrlib__xml2_wrapper__tXML2WrapperException_h__ 
    4343 
    4444//---------------------------------------------------------------------- 
  • tXMLDocument.h

    r24 r26  
    3838 */ 
    3939//---------------------------------------------------------------------- 
    40 #ifndef _rrlib_xml2_wrapper_tXMLDocument_h_ 
    41 #define _rrlib_xml2_wrapper_tXMLDocument_h_ 
     40#ifndef __rrlib__xml2_wrapper__tXMLDocument_h__ 
     41#define __rrlib__xml2_wrapper__tXMLDocument_h__ 
    4242 
    4343//---------------------------------------------------------------------- 
     
    8484class tXMLDocument 
    8585{ 
    86   xmlDocPtr document; 
    87   mutable tXMLNode *root_node; 
    8886 
    8987//---------------------------------------------------------------------- 
    90 // Public methods 
     88// Public methods and typedefs 
    9189//---------------------------------------------------------------------- 
    9290public: 
     
    125123   * \param validate    Whether the validation should be processed or not 
    126124   */ 
    127   explicit tXMLDocument(const void *buffer, size_t size, bool validate = true); 
     125  tXMLDocument(const void *buffer, size_t size, bool validate = true); 
    128126 
    129127  /*! The dtor of tXMLDocument 
     
    173171  void WriteToFile(const std::string &file_name, int compression = 0) const; 
    174172 
     173//---------------------------------------------------------------------- 
     174// Private fields and methods 
     175//---------------------------------------------------------------------- 
     176private: 
     177 
     178  xmlDocPtr document; 
     179  mutable tXMLNode *root_node; 
     180 
    175181}; 
    176182 
  • tXMLNode.h

    r25 r26  
    3838 */ 
    3939//---------------------------------------------------------------------- 
    40 #ifndef _rrlib_xml2_wrapper_tXMLNode_h_ 
    41 #define _rrlib_xml2_wrapper_tXMLNode_h_ 
     40#ifndef __rrlib__xml2_wrapper__tXMLNode_h__ 
     41#define __rrlib__xml2_wrapper__tXMLNode_h__ 
    4242 
    4343//---------------------------------------------------------------------- 
     
    9595  friend class tXMLDocument; 
    9696 
    97   template <typename TNumber> 
    98   static const TNumber ConvertStringToNumber(const std::string &value, TNumber(&convert_function)(const char *, char **, int), int base) 
    99   { 
    100     errno = 0; 
    101     char *endptr; 
    102     TNumber result = convert_function(value.c_str(), &endptr, base); 
    103     if (errno || *endptr) 
    104     { 
    105       printf("errno = %d\n*endptr = '%c'\n", errno, *endptr); 
    106       printf("ERANGE = %d\n", ERANGE); 
    107       throw tXML2WrapperException("Could not convert `" + value + "' to number!"); 
    108     } 
    109     return result; 
    110   } 
    111  
    112   template <typename TNumber> 
    113   static const TNumber ConvertStringToNumber(const std::string &value, TNumber(&convert_function)(const char *, char **)) 
    114   { 
    115     errno = 0; 
    116     char *endptr; 
    117     TNumber result = convert_function(value.c_str(), &endptr); 
    118     if (errno || *endptr) 
    119     { 
    120       printf("errno = %d\n*endptr = '%c'\n", errno, *endptr); 
    121       printf("ERANGE = %d\n", ERANGE); 
    122       throw tXML2WrapperException("Could not convert `" + value + "' to number!"); 
    123     } 
    124     return result; 
    125   } 
    126  
    127   void SetStringAttribute(const std::string &name, const std::string &value, bool create); 
    128  
    129 //---------------------------------------------------------------------- 
    130 // Public methods 
     97//---------------------------------------------------------------------- 
     98// Public methods and typedefs 
    13199//---------------------------------------------------------------------- 
    132100public: 
     
    817785  const std::string GetXMLDump(bool format = false) const; 
    818786 
     787//---------------------------------------------------------------------- 
     788// Private fields and methods 
     789//---------------------------------------------------------------------- 
     790private: 
     791 
     792  template <typename TNumber> 
     793  static const TNumber ConvertStringToNumber(const std::string &value, TNumber(&convert_function)(const char *, char **, int), int base) 
     794  { 
     795    errno = 0; 
     796    char *endptr; 
     797    TNumber result = convert_function(value.c_str(), &endptr, base); 
     798    if (errno || *endptr) 
     799    { 
     800      throw tXML2WrapperException("Could not convert `" + value + "' to number!"); 
     801    } 
     802    return result; 
     803  } 
     804 
     805  template <typename TNumber> 
     806  static const TNumber ConvertStringToNumber(const std::string &value, TNumber(&convert_function)(const char *, char **)) 
     807  { 
     808    errno = 0; 
     809    char *endptr; 
     810    TNumber result = convert_function(value.c_str(), &endptr); 
     811    if (errno || *endptr) 
     812    { 
     813      throw tXML2WrapperException("Could not convert `" + value + "' to number!"); 
     814    } 
     815    return result; 
     816  } 
     817 
     818  void SetStringAttribute(const std::string &name, const std::string &value, bool create); 
     819 
    819820}; 
    820821 
  • test/test_xml2_wrapper.cpp

    r21 r26  
    11// 
    2 // You received this file as part of MCA2 
    3 // Modular Controller Architecture Version 2 
     2// You received this file as part of RRLib 
     3// Robotics Research Library 
    44// 
    5 //Copyright (C) AG Robotersysteme TU Kaiserslautern 
     5// Copyright (C) AG Robotersysteme TU Kaiserslautern 
    66// 
    7 //This program is free software; you can redistribute it and/or 
    8 //modify it under the terms of the GNU General Public License 
    9 //as published by the Free Software Foundation; either version 2 
    10 //of the License, or (at your option) any later version. 
     7// This program is free software; you can redistribute it and/or 
     8// modify it under the terms of the GNU General Public License 
     9// as published by the Free Software Foundation; either version 2 
     10// of the License, or (at your option) any later version. 
    1111// 
    12 //This program is distributed in the hope that it will be useful, 
    13 //but WITHOUT ANY WARRANTY; without even the implied warranty of 
    14 //MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the 
    15 //GNU General Public License for more details. 
     12// This program is distributed in the hope that it will be useful, 
     13// but WITHOUT ANY WARRANTY; without even the implied warranty of 
     14// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the 
     15// GNU General Public License for more details. 
    1616// 
    17 //You should have received a copy of the GNU General Public License 
    18 //along with this program; if not, write to the Free Software 
    19 //Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA. 
     17// You should have received a copy of the GNU General Public License 
     18// along with this program; if not, write to the Free Software 
     19// Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA. 
    2020// 
    21 // this is for emacs file handling -*- mode: c++; indent-tabs-mode: nil -*- 
    2221//---------------------------------------------------------------------- 
    2322/*!\file    test_xml2_wrapper.cpp 
    2423 * 
    2524 * \author  Tobias Foehst 
     25 * 
    2626 * \date    2010-08-26 
    2727 * 
     
    3030 
    3131//---------------------------------------------------------------------- 
    32 // non MCA Includes - include with <> 
    33 // MCA Includes - include with "" 
     32// External includes (system with <>, local with "") 
    3433//---------------------------------------------------------------------- 
    3534#include <cstdlib> 
    3635#include <iostream> 
    3736 
     37//---------------------------------------------------------------------- 
     38// Internal includes with "" 
     39//---------------------------------------------------------------------- 
    3840#include "rrlib/xml2_wrapper/tXMLDocument.h" 
    39  
    40 using namespace rrlib::xml2; 
    41 //---------------------------------------------------------------------- 
    42 // typedefs and enums 
    43 //---------------------------------------------------------------------- 
    44  
    45 //---------------------------------------------------------------------- 
    46 // defines and consts 
    47 // global vars (prefer static class vars!) 
    48 //---------------------------------------------------------------------- 
    49  
    50 //---------------------------------------------------------------------- 
    51 // Forward class declarations 
    52 // Extern methods 
    53 //---------------------------------------------------------------------- 
    5441 
    5542//---------------------------------------------------------------------- 
     
    5744//---------------------------------------------------------------------- 
    5845#include <cassert> 
     46 
     47//---------------------------------------------------------------------- 
     48// Namespace usage 
     49//---------------------------------------------------------------------- 
     50using namespace rrlib::xml2; 
     51 
     52//---------------------------------------------------------------------- 
     53// Forward declarations / typedefs / enums 
     54//---------------------------------------------------------------------- 
     55 
     56//---------------------------------------------------------------------- 
     57// Const values 
     58//---------------------------------------------------------------------- 
    5959 
    6060//---------------------------------------------------------------------- 
Note: See TracChangeset for help on using the changeset viewer.