OBT Namespace Reference

Classes

class  OBT_Exception
 OBT exception class. More...
class  AbstractAttribute
 Base class for inspectable attributes. More...
class  AbstractConfigurationFileParser
 Abstract class for configuration file parsers. More...
class  ArgException
class  BasicPlugin
 Basic plugin. More...
class  ConfigurationItem
 Node of the configuration items tree. More...
class  ConfigurationTree
 Singleton class providing a unique access point to the configuration items tree. More...
class  Event
 Base class of all event objects. More...
class  EventSource
 Abstract base class of all event sources. More...
class  IService
 A root interface for services. More...
class  OldPlugin
 Plugin interface for old plugins. More...
class  OtherOptionArg
class  OptionArg
 This class handles an argument of a command line. More...
class  OptionLastArg
 The option to retrieve the last argument of a command line. More...
class  OptionFlag
 The option flag. More...
class  OptionNPrm
 The option flag with arguments. More...
class  OptionMultiNPrm
 The option flag with arguments. More...
class  ArgsOp
class  Imply
class  Exclusive
class  Inclusive
class  AtLeastOne
class  OptionArgHandler
 This class handles all the options to parse a command line. More...
class  Plugin
 This class permits to load / unload a plugin (a cross-platform dynamically linked library). More...
class  PluginInformation
 Information class about a plugin. More...
class  PluginInterface
 Plugin interface. More...
struct  PluginImpl
class  PluginLoaderImpl
 This class load / unload a plugin based on OBT::PluginInterface. More...
class  PrimitiveAttribute
 Template class for inspectable attributes giving access to primitive data types (short, int, float, etc. More...
class  BoolAttribute
class  ShortAttribute
class  UnsignedShortAttribute
class  IntAttribute
class  UnsignedIntAttribute
class  LongAttribute
class  UnsignedLongAttribute
class  FloatAttribute
class  DoubleAttribute
class  StringAttribute
class  PrototypeFactory
 Template factory prototype class. More...
class  RTTI
 Run Time Type Identifcation description class. More...
class  ServiceManager
 Plugins can add services to the ServiceManager, these services can later be used without knowing their implementation. More...
class  Singleton
 Singleton template class. More...
class  SmartPointer
 Smart pointer template class. More...
struct  TiXmlCursor
class  TiXmlVisitor
 If you call the Accept() method, it requires being passed a TiXmlVisitor class to handle callbacks. More...
class  TiXmlBase
 TiXmlBase is a base class for every class in TinyXml. More...
class  TiXmlNode
 The parent class for everything in the Document Object Model. More...
class  TiXmlAttribute
 An attribute is a name-value pair. More...
class  TiXmlAttributeSet
class  TiXmlElement
 The element is a container class. More...
class  TiXmlComment
 An XML comment. More...
class  TiXmlText
 XML text. More...
class  TiXmlDeclaration
 In correct XML the declaration is the first entry in the file. More...
class  TiXmlUnknown
 Any tag that tinyXml doesn't recognize is saved as an unknown. More...
class  TiXmlDocument
 Always the top level node. More...
class  TiXmlHandle
 A TiXmlHandle is a class that wraps a node pointer with null checks; this is an incredibly useful thing. More...
class  TiXmlPrinter
 Print to memory functionality. More...
class  TiXmlParsingData
class  TracerOutput
 Interface to output messages in a console. More...
class  Tracer
 Tracer used to output messages. More...
class  TypedAttribute
 Template class for inspectable attributes giving access to non primitive data types. More...
class  PointedObject
 Root class to manage guarded pointers. More...
class  GuardedPointer
 Non-typed version of the guarded pointer. More...
class  GuardedPointerT
 Guarded pointer. More...
class  XMLConfigurationFileParser
 Realization of the AbstractConfigurationFileParser class for the tinyXML library. More...
class  TiXmlString
class  TiXmlOutStream

Typedefs

typedef std::list< OptionArg * > ListArg
typedef std::list< ArgsOp * > ArgsOpList
typedef Singleton
< PluginLoaderImpl
PluginLoader
typedef unsigned long TypeID

Enumerations

enum  {
  TIXML_SUCCESS,
  TIXML_NO_ATTRIBUTE,
  TIXML_WRONG_TYPE
}
enum  TiXmlEncoding {
  TIXML_ENCODING_UNKNOWN,
  TIXML_ENCODING_UTF8,
  TIXML_ENCODING_LEGACY,
  TIXML_ENCODING_UNKNOWN,
  TIXML_ENCODING_UTF8,
  TIXML_ENCODING_LEGACY
}
enum  {
  TIXML_SUCCESS,
  TIXML_NO_ATTRIBUTE,
  TIXML_WRONG_TYPE
}
enum  TiXmlEncoding {
  TIXML_ENCODING_UNKNOWN,
  TIXML_ENCODING_UTF8,
  TIXML_ENCODING_LEGACY,
  TIXML_ENCODING_UNKNOWN,
  TIXML_ENCODING_UTF8,
  TIXML_ENCODING_LEGACY
}

Functions

template<class TAttribute >
TAttribute::value_type getAttributeValue (const typename TAttribute::owner_type &owner, unsigned int attributeNumber)
template<class TAttribute >
TAttribute::value_type getAttributeValue (const typename TAttribute::owner_type &owner, const char *name)
template<class TAttribute >
void setAttributeValue (typename TAttribute::owner_type &owner, unsigned int attributeNumber, typename TAttribute::value_type value)
template<class TAttribute >
void setAttributeValue (typename TAttribute::owner_type &owner, const char *name, typename TAttribute::value_type value)
OptionArgHandleroperator< (OptionArg &o1, OptionArg &o2)
OptionArgHandleroperator< (OptionArgHandler &h, OptionArg &o)
OptionArgHandleroperator^ (OptionArg &o1, OptionArg &o2)
OptionArgHandleroperator^ (OptionArgHandler &h, OptionArg &o)
OptionArgHandleroperator& (OptionArg &o1, OptionArg &o2)
OptionArgHandleroperator& (OptionArgHandler &h, OptionArg &o)
OptionArgHandleroperator| (OptionArg &o1, OptionArg &o2)
OptionArgHandleroperator| (OptionArgHandler &h, OptionArg &o)
template<class TService >
TService * getService (unsigned int ID)
template<class TService >
const std::map< unsigned int,
IService * > * 
getServices ()
template<class TService >
void addService (TService *service, unsigned int ID)
template<class TService >
void removeService (unsigned int ID)
template<class TTo , class TFrom >
SmartPointer< TTo > & ConstCast (const SmartPointer< TFrom > &from)
template<class TTo , class TFrom >
const SmartPointer< TTo > & StaticCast (const SmartPointer< TFrom > &from)
template<class TPointeeType , class U >
bool operator== (const SmartPointer< TPointeeType > &lhs, const U *rhs)
template<class U , class TPointeeType >
bool operator== (const U *lhs, const SmartPointer< TPointeeType > &rhs)
template<class TPointeeType , class U >
bool operator!= (const SmartPointer< TPointeeType > &lhs, const U *rhs)
template<class U , class TPointeeType >
bool operator!= (const U *lhs, const SmartPointer< TPointeeType > &rhs)
FILE * TiXmlFOpen (const char *filename, const char *mode)
TiXmlString operator+ (const TiXmlString &a, const TiXmlString &b)
TiXmlString operator+ (const TiXmlString &a, const char *b)
TiXmlString operator+ (const char *a, const TiXmlString &b)
bool operator== (const TiXmlString &a, const TiXmlString &b)
bool operator< (const TiXmlString &a, const TiXmlString &b)
bool operator!= (const TiXmlString &a, const TiXmlString &b)
bool operator> (const TiXmlString &a, const TiXmlString &b)
bool operator<= (const TiXmlString &a, const TiXmlString &b)
bool operator>= (const TiXmlString &a, const TiXmlString &b)
bool operator== (const TiXmlString &a, const char *b)
bool operator== (const char *a, const TiXmlString &b)
bool operator!= (const TiXmlString &a, const char *b)
bool operator!= (const char *a, const TiXmlString &b)
bool XmlTest (const char *testString, const char *expected, const char *found, bool noEcho=false)
bool XmlTest (const char *testString, int expected, int found, bool noEcho=false)
int main ()

Variables

template class OBT_API Singleton< ConfigurationTree >
template class OBT_API Singleton< ServiceManager >
const int TIXML_MAJOR_VERSION = 2
const int TIXML_MINOR_VERSION = 5
const int TIXML_PATCH_VERSION = 3
const TiXmlEncoding TIXML_DEFAULT_ENCODING = TIXML_ENCODING_UNKNOWN
const unsigned char TIXML_UTF_LEAD_0 = 0xefU
const unsigned char TIXML_UTF_LEAD_1 = 0xbbU
const unsigned char TIXML_UTF_LEAD_2 = 0xbfU
template class OBT_API Singleton< Tracer >
 The Tracer singleton.
static int gPass = 0
static int gFail = 0

Typedef Documentation

typedef std::list< ArgsOp* > OBT::ArgsOpList

Definition at line 17 of file OBTOptionArgHandler.h.

typedef std::list< OptionArg* > OBT::ListArg

Definition at line 15 of file OBTOptionArgHandler.h.

Definition at line 154 of file OBTPluginLoader.h.

typedef unsigned long OBT::TypeID

Definition at line 11 of file OBTRTTI.h.


Enumeration Type Documentation

anonymous enum
Enumerator:
TIXML_SUCCESS 
TIXML_NO_ATTRIBUTE 
TIXML_WRONG_TYPE 

Definition at line 163 of file OBTtinyxml.h.

00164 { 
00165         TIXML_SUCCESS,
00166         TIXML_NO_ATTRIBUTE,
00167         TIXML_WRONG_TYPE
00168 };

anonymous enum
Enumerator:
TIXML_SUCCESS 
TIXML_NO_ATTRIBUTE 
TIXML_WRONG_TYPE 

Definition at line 162 of file tiny/OBTtinyxml.h.

00163 { 
00164         TIXML_SUCCESS,
00165         TIXML_NO_ATTRIBUTE,
00166         TIXML_WRONG_TYPE
00167 };

Enumerator:
TIXML_ENCODING_UNKNOWN 
TIXML_ENCODING_UTF8 
TIXML_ENCODING_LEGACY 
TIXML_ENCODING_UNKNOWN 
TIXML_ENCODING_UTF8 
TIXML_ENCODING_LEGACY 

Definition at line 171 of file tiny/OBTtinyxml.h.

Enumerator:
TIXML_ENCODING_UNKNOWN 
TIXML_ENCODING_UTF8 
TIXML_ENCODING_LEGACY 
TIXML_ENCODING_UNKNOWN 
TIXML_ENCODING_UTF8 
TIXML_ENCODING_LEGACY 

Definition at line 172 of file OBTtinyxml.h.


Function Documentation

template<class TService >
void OBT::addService ( TService *  service,
unsigned int  ID = 0 
) [inline]
Parameters:
service to add.
Exceptions:
[DEBUG ONLY] if service is null

Definition at line 125 of file OBTServiceManager.h.

References OBT_DBG_ASSERT.

00126         {
00127                 OBT_DBG_ASSERT( service != NULL ) ;
00128                 ServiceManager::ServicesMap::mapped_type& serviceMap
00129                         ( Singleton< ServiceManager >::getInstance()._services[ typeid( TService ).name() ] ) ;
00130                 serviceMap[ ID ] = service ;
00131         }

template<class TTo , class TFrom >
SmartPointer< TTo >& OBT::ConstCast ( const SmartPointer< TFrom > &  from  )  [inline]

Definition at line 373 of file OBTSmartPointer.h.

00374         {
00375                 return const_cast<SmartPointer< TTo >&>( reinterpret_cast<const SmartPointer< TTo >&>( from ) ) ;
00376         }

template<class TAttribute >
TAttribute::value_type OBT::getAttributeValue ( const typename TAttribute::owner_type &  owner,
const char *  name 
) [inline]

Definition at line 113 of file OBTAbstractAttribute.h.

00114         {
00115                 return ( owner.getRTTI().template getAttribute< TAttribute >( name )->getValue( owner ) ) ;
00116         }

template<class TAttribute >
TAttribute::value_type OBT::getAttributeValue ( const typename TAttribute::owner_type &  owner,
unsigned int  attributeNumber 
) [inline]

Definition at line 103 of file OBTAbstractAttribute.h.

00104         {
00105                 return ( owner.getRTTI().template getAttribute< TAttribute >( attributeNumber )->getValue( owner ) ) ;
00106         }

template<class TService >
TService* OBT::getService ( unsigned int  ID = 0  )  [inline]
Parameters:
TService type of the service to get.
ID id of the service to get.
Returns:
the service if found, NULL otherwise.

Definition at line 85 of file OBTServiceManager.h.

References TRACE_WARNING.

00086         {
00087                 ServiceManager::ServicesMap& services( Singleton< ServiceManager >::getInstance()._services ) ;
00088                 ServiceManager::ServicesMap::iterator servicesIte( services.find( typeid( TService ).name() ) ) ;
00089                 if ( servicesIte != services.end() )
00090                 {
00091                         std::map< unsigned int, IService* >::iterator ite( servicesIte->second.find( ID ) ) ;
00092                         if ( ite != servicesIte->second.end() )
00093                         {
00094                                 return static_cast<TService*>( ite->second ) ;
00095                         }
00096                 }
00097                 TRACE_WARNING( "The following service was not found : " << typeid( TService ).name() << " with id " << ID ) ;
00098                 return NULL ;
00099         }

template<class TService >
const std::map< unsigned int, IService* >* OBT::getServices (  )  [inline]
Parameters:
TService type of the services to get.
Returns:
the service if found, NULL otherwise.

Definition at line 105 of file OBTServiceManager.h.

References TRACE_WARNING.

00106         {
00107                 const std::map< unsigned int, IService* >* servicesFound = 0 ;
00108                 ServiceManager::ServicesMap& services( Singleton< ServiceManager >::getInstance()._services ) ;
00109                 ServiceManager::ServicesMap::const_iterator servicesIte( services.find( typeid( TService ).name() ) ) ;
00110                 if ( servicesIte != services.end() )
00111                 {
00112                         servicesFound = &servicesIte->second ;
00113                 }
00114                 else
00115                 {
00116                         TRACE_WARNING( "The following services was not found : " << typeid( TService ).name() ) ;
00117                 }
00118                 return servicesFound ;
00119         }

int OBT::main (  ) 

Definition at line 77 of file OBTxmltest.cpp.

References OBT::TiXmlDocument::Accept(), OBT::TiXmlElement::Attribute(), OBT::TiXmlString::c_str(), OBT::TiXmlHandle::Child(), OBT::TiXmlHandle::ChildElement(), OBT::TiXmlNode::Clear(), OBT::TiXmlDocument::ClearError(), OBT::TiXmlBase::Column(), OBT::TiXmlPrinter::CStr(), OBT::TiXmlHandle::Element(), OBT::TiXmlDeclaration::Encoding(), OBT::TiXmlDocument::Error(), OBT::TiXmlDocument::ErrorCol(), OBT::TiXmlDocument::ErrorDesc(), OBT::TiXmlDocument::ErrorId(), OBT::TiXmlDocument::ErrorRow(), OBT::TiXmlElement::FirstAttribute(), OBT::TiXmlHandle::FirstChild(), OBT::TiXmlNode::FirstChild(), OBT::TiXmlHandle::FirstChildElement(), OBT::TiXmlNode::FirstChildElement(), OBT::TiXmlElement::GetText(), gFail, gPass, OBT::TiXmlNode::InsertAfterChild(), OBT::TiXmlNode::InsertBeforeChild(), OBT::TiXmlNode::InsertEndChild(), OBT::TiXmlNode::LastChild(), OBT::TiXmlDocument::LoadFile(), OBT::TiXmlNode::NextSibling(), OBT::TiXmlNode::NextSiblingElement(), OBT::TiXmlHandle::Node(), OBT::TiXmlUnknown::Parse(), OBT::TiXmlComment::Parse(), OBT::TiXmlElement::Parse(), OBT::TiXmlDocument::Parse(), OBT::TiXmlNode::PreviousSibling(), OBT::TiXmlElement::Print(), OBT::TiXmlDocument::Print(), OBT::TiXmlElement::QueryDoubleAttribute(), OBT::TiXmlElement::QueryIntAttribute(), OBT::TiXmlNode::RemoveChild(), OBT::TiXmlDocument::RootElement(), OBT::TiXmlBase::Row(), OBT::TiXmlDocument::SaveFile(), OBT::TiXmlElement::SetAttribute(), OBT::TiXmlBase::SetCondenseWhiteSpace(), OBT::TiXmlPrinter::SetStreamPrinting(), OBT::TiXmlDocument::SetTabSize(), OBT::TiXmlHandle::Text(), TIXML_ENCODING_LEGACY, TIXML_ENCODING_UNKNOWN, OBT::TiXmlBase::TIXML_ERROR_DOCUMENT_EMPTY, OBT::TiXmlBase::TIXML_ERROR_DOCUMENT_TOP_ONLY, OBT::TiXmlBase::TIXML_ERROR_OPENING_FILE, TIXML_NO_ATTRIBUTE, TIXML_STRING, TIXML_SUCCESS, TIXML_WRONG_TYPE, OBT::TiXmlNode::ToComment(), OBT::TiXmlNode::ToDeclaration(), OBT::TiXmlNode::ToElement(), OBT::TiXmlNode::ToText(), OBT::TiXmlHandle::Unknown(), OBT::TiXmlNode::Value(), and XmlTest().

00078 {
00079         //
00080         // We start with the 'demoStart' todo list. Process it. And
00081         // should hopefully end up with the todo list as illustrated.
00082         //
00083         const char* demoStart =
00084                 "<?xml version=\"1.0\"  standalone='no' >\n"
00085                 "<!-- Our to do list data -->"
00086                 "<ToDo>\n"
00087                 "<!-- Do I need a secure PDA? -->\n"
00088                 "<Item priority=\"1\" distance='close'> Go to the <bold>Toy store!</bold></Item>"
00089                 "<Item priority=\"2\" distance='none'> Do bills   </Item>"
00090                 "<Item priority=\"2\" distance='far &amp; back'> Look for Evil Dinosaurs! </Item>"
00091                 "</ToDo>";
00092                 
00093         {
00094 
00095         #ifdef TIXML_USE_STL
00096                 /*      What the todo list should look like after processing.
00097                         In stream (no formatting) representation. */
00098                 const char* demoEnd =
00099                         "<?xml version=\"1.0\" standalone=\"no\" ?>"
00100                         "<!-- Our to do list data -->"
00101                         "<ToDo>"
00102                         "<!-- Do I need a secure PDA? -->"
00103                         "<Item priority=\"2\" distance=\"close\">Go to the"
00104                         "<bold>Toy store!"
00105                         "</bold>"
00106                         "</Item>"
00107                         "<Item priority=\"1\" distance=\"far\">Talk to:"
00108                         "<Meeting where=\"School\">"
00109                         "<Attendee name=\"Marple\" position=\"teacher\" />"
00110                         "<Attendee name=\"Voel\" position=\"counselor\" />"
00111                         "</Meeting>"
00112                         "<Meeting where=\"Lunch\" />"
00113                         "</Item>"
00114                         "<Item priority=\"2\" distance=\"here\">Do bills"
00115                         "</Item>"
00116                         "</ToDo>";
00117         #endif
00118 
00119                 // The example parses from the character string (above):
00120                 #if defined( WIN32 ) && defined( TUNE )
00121                 _CrtMemCheckpoint( &startMemState );
00122                 #endif  
00123 
00124                 {
00125                         // Write to a file and read it back, to check file I/O.
00126 
00127                         TiXmlDocument doc( "demotest.xml" );
00128                         doc.Parse( demoStart );
00129 
00130                         if ( doc.Error() )
00131                         {
00132                                 printf( "Error in %s: %s\n", doc.Value(), doc.ErrorDesc() );
00133                                 exit( 1 );
00134                         }
00135                         doc.SaveFile();
00136                 }
00137 
00138                 TiXmlDocument doc( "demotest.xml" );
00139                 bool loadOkay = doc.LoadFile();
00140 
00141                 if ( !loadOkay )
00142                 {
00143                         printf( "Could not load test file 'demotest.xml'. Error='%s'. Exiting.\n", doc.ErrorDesc() );
00144                         exit( 1 );
00145                 }
00146 
00147                 printf( "** Demo doc read from disk: ** \n\n" );
00148                 printf( "** Printing via doc.Print **\n" );
00149                 doc.Print( stdout );
00150 
00151                 {
00152                         printf( "** Printing via TiXmlPrinter **\n" );
00153                         TiXmlPrinter printer;
00154                         doc.Accept( &printer );
00155                         fprintf( stdout, "%s", printer.CStr() );
00156                 }
00157                 #ifdef TIXML_USE_STL    
00158                 {
00159                         printf( "** Printing via operator<< **\n" );
00160                         std::cout << doc;
00161                 }
00162                 #endif
00163                 TiXmlNode* node = 0;
00164                 TiXmlElement* todoElement = 0;
00165                 TiXmlElement* itemElement = 0;
00166 
00167 
00168                 // --------------------------------------------------------
00169                 // An example of changing existing attributes, and removing
00170                 // an element from the document.
00171                 // --------------------------------------------------------
00172 
00173                 // Get the "ToDo" element.
00174                 // It is a child of the document, and can be selected by name.
00175                 node = doc.FirstChild( "ToDo" );
00176                 assert( node );
00177                 todoElement = node->ToElement();
00178                 assert( todoElement  );
00179 
00180                 // Going to the toy store is now our second priority...
00181                 // So set the "priority" attribute of the first item in the list.
00182                 node = todoElement->FirstChildElement();        // This skips the "PDA" comment.
00183                 assert( node );
00184                 itemElement = node->ToElement();
00185                 assert( itemElement  );
00186                 itemElement->SetAttribute( "priority", 2 );
00187 
00188                 // Change the distance to "doing bills" from
00189                 // "none" to "here". It's the next sibling element.
00190                 itemElement = itemElement->NextSiblingElement();
00191                 assert( itemElement );
00192                 itemElement->SetAttribute( "distance", "here" );
00193 
00194                 // Remove the "Look for Evil Dinosaurs!" item.
00195                 // It is 1 more sibling away. We ask the parent to remove
00196                 // a particular child.
00197                 itemElement = itemElement->NextSiblingElement();
00198                 todoElement->RemoveChild( itemElement );
00199 
00200                 itemElement = 0;
00201 
00202                 // --------------------------------------------------------
00203                 // What follows is an example of created elements and text
00204                 // nodes and adding them to the document.
00205                 // --------------------------------------------------------
00206 
00207                 // Add some meetings.
00208                 TiXmlElement item( "Item" );
00209                 item.SetAttribute( "priority", "1" );
00210                 item.SetAttribute( "distance", "far" );
00211 
00212                 TiXmlText text( "Talk to:" );
00213 
00214                 TiXmlElement meeting1( "Meeting" );
00215                 meeting1.SetAttribute( "where", "School" );
00216 
00217                 TiXmlElement meeting2( "Meeting" );
00218                 meeting2.SetAttribute( "where", "Lunch" );
00219 
00220                 TiXmlElement attendee1( "Attendee" );
00221                 attendee1.SetAttribute( "name", "Marple" );
00222                 attendee1.SetAttribute( "position", "teacher" );
00223 
00224                 TiXmlElement attendee2( "Attendee" );
00225                 attendee2.SetAttribute( "name", "Voel" );
00226                 attendee2.SetAttribute( "position", "counselor" );
00227 
00228                 // Assemble the nodes we've created:
00229                 meeting1.InsertEndChild( attendee1 );
00230                 meeting1.InsertEndChild( attendee2 );
00231 
00232                 item.InsertEndChild( text );
00233                 item.InsertEndChild( meeting1 );
00234                 item.InsertEndChild( meeting2 );
00235 
00236                 // And add the node to the existing list after the first child.
00237                 node = todoElement->FirstChild( "Item" );
00238                 assert( node );
00239                 itemElement = node->ToElement();
00240                 assert( itemElement );
00241 
00242                 todoElement->InsertAfterChild( itemElement, item );
00243 
00244                 printf( "\n** Demo doc processed: ** \n\n" );
00245                 doc.Print( stdout );
00246 
00247 
00248         #ifdef TIXML_USE_STL
00249                 printf( "** Demo doc processed to stream: ** \n\n" );
00250                 cout << doc << endl << endl;
00251         #endif
00252 
00253                 // --------------------------------------------------------
00254                 // Different tests...do we have what we expect?
00255                 // --------------------------------------------------------
00256 
00257                 int count = 0;
00258                 TiXmlElement*   element;
00259 
00261 
00262         #ifdef TIXML_USE_STL
00263                 cout << "** Basic structure. **\n";
00264                 ostringstream outputStream( ostringstream::out );
00265                 outputStream << doc;
00266                 XmlTest( "Output stream correct.",      string( demoEnd ).c_str(),
00267                                                                                         outputStream.str().c_str(), true );
00268         #endif
00269 
00270                 node = doc.RootElement();
00271                 assert( node );
00272                 XmlTest( "Root element exists.", true, ( node != 0 && node->ToElement() ) );
00273                 XmlTest ( "Root element value is 'ToDo'.", "ToDo",  node->Value());
00274 
00275                 node = node->FirstChild();
00276                 XmlTest( "First child exists & is a comment.", true, ( node != 0 && node->ToComment() ) );
00277                 node = node->NextSibling();
00278                 XmlTest( "Sibling element exists & is an element.", true, ( node != 0 && node->ToElement() ) );
00279                 XmlTest ( "Value is 'Item'.", "Item", node->Value() );
00280 
00281                 node = node->FirstChild();
00282                 XmlTest ( "First child exists.", true, ( node != 0 && node->ToText() ) );
00283                 XmlTest ( "Value is 'Go to the'.", "Go to the", node->Value() );
00284 
00285 
00287                 printf ("\n** Iterators. **\n");
00288 
00289                 // Walk all the top level nodes of the document.
00290                 count = 0;
00291                 for( node = doc.FirstChild();
00292                          node;
00293                          node = node->NextSibling() )
00294                 {
00295                         count++;
00296                 }
00297                 XmlTest( "Top level nodes, using First / Next.", 3, count );
00298 
00299                 count = 0;
00300                 for( node = doc.LastChild();
00301                          node;
00302                          node = node->PreviousSibling() )
00303                 {
00304                         count++;
00305                 }
00306                 XmlTest( "Top level nodes, using Last / Previous.", 3, count );
00307 
00308                 // Walk all the top level nodes of the document,
00309                 // using a different syntax.
00310                 count = 0;
00311                 for( node = doc.IterateChildren( 0 );
00312                          node;
00313                          node = doc.IterateChildren( node ) )
00314                 {
00315                         count++;
00316                 }
00317                 XmlTest( "Top level nodes, using IterateChildren.", 3, count );
00318 
00319                 // Walk all the elements in a node.
00320                 count = 0;
00321                 for( element = todoElement->FirstChildElement();
00322                          element;
00323                          element = element->NextSiblingElement() )
00324                 {
00325                         count++;
00326                 }
00327                 XmlTest( "Children of the 'ToDo' element, using First / Next.",
00328                         3, count );
00329 
00330                 // Walk all the elements in a node by value.
00331                 count = 0;
00332                 for( node = todoElement->FirstChild( "Item" );
00333                          node;
00334                          node = node->NextSibling( "Item" ) )
00335                 {
00336                         count++;
00337                 }
00338                 XmlTest( "'Item' children of the 'ToDo' element, using First/Next.", 3, count );
00339 
00340                 count = 0;
00341                 for( node = todoElement->LastChild( "Item" );
00342                          node;
00343                          node = node->PreviousSibling( "Item" ) )
00344                 {
00345                         count++;
00346                 }
00347                 XmlTest( "'Item' children of the 'ToDo' element, using Last/Previous.", 3, count );
00348 
00349         #ifdef TIXML_USE_STL
00350                 {
00351                         cout << "\n** Parsing. **\n";
00352                         istringstream parse0( "<Element0 attribute0='foo0' attribute1= noquotes attribute2 = '&gt;' />" );
00353                         TiXmlElement element0( "default" );
00354                         parse0 >> element0;
00355 
00356                         XmlTest ( "Element parsed, value is 'Element0'.", "Element0", element0.Value() );
00357                         XmlTest ( "Reads attribute 'attribute0=\"foo0\"'.", "foo0", element0.Attribute( "attribute0" ));
00358                         XmlTest ( "Reads incorrectly formatted 'attribute1=noquotes'.", "noquotes", element0.Attribute( "attribute1" ) );
00359                         XmlTest ( "Read attribute with entity value '>'.", ">", element0.Attribute( "attribute2" ) );
00360                 }
00361         #endif
00362 
00363                 {
00364                         const char* error =     "<?xml version=\"1.0\" standalone=\"no\" ?>\n"
00365                                                                 "<passages count=\"006\" formatversion=\"20020620\">\n"
00366                                                                 "    <wrong error>\n"
00367                                                                 "</passages>";
00368 
00369                         TiXmlDocument docTest;
00370                         docTest.Parse( error );
00371                         XmlTest( "Error row", docTest.ErrorRow(), 3 );
00372                         XmlTest( "Error column", docTest.ErrorCol(), 17 );
00373                         //printf( "error=%d id='%s' row %d col%d\n", (int) doc.Error(), doc.ErrorDesc(), doc.ErrorRow()+1, doc.ErrorCol() + 1 );
00374 
00375                 }
00376 
00377         #ifdef TIXML_USE_STL
00378                 {
00380                         cout << "\n** Streaming. **\n";
00381 
00382                         // Round trip check: stream in, then stream back out to verify. The stream
00383                         // out has already been checked, above. We use the output
00384 
00385                         istringstream inputStringStream( outputStream.str() );
00386                         TiXmlDocument document0;
00387 
00388                         inputStringStream >> document0;
00389 
00390                         ostringstream outputStream0( ostringstream::out );
00391                         outputStream0 << document0;
00392 
00393                         XmlTest( "Stream round trip correct.",  string( demoEnd ).c_str(), 
00394                                                                                                         outputStream0.str().c_str(), true );
00395 
00396                         std::string str;
00397                         str << document0;
00398 
00399                         XmlTest( "String printing correct.", string( demoEnd ).c_str(), 
00400                                                                                                  str.c_str(), true );
00401                 }
00402         #endif
00403         }
00404         
00405         {
00406                 const char* str = "<doc attr0='1' attr1='2.0' attr2='foo' />";
00407 
00408                 TiXmlDocument doc;
00409                 doc.Parse( str );
00410 
00411                 TiXmlElement* ele = doc.FirstChildElement();
00412 
00413                 int iVal, result;
00414                 double dVal;
00415 
00416                 result = ele->QueryDoubleAttribute( "attr0", &dVal );
00417                 XmlTest( "Query attribute: int as double", result, TIXML_SUCCESS );
00418                 XmlTest( "Query attribute: int as double", (int)dVal, 1 );
00419                 result = ele->QueryDoubleAttribute( "attr1", &dVal );
00420                 XmlTest( "Query attribute: double as double", (int)dVal, 2 );
00421                 result = ele->QueryIntAttribute( "attr1", &iVal );
00422                 XmlTest( "Query attribute: double as int", result, TIXML_SUCCESS );
00423                 XmlTest( "Query attribute: double as int", iVal, 2 );
00424                 result = ele->QueryIntAttribute( "attr2", &iVal );
00425                 XmlTest( "Query attribute: not a number", result, TIXML_WRONG_TYPE );
00426                 result = ele->QueryIntAttribute( "bar", &iVal );
00427                 XmlTest( "Query attribute: does not exist", result, TIXML_NO_ATTRIBUTE );
00428         }
00429         
00430         {
00431                 const char* str =       "\t<?xml version=\"1.0\" standalone=\"no\" ?>\t<room doors='2'>\n"
00432                                                         "</room>";
00433 
00434                 TiXmlDocument doc;
00435                 doc.SetTabSize( 8 );
00436                 doc.Parse( str );
00437 
00438                 TiXmlHandle docHandle( &doc );
00439                 TiXmlHandle roomHandle = docHandle.FirstChildElement( "room" );
00440 
00441                 assert( docHandle.Node() );
00442                 assert( roomHandle.Element() );
00443 
00444                 TiXmlElement* room = roomHandle.Element();
00445                 assert( room );
00446                 TiXmlAttribute* doors = room->FirstAttribute();
00447                 assert( doors );
00448 
00449                 XmlTest( "Location tracking: Tab 8: room row", room->Row(), 1 );
00450                 XmlTest( "Location tracking: Tab 8: room col", room->Column(), 49 );
00451                 XmlTest( "Location tracking: Tab 8: doors row", doors->Row(), 1 );
00452                 XmlTest( "Location tracking: Tab 8: doors col", doors->Column(), 55 );
00453         }
00454         
00455         {
00456                 const char* str =       "\t<?xml version=\"1.0\" standalone=\"no\" ?>\t<room doors='2'>\n"
00457                                                         "  <!-- Silly example -->\n"
00458                                                         "    <door wall='north'>A great door!</door>\n"
00459                                                         "\t<door wall='east'/>"
00460                                                         "</room>";
00461 
00462                 TiXmlDocument doc;
00463                 doc.Parse( str );
00464 
00465                 TiXmlHandle docHandle( &doc );
00466                 TiXmlHandle roomHandle = docHandle.FirstChildElement( "room" );
00467                 TiXmlHandle commentHandle = docHandle.FirstChildElement( "room" ).FirstChild();
00468                 TiXmlHandle textHandle = docHandle.FirstChildElement( "room" ).ChildElement( "door", 0 ).FirstChild();
00469                 TiXmlHandle door0Handle = docHandle.FirstChildElement( "room" ).ChildElement( 0 );
00470                 TiXmlHandle door1Handle = docHandle.FirstChildElement( "room" ).ChildElement( 1 );
00471 
00472                 assert( docHandle.Node() );
00473                 assert( roomHandle.Element() );
00474                 assert( commentHandle.Node() );
00475                 assert( textHandle.Text() );
00476                 assert( door0Handle.Element() );
00477                 assert( door1Handle.Element() );
00478 
00479                 TiXmlDeclaration* declaration = doc.FirstChild()->ToDeclaration();
00480                 assert( declaration );
00481                 TiXmlElement* room = roomHandle.Element();
00482                 assert( room );
00483                 TiXmlAttribute* doors = room->FirstAttribute();
00484                 assert( doors );
00485                 TiXmlText* text = textHandle.Text();
00486                 TiXmlComment* comment = commentHandle.Node()->ToComment();
00487                 assert( comment );
00488                 TiXmlElement* door0 = door0Handle.Element();
00489                 TiXmlElement* door1 = door1Handle.Element();
00490 
00491                 XmlTest( "Location tracking: Declaration row", declaration->Row(), 1 );
00492                 XmlTest( "Location tracking: Declaration col", declaration->Column(), 5 );
00493                 XmlTest( "Location tracking: room row", room->Row(), 1 );
00494                 XmlTest( "Location tracking: room col", room->Column(), 45 );
00495                 XmlTest( "Location tracking: doors row", doors->Row(), 1 );
00496                 XmlTest( "Location tracking: doors col", doors->Column(), 51 );
00497                 XmlTest( "Location tracking: Comment row", comment->Row(), 2 );
00498                 XmlTest( "Location tracking: Comment col", comment->Column(), 3 );
00499                 XmlTest( "Location tracking: text row", text->Row(), 3 ); 
00500                 XmlTest( "Location tracking: text col", text->Column(), 24 );
00501                 XmlTest( "Location tracking: door0 row", door0->Row(), 3 );
00502                 XmlTest( "Location tracking: door0 col", door0->Column(), 5 );
00503                 XmlTest( "Location tracking: door1 row", door1->Row(), 4 );
00504                 XmlTest( "Location tracking: door1 col", door1->Column(), 5 );
00505         }
00506 
00507 
00508         // --------------------------------------------------------
00509         // UTF-8 testing. It is important to test:
00510         //      1. Making sure name, value, and text read correctly
00511         //      2. Row, Col functionality
00512         //      3. Correct output
00513         // --------------------------------------------------------
00514         printf ("\n** UTF-8 **\n");
00515         {
00516                 TiXmlDocument doc( "utf8test.xml" );
00517                 doc.LoadFile();
00518                 if ( doc.Error() && doc.ErrorId() == TiXmlBase::TIXML_ERROR_OPENING_FILE ) {
00519                         printf( "WARNING: File 'utf8test.xml' not found.\n"
00520                                         "(Are you running the test from the wrong directory?)\n"
00521                                     "Could not test UTF-8 functionality.\n" );
00522                 }
00523                 else
00524                 {
00525                         TiXmlHandle docH( &doc );
00526                         // Get the attribute "value" from the "Russian" element and check it.
00527                         TiXmlElement* element = docH.FirstChildElement( "document" ).FirstChildElement( "Russian" ).Element();
00528                         const unsigned char correctValue[] = {  0xd1U, 0x86U, 0xd0U, 0xb5U, 0xd0U, 0xbdU, 0xd0U, 0xbdU, 
00529                                                                                                         0xd0U, 0xbeU, 0xd1U, 0x81U, 0xd1U, 0x82U, 0xd1U, 0x8cU, 0 };
00530 
00531                         XmlTest( "UTF-8: Russian value.", (const char*)correctValue, element->Attribute( "value" ), true );
00532                         XmlTest( "UTF-8: Russian value row.", 4, element->Row() );
00533                         XmlTest( "UTF-8: Russian value column.", 5, element->Column() );
00534 
00535                         const unsigned char russianElementName[] = {    0xd0U, 0xa0U, 0xd1U, 0x83U,
00536                                                                                                                         0xd1U, 0x81U, 0xd1U, 0x81U,
00537                                                                                                                         0xd0U, 0xbaU, 0xd0U, 0xb8U,
00538                                                                                                                         0xd0U, 0xb9U, 0 };
00539                         const char russianText[] = "<\xD0\xB8\xD0\xBC\xD0\xB5\xD0\xB5\xD1\x82>";
00540 
00541                         TiXmlText* text = docH.FirstChildElement( "document" ).FirstChildElement( (const char*) russianElementName ).Child( 0 ).Text();
00542                         XmlTest( "UTF-8: Browsing russian element name.",
00543                                          russianText,
00544                                          text->Value(),
00545                                          true );
00546                         XmlTest( "UTF-8: Russian element name row.", 7, text->Row() );
00547                         XmlTest( "UTF-8: Russian element name column.", 47, text->Column() );
00548 
00549                         TiXmlDeclaration* dec = docH.Child( 0 ).Node()->ToDeclaration();
00550                         XmlTest( "UTF-8: Declaration column.", 1, dec->Column() );
00551                         XmlTest( "UTF-8: Document column.", 1, doc.Column() );
00552 
00553                         // Now try for a round trip.
00554                         doc.SaveFile( "utf8testout.xml" );
00555 
00556                         // Check the round trip.
00557                         char savedBuf[256];
00558                         char verifyBuf[256];
00559                         int okay = 1;
00560 
00561                         FILE* saved  = fopen( "utf8testout.xml", "r" );
00562                         FILE* verify = fopen( "utf8testverify.xml", "r" );
00563                         if ( saved && verify )
00564                         {
00565                                 while ( fgets( verifyBuf, 256, verify ) )
00566                                 {
00567                                         fgets( savedBuf, 256, saved );
00568                                         if ( strcmp( verifyBuf, savedBuf ) )
00569                                         {
00570                                                 okay = 0;
00571                                                 break;
00572                                         }
00573                                 }
00574                                 fclose( saved );
00575                                 fclose( verify );
00576                         }
00577                         XmlTest( "UTF-8: Verified multi-language round trip.", 1, okay );
00578 
00579                         // On most Western machines, this is an element that contains
00580                         // the word "resume" with the correct accents, in a latin encoding.
00581                         // It will be something else completely on non-wester machines,
00582                         // which is why TinyXml is switching to UTF-8.
00583                         const char latin[] = "<element>r\x82sum\x82</element>";
00584 
00585                         TiXmlDocument latinDoc;
00586                         latinDoc.Parse( latin, 0, TIXML_ENCODING_LEGACY );
00587 
00588                         text = latinDoc.FirstChildElement()->FirstChild()->ToText();
00589                         XmlTest( "Legacy encoding: Verify text element.", "r\x82sum\x82", text->Value() );
00590                 }
00591         }               
00592 
00594         // Copy and assignment
00596         printf ("\n** Copy and Assignment **\n");
00597         {
00598                 TiXmlElement element( "foo" );
00599                 element.Parse( "<element name='value' />", 0, TIXML_ENCODING_UNKNOWN );
00600 
00601                 TiXmlElement elementCopy( element );
00602                 TiXmlElement elementAssign( "foo" );
00603                 elementAssign.Parse( "<incorrect foo='bar'/>", 0, TIXML_ENCODING_UNKNOWN );
00604                 elementAssign = element;
00605 
00606                 XmlTest( "Copy/Assign: element copy #1.", "element", elementCopy.Value() );
00607                 XmlTest( "Copy/Assign: element copy #2.", "value", elementCopy.Attribute( "name" ) );
00608                 XmlTest( "Copy/Assign: element assign #1.", "element", elementAssign.Value() );
00609                 XmlTest( "Copy/Assign: element assign #2.", "value", elementAssign.Attribute( "name" ) );
00610                 XmlTest( "Copy/Assign: element assign #3.", true, ( 0 == elementAssign.Attribute( "foo" )) );
00611 
00612                 TiXmlComment comment;
00613                 comment.Parse( "<!--comment-->", 0, TIXML_ENCODING_UNKNOWN );
00614                 TiXmlComment commentCopy( comment );
00615                 TiXmlComment commentAssign;
00616                 commentAssign = commentCopy;
00617                 XmlTest( "Copy/Assign: comment copy.", "comment", commentCopy.Value() );
00618                 XmlTest( "Copy/Assign: comment assign.", "comment", commentAssign.Value() );
00619 
00620                 TiXmlUnknown unknown;
00621                 unknown.Parse( "<[unknown]>", 0, TIXML_ENCODING_UNKNOWN );
00622                 TiXmlUnknown unknownCopy( unknown );
00623                 TiXmlUnknown unknownAssign;
00624                 unknownAssign.Parse( "incorrect", 0, TIXML_ENCODING_UNKNOWN );
00625                 unknownAssign = unknownCopy;
00626                 XmlTest( "Copy/Assign: unknown copy.", "[unknown]", unknownCopy.Value() );
00627                 XmlTest( "Copy/Assign: unknown assign.", "[unknown]", unknownAssign.Value() );
00628                 
00629                 TiXmlText text( "TextNode" );
00630                 TiXmlText textCopy( text );
00631                 TiXmlText textAssign( "incorrect" );
00632                 textAssign = text;
00633                 XmlTest( "Copy/Assign: text copy.", "TextNode", textCopy.Value() );
00634                 XmlTest( "Copy/Assign: text assign.", "TextNode", textAssign.Value() );
00635 
00636                 TiXmlDeclaration dec;
00637                 dec.Parse( "<?xml version='1.0' encoding='UTF-8'?>", 0, TIXML_ENCODING_UNKNOWN );
00638                 TiXmlDeclaration decCopy( dec );
00639                 TiXmlDeclaration decAssign;
00640                 decAssign = dec;
00641 
00642                 XmlTest( "Copy/Assign: declaration copy.", "UTF-8", decCopy.Encoding() );
00643                 XmlTest( "Copy/Assign: text assign.", "UTF-8", decAssign.Encoding() );
00644 
00645                 TiXmlDocument doc;
00646                 elementCopy.InsertEndChild( textCopy );
00647                 doc.InsertEndChild( decAssign );
00648                 doc.InsertEndChild( elementCopy );
00649                 doc.InsertEndChild( unknownAssign );
00650 
00651                 TiXmlDocument docCopy( doc );
00652                 TiXmlDocument docAssign;
00653                 docAssign = docCopy;
00654 
00655                 #ifdef TIXML_USE_STL
00656                 std::string original, copy, assign;
00657                 original << doc;
00658                 copy << docCopy;
00659                 assign << docAssign;
00660                 XmlTest( "Copy/Assign: document copy.", original.c_str(), copy.c_str(), true );
00661                 XmlTest( "Copy/Assign: document assign.", original.c_str(), assign.c_str(), true );
00662 
00663                 #endif
00664         }       
00665 
00667 #ifdef TIXML_USE_STL
00668         printf ("\n** Parsing, no Condense Whitespace **\n");
00669         TiXmlBase::SetCondenseWhiteSpace( false );
00670         {
00671                 istringstream parse1( "<start>This  is    \ntext</start>" );
00672                 TiXmlElement text1( "text" );
00673                 parse1 >> text1;
00674 
00675                 XmlTest ( "Condense white space OFF.", "This  is    \ntext",
00676                                         text1.FirstChild()->Value(),
00677                                         true );
00678         }
00679         TiXmlBase::SetCondenseWhiteSpace( true );
00680 #endif
00681 
00683         // GetText();
00684         {
00685                 const char* str = "<foo>This is text</foo>";
00686                 TiXmlDocument doc;
00687                 doc.Parse( str );
00688                 const TiXmlElement* element = doc.RootElement();
00689 
00690                 XmlTest( "GetText() normal use.", "This is text", element->GetText() );
00691 
00692                 str = "<foo><b>This is text</b></foo>";
00693                 doc.Clear();
00694                 doc.Parse( str );
00695                 element = doc.RootElement();
00696 
00697                 XmlTest( "GetText() contained element.", element->GetText() == 0, true );
00698 
00699                 str = "<foo>This is <b>text</b></foo>";
00700                 doc.Clear();
00701                 TiXmlBase::SetCondenseWhiteSpace( false );
00702                 doc.Parse( str );
00703                 TiXmlBase::SetCondenseWhiteSpace( true );
00704                 element = doc.RootElement();
00705 
00706                 XmlTest( "GetText() partial.", "This is ", element->GetText() );
00707         }
00708 
00709 
00711         // CDATA
00712         {
00713                 const char* str =       "<xmlElement>"
00714                                                                 "<![CDATA["
00715                                                                         "I am > the rules!\n"
00716                                                                         "...since I make symbolic puns"
00717                                                                 "]]>"
00718                                                         "</xmlElement>";
00719                 TiXmlDocument doc;
00720                 doc.Parse( str );
00721                 doc.Print();
00722 
00723                 XmlTest( "CDATA parse.", doc.FirstChildElement()->FirstChild()->Value(), 
00724                                                                  "I am > the rules!\n...since I make symbolic puns",
00725                                                                  true );
00726 
00727                 #ifdef TIXML_USE_STL
00728                 //cout << doc << '\n';
00729 
00730                 doc.Clear();
00731 
00732                 istringstream parse0( str );
00733                 parse0 >> doc;
00734                 //cout << doc << '\n';
00735 
00736                 XmlTest( "CDATA stream.", doc.FirstChildElement()->FirstChild()->Value(), 
00737                                                                  "I am > the rules!\n...since I make symbolic puns",
00738                                                                  true );
00739                 #endif
00740 
00741                 TiXmlDocument doc1 = doc;
00742                 //doc.Print();
00743 
00744                 XmlTest( "CDATA copy.", doc1.FirstChildElement()->FirstChild()->Value(), 
00745                                                                  "I am > the rules!\n...since I make symbolic puns",
00746                                                                  true );
00747         }
00748         {
00749                 // [ 1482728 ] Wrong wide char parsing
00750                 char buf[256];
00751                 buf[255] = 0;
00752                 for( int i=0; i<255; ++i ) {
00753                         buf[i] = (char)((i>=32) ? i : 32);
00754                 }
00755                 TIXML_STRING str( "<xmlElement><![CDATA[" );
00756                 str += buf;
00757                 str += "]]></xmlElement>";
00758 
00759                 TiXmlDocument doc;
00760                 doc.Parse( str.c_str() );
00761 
00762                 TiXmlPrinter printer;
00763                 printer.SetStreamPrinting();
00764                 doc.Accept( &printer );
00765 
00766                 XmlTest( "CDATA with all bytes #1.", str.c_str(), printer.CStr(), true );
00767 
00768                 #ifdef TIXML_USE_STL
00769                 doc.Clear();
00770                 istringstream iss( printer.Str() );
00771                 iss >> doc;
00772                 std::string out;
00773                 out << doc;
00774                 XmlTest( "CDATA with all bytes #2.", out.c_str(), printer.CStr(), true );
00775                 #endif
00776         }
00777         {
00778                 // [ 1480107 ] Bug-fix for STL-streaming of CDATA that contains tags
00779                 // CDATA streaming had a couple of bugs, that this tests for.
00780                 const char* str =       "<xmlElement>"
00781                                                                 "<![CDATA["
00782                                                                         "<b>I am > the rules!</b>\n"
00783                                                                         "...since I make symbolic puns"
00784                                                                 "]]>"
00785                                                         "</xmlElement>";
00786                 TiXmlDocument doc;
00787                 doc.Parse( str );
00788                 doc.Print();
00789 
00790                 XmlTest( "CDATA parse. [ 1480107 ]", doc.FirstChildElement()->FirstChild()->Value(), 
00791                                                                  "<b>I am > the rules!</b>\n...since I make symbolic puns",
00792                                                                  true );
00793 
00794                 #ifdef TIXML_USE_STL
00795 
00796                 doc.Clear();
00797 
00798                 istringstream parse0( str );
00799                 parse0 >> doc;
00800 
00801                 XmlTest( "CDATA stream. [ 1480107 ]", doc.FirstChildElement()->FirstChild()->Value(), 
00802                                                                  "<b>I am > the rules!</b>\n...since I make symbolic puns",
00803                                                                  true );
00804                 #endif
00805 
00806                 TiXmlDocument doc1 = doc;
00807                 //doc.Print();
00808 
00809                 XmlTest( "CDATA copy. [ 1480107 ]", doc1.FirstChildElement()->FirstChild()->Value(), 
00810                                                                  "<b>I am > the rules!</b>\n...since I make symbolic puns",
00811                                                                  true );
00812         }
00814         // Visit()
00815 
00816 
00817 
00819         printf( "\n** Fuzzing... **\n" );
00820 
00821         const int FUZZ_ITERATION = 300;
00822 
00823         // The only goal is not to crash on bad input.
00824         int len = (int) strlen( demoStart );
00825         for( int i=0; i<FUZZ_ITERATION; ++i ) 
00826         {
00827                 char* demoCopy = new char[ len+1 ];
00828                 strcpy( demoCopy, demoStart );
00829 
00830                 demoCopy[ i%len ] = (char)((i+1)*3);
00831                 demoCopy[ (i*7)%len ] = '>';
00832                 demoCopy[ (i*11)%len ] = '<';
00833 
00834                 TiXmlDocument xml;
00835                 xml.Parse( demoCopy );
00836 
00837                 delete [] demoCopy;
00838         }
00839         printf( "** Fuzzing Complete. **\n" );
00840         
00842         printf ("\n** Bug regression tests **\n");
00843 
00844         // InsertBeforeChild and InsertAfterChild causes crash.
00845         {
00846                 TiXmlElement parent( "Parent" );
00847                 TiXmlElement childText0( "childText0" );
00848                 TiXmlElement childText1( "childText1" );
00849                 TiXmlNode* childNode0 = parent.InsertEndChild( childText0 );
00850                 TiXmlNode* childNode1 = parent.InsertBeforeChild( childNode0, childText1 );
00851 
00852                 XmlTest( "Test InsertBeforeChild on empty node.", ( childNode1 == parent.FirstChild() ), true );
00853         }
00854 
00855         {
00856                 // InsertBeforeChild and InsertAfterChild causes crash.
00857                 TiXmlElement parent( "Parent" );
00858                 TiXmlElement childText0( "childText0" );
00859                 TiXmlElement childText1( "childText1" );
00860                 TiXmlNode* childNode0 = parent.InsertEndChild( childText0 );
00861                 TiXmlNode* childNode1 = parent.InsertAfterChild( childNode0, childText1 );
00862 
00863                 XmlTest( "Test InsertAfterChild on empty node. ", ( childNode1 == parent.LastChild() ), true );
00864         }
00865 
00866         // Reports of missing constructors, irregular string problems.
00867         {
00868                 // Missing constructor implementation. No test -- just compiles.
00869                 TiXmlText text( "Missing" );
00870 
00871                 #ifdef TIXML_USE_STL
00872                         // Missing implementation:
00873                         TiXmlDocument doc;
00874                         string name = "missing";
00875                         doc.LoadFile( name );
00876 
00877                         TiXmlText textSTL( name );
00878                 #else
00879                         // verifying some basic string functions:
00880                         TiXmlString a;
00881                         TiXmlString b( "Hello" );
00882                         TiXmlString c( "ooga" );
00883 
00884                         c = " World!";
00885                         a = b;
00886                         a += c;
00887                         a = a;
00888 
00889                         XmlTest( "Basic TiXmlString test. ", "Hello World!", a.c_str() );
00890                 #endif
00891         }
00892 
00893         // Long filenames crashing STL version
00894         {
00895                 TiXmlDocument doc( "midsummerNightsDreamWithAVeryLongFilenameToConfuseTheStringHandlingRoutines.xml" );
00896                 bool loadOkay = doc.LoadFile();
00897                 loadOkay = true;        // get rid of compiler warning.
00898                 // Won't pass on non-dev systems. Just a "no crash" check.
00899                 //XmlTest( "Long filename. ", true, loadOkay );
00900         }
00901 
00902         {
00903                 // Entities not being written correctly.
00904                 // From Lynn Allen
00905 
00906                 const char* passages =
00907                         "<?xml version=\"1.0\" standalone=\"no\" ?>"
00908                         "<passages count=\"006\" formatversion=\"20020620\">"
00909                                 "<psg context=\"Line 5 has &quot;quotation marks&quot; and &apos;apostrophe marks&apos;."
00910                                 " It also has &lt;, &gt;, and &amp;, as well as a fake copyright &#xA9;.\"> </psg>"
00911                         "</passages>";
00912 
00913                 TiXmlDocument doc( "passages.xml" );
00914                 doc.Parse( passages );
00915                 TiXmlElement* psg = doc.RootElement()->FirstChildElement();
00916                 const char* context = psg->Attribute( "context" );
00917                 const char* expected = "Line 5 has \"quotation marks\" and 'apostrophe marks'. It also has <, >, and &, as well as a fake copyright \xC2\xA9.";
00918 
00919                 XmlTest( "Entity transformation: read. ", expected, context, true );
00920 
00921                 FILE* textfile = fopen( "textfile.txt", "w" );
00922                 if ( textfile )
00923                 {
00924                         psg->Print( textfile, 0 );
00925                         fclose( textfile );
00926                 }
00927                 textfile = fopen( "textfile.txt", "r" );
00928                 assert( textfile );
00929                 if ( textfile )
00930                 {
00931                         char buf[ 1024 ];
00932                         fgets( buf, 1024, textfile );
00933                         XmlTest( "Entity transformation: write. ",
00934                                          "<psg context=\'Line 5 has &quot;quotation marks&quot; and &apos;apostrophe marks&apos;."
00935                                          " It also has &lt;, &gt;, and &amp;, as well as a fake copyright \xC2\xA9.' />",
00936                                          buf,
00937                                          true );
00938                 }
00939                 fclose( textfile );
00940         }
00941 
00942     {
00943                 FILE* textfile = fopen( "test5.xml", "w" );
00944                 if ( textfile )
00945                 {
00946             fputs("<?xml version='1.0'?><a.elem xmi.version='2.0'/>", textfile);
00947             fclose(textfile);
00948 
00949                         TiXmlDocument doc;
00950             doc.LoadFile( "test5.xml" );
00951             XmlTest( "dot in element attributes and names", doc.Error(), 0);
00952                 }
00953     }
00954 
00955         {
00956                 FILE* textfile = fopen( "test6.xml", "w" );
00957                 if ( textfile )
00958                 {
00959             fputs("<element><Name>1.1 Start easy ignore fin thickness&#xA;</Name></element>", textfile );
00960             fclose(textfile);
00961 
00962             TiXmlDocument doc;
00963             bool result = doc.LoadFile( "test6.xml" );
00964             XmlTest( "Entity with one digit.", result, true );
00965 
00966                         TiXmlText* text = doc.FirstChildElement()->FirstChildElement()->FirstChild()->ToText();
00967                         XmlTest( "Entity with one digit.",
00968                                                 text->Value(), "1.1 Start easy ignore fin thickness\n" );
00969                 }
00970     }
00971 
00972         {
00973                 // DOCTYPE not preserved (950171)
00974                 // 
00975                 const char* doctype =
00976                         "<?xml version=\"1.0\" ?>"
00977                         "<!DOCTYPE PLAY SYSTEM 'play.dtd'>"
00978                         "<!ELEMENT title (#PCDATA)>"
00979                         "<!ELEMENT books (title,authors)>"
00980                         "<element />";
00981 
00982                 TiXmlDocument doc;
00983                 doc.Parse( doctype );
00984                 doc.SaveFile( "test7.xml" );
00985                 doc.Clear();
00986                 doc.LoadFile( "test7.xml" );
00987                 
00988                 TiXmlHandle docH( &doc );
00989                 TiXmlUnknown* unknown = docH.Child( 1 ).Unknown();
00990                 XmlTest( "Correct value of unknown.", "!DOCTYPE PLAY SYSTEM 'play.dtd'", unknown->Value() );
00991                 #ifdef TIXML_USE_STL
00992                 TiXmlNode* node = docH.Child( 2 ).Node();
00993                 std::string str;
00994                 str << (*node);
00995                 XmlTest( "Correct streaming of unknown.", "<!ELEMENT title (#PCDATA)>", str.c_str() );
00996                 #endif
00997         }
00998 
00999         {
01000                 // [ 791411 ] Formatting bug
01001                 // Comments do not stream out correctly.
01002                 const char* doctype = 
01003                         "<!-- Somewhat<evil> -->";
01004                 TiXmlDocument doc;
01005                 doc.Parse( doctype );
01006 
01007                 TiXmlHandle docH( &doc );
01008                 TiXmlComment* comment = docH.Child( 0 ).Node()->ToComment();
01009 
01010                 XmlTest( "Comment formatting.", " Somewhat<evil> ", comment->Value() );
01011                 #ifdef TIXML_USE_STL
01012                 std::string str;
01013                 str << (*comment);
01014                 XmlTest( "Comment streaming.", "<!-- Somewhat<evil> -->", str.c_str() );
01015                 #endif
01016         }
01017 
01018         {
01019                 // [ 870502 ] White space issues
01020                 TiXmlDocument doc;
01021                 TiXmlText* text;
01022                 TiXmlHandle docH( &doc );
01023         
01024                 const char* doctype0 = "<element> This has leading and trailing space </element>";
01025                 const char* doctype1 = "<element>This has  internal space</element>";
01026                 const char* doctype2 = "<element> This has leading, trailing, and  internal space </element>";
01027 
01028                 TiXmlBase::SetCondenseWhiteSpace( false );
01029                 doc.Clear();
01030                 doc.Parse( doctype0 );
01031                 text = docH.FirstChildElement( "element" ).Child( 0 ).Text();
01032                 XmlTest( "White space kept.", " This has leading and trailing space ", text->Value() );
01033 
01034                 doc.Clear();
01035                 doc.Parse( doctype1 );
01036                 text = docH.FirstChildElement( "element" ).Child( 0 ).Text();
01037                 XmlTest( "White space kept.", "This has  internal space", text->Value() );
01038 
01039                 doc.Clear();
01040                 doc.Parse( doctype2 );
01041                 text = docH.FirstChildElement( "element" ).Child( 0 ).Text();
01042                 XmlTest( "White space kept.", " This has leading, trailing, and  internal space ", text->Value() );
01043 
01044                 TiXmlBase::SetCondenseWhiteSpace( true );
01045                 doc.Clear();
01046                 doc.Parse( doctype0 );
01047                 text = docH.FirstChildElement( "element" ).Child( 0 ).Text();
01048                 XmlTest( "White space condensed.", "This has leading and trailing space", text->Value() );
01049 
01050                 doc.Clear();
01051                 doc.Parse( doctype1 );
01052                 text = docH.FirstChildElement( "element" ).Child( 0 ).Text();
01053                 XmlTest( "White space condensed.", "This has internal space", text->Value() );
01054 
01055                 doc.Clear();
01056                 doc.Parse( doctype2 );
01057                 text = docH.FirstChildElement( "element" ).Child( 0 ).Text();
01058                 XmlTest( "White space condensed.", "This has leading, trailing, and internal space", text->Value() );
01059         }
01060 
01061         {
01062                 // Double attributes
01063                 const char* doctype = "<element attr='red' attr='blue' />";
01064 
01065                 TiXmlDocument doc;
01066                 doc.Parse( doctype );
01067                 
01068                 XmlTest( "Parsing repeated attributes.", 0, (int)doc.Error() ); // not an  error to tinyxml
01069                 XmlTest( "Parsing repeated attributes.", "blue", doc.FirstChildElement( "element" )->Attribute( "attr" ) );
01070         }
01071 
01072         {
01073                 // Embedded null in stream.
01074                 const char* doctype = "<element att\0r='red' attr='blue' />";
01075 
01076                 TiXmlDocument doc;
01077                 doc.Parse( doctype );
01078                 XmlTest( "Embedded null throws error.", true, doc.Error() );
01079 
01080                 #ifdef TIXML_USE_STL
01081                 istringstream strm( doctype );
01082                 doc.Clear();
01083                 doc.ClearError();
01084                 strm >> doc;
01085                 XmlTest( "Embedded null throws error.", true, doc.Error() );
01086                 #endif
01087         }
01088 
01089     {
01090             // Legacy mode test. (This test may only pass on a western system)
01091             const char* str =
01092                         "<?xml version=\"1.0\" encoding=\"ISO-8859-1\"?>"
01093                         "<ä>"
01094                         "CöntäntßäöüÄÖÜ"
01095                         "</ä>";
01096 
01097             TiXmlDocument doc;
01098             doc.Parse( str );
01099 
01100             TiXmlHandle docHandle( &doc );
01101             TiXmlHandle aHandle = docHandle.FirstChildElement( "ä" );
01102             TiXmlHandle tHandle = aHandle.Child( 0 );
01103             assert( aHandle.Element() );
01104             assert( tHandle.Text() );
01105             XmlTest( "ISO-8859-1 Parsing.", "CöntäntßäöüÄÖÜ", tHandle.Text()->Value() );
01106     }
01107 
01108         {
01109                 // Empty documents should return TIXML_ERROR_PARSING_EMPTY, bug 1070717
01110                 const char* str = "    ";
01111                 TiXmlDocument doc;
01112                 doc.Parse( str );
01113                 XmlTest( "Empty document error TIXML_ERROR_DOCUMENT_EMPTY", TiXmlBase::TIXML_ERROR_DOCUMENT_EMPTY, doc.ErrorId() );
01114         }
01115         #ifndef TIXML_USE_STL
01116         {
01117                 // String equality. [ 1006409 ] string operator==/!= no worky in all cases
01118                 TiXmlString temp;
01119                 XmlTest( "Empty tinyxml string compare equal", ( temp == "" ), true );
01120 
01121                 TiXmlString    foo;
01122                 TiXmlString    bar( "" );
01123                 XmlTest( "Empty tinyxml string compare equal", ( foo == bar ), true );
01124         }
01125 
01126         #endif
01127         {
01128                 // Bug [ 1195696 ] from marlonism
01129                 TiXmlBase::SetCondenseWhiteSpace(false); 
01130                 TiXmlDocument xml; 
01131                 xml.Parse("<text><break/>This hangs</text>"); 
01132                 XmlTest( "Test safe error return.", xml.Error(), false );
01133         }
01134 
01135         {
01136                 // Bug [ 1243992 ] - another infinite loop
01137                 TiXmlDocument doc;
01138                 doc.SetCondenseWhiteSpace(false);
01139                 doc.Parse("<p><pb></pb>test</p>");
01140         } 
01141         {
01142                 // Low entities
01143                 TiXmlDocument xml;
01144                 xml.Parse( "<test>&#x0e;</test>" );
01145                 const char result[] = { 0x0e, 0 };
01146                 XmlTest( "Low entities.", xml.FirstChildElement()->GetText(), result );
01147                 xml.Print();
01148         }
01149         {
01150                 // Bug [ 1451649 ] Attribute values with trailing quotes not handled correctly
01151                 TiXmlDocument xml;
01152                 xml.Parse( "<foo attribute=bar\" />" );
01153                 XmlTest( "Throw error with bad end quotes.", xml.Error(), true );
01154         }
01155         #ifdef TIXML_USE_STL
01156         {
01157                 // Bug [ 1449463 ] Consider generic query
01158                 TiXmlDocument xml;
01159                 xml.Parse( "<foo bar='3' barStr='a string'/>" );
01160 
01161                 TiXmlElement* ele = xml.FirstChildElement();
01162                 double d;
01163                 int i;
01164                 float f;
01165                 bool b;
01166                 //std::string str;
01167 
01168                 XmlTest( "QueryValueAttribute", ele->QueryValueAttribute( "bar", &d ), TIXML_SUCCESS );
01169                 XmlTest( "QueryValueAttribute", ele->QueryValueAttribute( "bar", &i ), TIXML_SUCCESS );
01170                 XmlTest( "QueryValueAttribute", ele->QueryValueAttribute( "bar", &f ), TIXML_SUCCESS );
01171                 XmlTest( "QueryValueAttribute", ele->QueryValueAttribute( "bar", &b ), TIXML_WRONG_TYPE );
01172                 XmlTest( "QueryValueAttribute", ele->QueryValueAttribute( "nobar", &b ), TIXML_NO_ATTRIBUTE );
01173                 //XmlTest( "QueryValueAttribute", ele->QueryValueAttribute( "barStr", &str ), TIXML_SUCCESS );
01174 
01175                 XmlTest( "QueryValueAttribute", (d==3.0), true );
01176                 XmlTest( "QueryValueAttribute", (i==3), true );
01177                 XmlTest( "QueryValueAttribute", (f==3.0f), true );
01178                 //XmlTest( "QueryValueAttribute", (str==std::string( "a string" )), true );
01179         }
01180         #endif
01181 
01182         #ifdef TIXML_USE_STL
01183         {
01184                 // [ 1505267 ] redundant malloc in TiXmlElement::Attribute
01185                 TiXmlDocument xml;
01186                 xml.Parse( "<foo bar='3' />" );
01187                 TiXmlElement* ele = xml.FirstChildElement();
01188                 double d;
01189                 int i;
01190 
01191                 std::string bar = "bar";
01192 
01193                 const std::string* atrrib = ele->Attribute( bar );
01194                 ele->Attribute( bar, &d );
01195                 ele->Attribute( bar, &i );
01196 
01197                 XmlTest( "Attribute", atrrib->empty(), false );
01198                 XmlTest( "Attribute", (d==3.0), true );
01199                 XmlTest( "Attribute", (i==3), true );
01200         }
01201         #endif
01202 
01203         {
01204                 // [ 1356059 ] Allow TiXMLDocument to only be at the top level
01205                 TiXmlDocument xml, xml2;
01206                 xml.InsertEndChild( xml2 );
01207                 XmlTest( "Document only at top level.", xml.Error(), true );
01208                 XmlTest( "Document only at top level.", xml.ErrorId(), TiXmlBase::TIXML_ERROR_DOCUMENT_TOP_ONLY );
01209         }
01210 
01211         {
01212                 // [ 1663758 ] Failure to report error on bad XML
01213                 TiXmlDocument xml;
01214                 xml.Parse("<x>");
01215                 XmlTest("Missing end tag at end of input", xml.Error(), true);
01216                 xml.Parse("<x> ");
01217                 XmlTest("Missing end tag with trailing whitespace", xml.Error(), true);
01218         } 
01219 
01220         {
01221                 // [ 1635701 ] fail to parse files with a tag separated into two lines
01222                 // I'm not sure this is a bug. Marked 'pending' for feedback.
01223                 TiXmlDocument xml;
01224                 xml.Parse( "<title><p>text</p\n><title>" );
01225                 //xml.Print();
01226                 //XmlTest( "Tag split by newline", xml.Error(), false );
01227         }
01228 
01229         #ifdef TIXML_USE_STL
01230         {
01231                 // [ 1475201 ] TinyXML parses entities in comments
01232                 TiXmlDocument xml;
01233                 istringstream parse1( "<!-- declarations for <head> & <body> -->"
01234                                                       "<!-- far &amp; away -->" );
01235                 parse1 >> xml;
01236 
01237                 TiXmlNode* e0 = xml.FirstChild();
01238                 TiXmlNode* e1 = e0->NextSibling();
01239                 TiXmlComment* c0 = e0->ToComment();
01240                 TiXmlComment* c1 = e1->ToComment();
01241 
01242                 XmlTest( "Comments ignore entities.", " declarations for <head> & <body> ", c0->Value(), true );
01243                 XmlTest( "Comments ignore entities.", " far &amp; away ", c1->Value(), true );
01244         }
01245         #endif
01246 
01247         {
01248                 // [ 1475201 ] TinyXML parses entities in comments
01249                 TiXmlDocument xml;
01250                 xml.Parse("<!-- declarations for <head> & <body> -->"
01251                                   "<!-- far &amp; away -->" );
01252 
01253                 TiXmlNode* e0 = xml.FirstChild();
01254                 TiXmlNode* e1 = e0->NextSibling();
01255                 TiXmlComment* c0 = e0->ToComment();
01256                 TiXmlComment* c1 = e1->ToComment();
01257 
01258                 XmlTest( "Comments ignore entities.", " declarations for <head> & <body> ", c0->Value(), true );
01259                 XmlTest( "Comments ignore entities.", " far &amp; away ", c1->Value(), true );
01260         }
01261         /*
01262         {
01263                 TiXmlDocument xml;
01264                 xml.Parse( "<tag>/</tag>" );
01265                 xml.Print();
01266                 xml.FirstChild()->Print( stdout, 0 );
01267                 xml.FirstChild()->Type();
01268         }
01269         */
01270         
01271         /*  1417717 experiment
01272         {
01273                 TiXmlDocument xml;
01274                 xml.Parse("<text>Dan & Tracie</text>");
01275                 xml.Print(stdout);
01276         }
01277         {
01278                 TiXmlDocument xml;
01279                 xml.Parse("<text>Dan &foo; Tracie</text>");
01280                 xml.Print(stdout);
01281         }
01282         */
01283         #if defined( WIN32 ) && defined( TUNE )
01284         _CrtMemCheckpoint( &endMemState );
01285         //_CrtMemDumpStatistics( &endMemState );
01286 
01287         _CrtMemState diffMemState;
01288         _CrtMemDifference( &diffMemState, &startMemState, &endMemState );
01289         _CrtMemDumpStatistics( &diffMemState );
01290         #endif
01291 
01292         printf ("\nPass %d, Fail %d\n", gPass, gFail);
01293         return gFail;
01294 }

bool OBT::operator!= ( const char *  a,
const TiXmlString &  b 
) [inline]

Definition at line 288 of file OBTtinystr.h.

00288 { return !(b == a); }

bool OBT::operator!= ( const TiXmlString &  a,
const char *  b 
) [inline]

Definition at line 287 of file OBTtinystr.h.

00287 { return !(a == b); }

bool OBT::operator!= ( const TiXmlString &  a,
const TiXmlString &  b 
) [inline]

Definition at line 280 of file OBTtinystr.h.

00280 { return !(a == b); }

template<class U , class TPointeeType >
bool OBT::operator!= ( const U *  lhs,
const SmartPointer< TPointeeType > &  rhs 
) [inline]

Definition at line 452 of file OBTSmartPointer.h.

References OBT::SmartPointer< TPointeeType >::_pointee.

00453         {
00454                 return lhs != rhs._pointee ;
00455         }

template<class TPointeeType , class U >
bool OBT::operator!= ( const SmartPointer< TPointeeType > &  lhs,
const U *  rhs 
) [inline]

Definition at line 443 of file OBTSmartPointer.h.

References OBT::SmartPointer< TPointeeType >::_pointee.

00444         {
00445                 return lhs._pointee != rhs ;
00446         }

OBT_API OptionArgHandler & OBT::operator& ( OptionArgHandler &  h,
OptionArg &  o 
)
OBT_API OptionArgHandler & OBT::operator& ( OptionArg &  o1,
OptionArg &  o2 
)

In the command

 -socket xxx -ip xxx

To retrieve such command arguments

 OptionNPrm socketOpt( "-socket", "the socket number", "<socket>", 1 ) ;
 OptionNPrm ipOpt( "-ip", "the ip adress", "<ip adress>", 1 ) ;
 // the rule: Both options must be present or not
 socketOpt & ipOpt ;

To get the parameters

 if( socketOpt.isPresent() )
 {
   assert( ipOpt.isPresent() ) ;
   DefineCommunication( ipOpt.getPrm(), socketOpt.getPrm() ) ;
   ...
 }
TiXmlString OBT::operator+ ( const char *  a,
const TiXmlString &  b 
)
TiXmlString OBT::operator+ ( const TiXmlString &  a,
const char *  b 
)
TiXmlString OBT::operator+ ( const TiXmlString &  a,
const TiXmlString &  b 
)
bool OBT::operator< ( const TiXmlString &  a,
const TiXmlString &  b 
) [inline]

Definition at line 275 of file OBTtinystr.h.

References OBT::TiXmlString::c_str().

00276 {
00277         return strcmp(a.c_str(), b.c_str()) < 0;
00278 }

OBT_API OptionArgHandler & OBT::operator< ( OptionArgHandler &  h,
OptionArg &  o 
)
OBT_API OptionArgHandler & OBT::operator< ( OptionArg &  o1,
OptionArg &  o2 
)

In the command line

 -trace -traceFile out.log

To retrieve such command arguments

 OptionFlag traceOpt( "-trace", "this option activate the trace mode" ) ;
 OptionNPrm traceFileOpt( "-traceFile", "the trace file",
                          "<outup file>", 1 ) ;
 // the rule: if -traceFile is in the command line, -trace must be also defined
 traceOpt < traceFileOpt ;

To get the parameters

 if( traceOpt.isPresent() )
 { // -trace is in the command line
   activateTraces( true ) ;
   if( traceFileOpt.isPresent() )
   { // -traceFile is in the command line
     // Get the file name
     std::string fileName( traceFileOpt.getPrm() ) ;
     // Create the file
     ...
   }
 }
bool OBT::operator<= ( const TiXmlString &  a,
const TiXmlString &  b 
) [inline]

Definition at line 282 of file OBTtinystr.h.

00282 { return !(b < a); }

bool OBT::operator== ( const char *  a,
const TiXmlString &  b 
) [inline]

Definition at line 286 of file OBTtinystr.h.

00286 { return b == a; }

bool OBT::operator== ( const TiXmlString &  a,
const char *  b 
) [inline]

Definition at line 285 of file OBTtinystr.h.

References OBT::TiXmlString::c_str().

00285 { return strcmp(a.c_str(), b) == 0; }

bool OBT::operator== ( const TiXmlString &  a,
const TiXmlString &  b 
) [inline]

Definition at line 270 of file OBTtinystr.h.

References OBT::TiXmlString::c_str(), and OBT::TiXmlString::length().

00271 {
00272         return    ( a.length() == b.length() )                          // optimization on some platforms
00273                && ( strcmp(a.c_str(), b.c_str()) == 0 );        // actual compare
00274 }

template<class U , class TPointeeType >
bool OBT::operator== ( const U *  lhs,
const SmartPointer< TPointeeType > &  rhs 
) [inline]

Definition at line 423 of file OBTSmartPointer.h.

References OBT::SmartPointer< TPointeeType >::_pointee.

00424         {
00425                 return lhs == rhs._pointee ;
00426         }

template<class TPointeeType , class U >
bool OBT::operator== ( const SmartPointer< TPointeeType > &  lhs,
const U *  rhs 
) [inline]

Definition at line 413 of file OBTSmartPointer.h.

References OBT::SmartPointer< TPointeeType >::_pointee.

00414         {
00415                 return lhs._pointee == rhs ;
00416         }

bool OBT::operator> ( const TiXmlString &  a,
const TiXmlString &  b 
) [inline]

Definition at line 281 of file OBTtinystr.h.

00281 { return b < a; }

bool OBT::operator>= ( const TiXmlString &  a,
const TiXmlString &  b 
) [inline]

Definition at line 283 of file OBTtinystr.h.

00283 { return !(a < b); }

OBT_API OptionArgHandler & OBT::operator^ ( OptionArgHandler &  h,
OptionArg &  o 
)
OBT_API OptionArgHandler & OBT::operator^ ( OptionArg &  o1,
OptionArg &  o2 
)

In the command line these argument will fail

 -trace -optimized

To retrieve such command arguments

 OptionFlag traceOpt( "-trace", "this option activate the trace mode" ) ;
 OptionFlag optimizedOpt( "-optimized", "this option activate the optimized mode" ) ;
 // the rule: if -trace is in the command line, -optimized cannot be defined, and the opposite
 traceOpt ^ optimizedOpt ;

To get the parameters

 activateTraces( traceOpt.isPresent() ) ;
 activateOptimization( optimizedOpt.isPresent() ) ;
OBT_API OptionArgHandler & OBT::operator| ( OptionArgHandler &  h,
OptionArg &  o 
)
OBT_API OptionArgHandler & OBT::operator| ( OptionArg &  o1,
OptionArg &  o2 
)

In the command

 -socket xxx -o fileName

To retrieve such command arguments

 OptionNPrm socketOpt( "-socket", "the socket number", "<socket>", 1 ) ;
 OptionNPrm outputOpt( "-o", "the output file", "<outup file>", 1 ) ;
 // the rule: At least one of the options must be present
 socketOpt | outputOpt ;

To get the parameters

 if( socketOpt.isPresent() ) defineSocket( socketOpt.getPrm() ) ;
 if( outputOpt.isPresent() )
 {
   openOutputFile( outputOpt.getPrm() ) ;
   ...
 }
template<class TService >
void OBT::removeService ( unsigned int  ID = 0  )  [inline]
Exceptions:
[DEBUG ONLY] if service is null

Definition at line 137 of file OBTServiceManager.h.

References OBT::Singleton< T >::getInstance().

00138         {
00139                 ServiceManager::ServicesMap::iterator servicesIte
00140                         ( Singleton< ServiceManager >::getInstance()._services.find( typeid( TService ).name() ) ) ;
00141                 if ( servicesIte != Singleton< ServiceManager >::getInstance()._services.end() )
00142                 {
00143                         std::map< unsigned int, IService* >::iterator ite( servicesIte->second.find( ID ) ) ;
00144                         if ( ite != servicesIte->second.end() )
00145                         {
00146                                 servicesIte->second.erase( ite ) ;
00147                                 if ( servicesIte->second.empty() )
00148                                 {
00149                                         Singleton< ServiceManager >::getInstance()._services.erase( servicesIte ) ;
00150                                 }
00151                         }
00152                 }
00153         }

template<class TAttribute >
void OBT::setAttributeValue ( typename TAttribute::owner_type &  owner,
const char *  name,
typename TAttribute::value_type  value 
) [inline]

Definition at line 133 of file OBTAbstractAttribute.h.

00134         {
00135                 owner.getRTTI().template getAttribute< TAttribute >( name )->setValue( owner, value ) ;
00136         }

template<class TAttribute >
void OBT::setAttributeValue ( typename TAttribute::owner_type &  owner,
unsigned int  attributeNumber,
typename TAttribute::value_type  value 
) [inline]

Definition at line 123 of file OBTAbstractAttribute.h.

00124         {
00125                 owner.getRTTI().template getAttribute< TAttribute >( attributeNumber )->setValue( owner, value ) ;
00126         }

template<class TTo , class TFrom >
const SmartPointer< TTo >& OBT::StaticCast ( const SmartPointer< TFrom > &  from  )  [inline]

Definition at line 383 of file OBTSmartPointer.h.

00384         {
00385                 return reinterpret_cast<const SmartPointer< TTo >&>( from ) ;
00386         }

FILE * OBT::TiXmlFOpen ( const char *  filename,
const char *  mode 
)

Definition at line 41 of file tiny/OBTtinyxml.cpp.

Referenced by OBT::TiXmlDocument::LoadFile(), and OBT::TiXmlDocument::SaveFile().

00042 {
00043         #if defined(_MSC_VER) && (_MSC_VER >= 1400 )
00044                 FILE* fp = 0;
00045                 errno_t err = fopen_s( &fp, filename, mode );
00046                 if ( !err && fp )
00047                         return fp;
00048                 return 0;
00049         #else
00050                 return fopen( filename, mode );
00051         #endif
00052 }

bool OBT::XmlTest ( const char *  testString,
int  expected,
int  found,
bool  noEcho = false 
)

Definition at line 49 of file OBTxmltest.cpp.

References gFail, and gPass.

00050 {
00051         bool pass = ( expected == found );
00052         if ( pass )
00053                 printf ("[pass]");
00054         else
00055                 printf ("[fail]");
00056 
00057         if ( noEcho )
00058                 printf (" %s\n", testString);
00059         else
00060                 printf (" %s [%d][%d]\n", testString, expected, found);
00061 
00062         if ( pass )
00063                 ++gPass;
00064         else
00065                 ++gFail;
00066         return pass;
00067 }

bool OBT::XmlTest ( const char *  testString,
const char *  expected,
const char *  found,
bool  noEcho = false 
)

Definition at line 28 of file OBTxmltest.cpp.

References gFail, and gPass.

Referenced by main().

00029 {
00030         bool pass = !strcmp( expected, found );
00031         if ( pass )
00032                 printf ("[pass]");
00033         else
00034                 printf ("[fail]");
00035 
00036         if ( noEcho )
00037                 printf (" %s\n", testString);
00038         else
00039                 printf (" %s [%s][%s]\n", testString, expected, found);
00040 
00041         if ( pass )
00042                 ++gPass;
00043         else
00044                 ++gFail;
00045         return pass;
00046 }


Variable Documentation

int OBT::gFail = 0 [static]

Definition at line 25 of file OBTxmltest.cpp.

Referenced by main(), and XmlTest().

int OBT::gPass = 0 [static]

Definition at line 24 of file OBTxmltest.cpp.

Referenced by main(), and XmlTest().

template class OBT_API OBT::Singleton< ConfigurationTree >

Definition at line 69 of file OBTConfigurationTree.h.

template class OBT_API OBT::Singleton< ServiceManager >

Definition at line 79 of file OBTServiceManager.h.

template class OBT_API OBT::Singleton< Tracer >

The Tracer singleton.

The singleton is a friend.

Definition at line 263 of file OBTTrace.h.

const TiXmlEncoding OBT::TIXML_DEFAULT_ENCODING = TIXML_ENCODING_UNKNOWN

Definition at line 179 of file OBTtinyxml.h.

const int OBT::TIXML_MAJOR_VERSION = 2

Definition at line 102 of file OBTtinyxml.h.

const int OBT::TIXML_MINOR_VERSION = 5

Definition at line 103 of file OBTtinyxml.h.

const int OBT::TIXML_PATCH_VERSION = 3

Definition at line 104 of file OBTtinyxml.h.

const unsigned char OBT::TIXML_UTF_LEAD_0 = 0xefU
const unsigned char OBT::TIXML_UTF_LEAD_1 = 0xbbU
const unsigned char OBT::TIXML_UTF_LEAD_2 = 0xbfU

Generated on 1 Jan 2010 for OBT by  doxygen 1.6.1