Main Page | Namespace List | Class Hierarchy | Alphabetical List | Class List | File List | Namespace Members | Class Members | File Members | Related Pages

base::Externalizer Class Reference

Inheritance diagram for base::Externalizer:

Inheritance graph
[legend]
Collaboration diagram for base::Externalizer:

Collaboration graph
[legend]
List of all members.

Public Member Functions

 Externalizer (Externalizable::ExternalizationType type, ref< VFile > archive)
 Externalizer (Externalizable::ExternalizationType type, std::ios &stream)
virtual ~Externalizer ()
virtual String className () const
bool isOutput () const
 true is this is an output serialization stream

bool isInput () const
 true if this is an input serialization stream

Externalizable::ExternalizationType ioType ()
PathName getArchivePath () const
void flush ()
 flush output stream (no-op on input). Should use this before closing an output file before Externalizer goes out-of-scope.

bool moreInput ()
String readLine ()
 read until end of line

String readString (SInt maxLength=-1)
 read maxLength chars (or until end of context if -1)

void writeLine (const String &line)
 write 'line' followed by end-of-line char

void writeString (const String &str)
 write String str (may contain end-of-line chars)

void writeComment (const String &comment)
 output a comment ('# ' in raw mode, xml comment in XML mode)

dom::DOMDocument * doc ()
dom::DOMNode * context ()
void setDocumentType (const String &name, const String &publicid, const String &sysid)
dom::DOMElement * createElement (const String &tagname, bool indenting=true)
void pushContext (dom::DOMNode *context)
dom::DOMNode * popContext ()
void appendElement (dom::DOMElement *e)
void appendBreak ()
dom::DOMElement * lastAppendedElement ()
String elementTagName (dom::DOMNode *n)
void appendElement (dom::DOMNode *n, const String &tagname, bool indenting=true)
void setElementAttribute (dom::DOMElement *e, const String &attrname, const String &value)
void appendProcessingInstruction (dom::DOMNode *n, const String &target, const String &data)
dom::DOMText * createText (const String &text)
void appendText (dom::DOMNode *n, const String &text)
dom::DOMComment * createComment (const String &comment)
void appendComment (dom::DOMNode *n, const String &comment)
dom::DOMCDATASection * createCDATA (const String &text)
void appendCDATA (dom::DOMNode *n, const String &text)
void appendNode (dom::DOMNode *n, dom::DOMNode *n2)
void appendBreak (dom::DOMNode *n)
dom::DOMElement * getFirstElement (dom::DOMNode *n, const String &tagname, bool required=true)
dom::DOMElement * getFirstChildElement (dom::DOMNode *n, const String &tagname, bool required=true)
dom::DOMElement * getNextSiblingElement (dom::DOMNode *n, const String &tagname, bool required=true)
void removeElement (dom::DOMElement *e)
String getContainedText (dom::DOMNode *n, bool removeIndentation=false)
String getElementAttribute (dom::DOMElement *e, const String &attrname, bool required=true)
String getDefaultedElementAttribute (dom::DOMElement *e, const String &attrname, const String &defaultValue)
virtual bool isSameKindAs (const Object &) const

Static Public Member Functions

String readLineFromStream (std::istream &istream)
array< StringsplitIntoLines (const String &text, bool removeBlankLines=true)
array< StringsplitAtDelimiter (const String &line, char delimiter=',')
base::Vector stringsToReals (const array< String > &strings, bool acceptUnits=true)
base::Matrix4 toMatrix4 (const String &text)
String toString (const base::Matrix4 &m)
base::Vector3 toVector3 (const String &text, bool acceptUnits=true)
base::Vector toVector (const String &text, bool commasep=false, bool acceptUnits=true)
String toString (const base::Vector3 &v)
String toString (const base::Vector &v, bool commasep=false)
String toString (const base::Matrix &m)
String toString (Real v, const String &units="m")
Real toReal (const String &text, bool acceptUnits=true)
base::Matrix toMatrix (const String &text)
String removeChar (const String &text, char toRemove)
bool isNumeric (const String &text)

Static Public Attributes

const String newline
const Int indentSpaces = 2

Protected Member Functions

 Externalizer (const Externalizer &e)
std::istream & input ()
std::ostream & output ()
void initXMLDoc (const String &rootElementName="")
dom::DOMDocument * xmlParseDocument ()
void xmlWriteDocument (dom::DOMDocument *doc)
void xmlReleaseDocument ()
void xmlFormat (dom::DOMNode *n, Int indent)
bool isNewline (dom::DOMNode *n)
bool equals (const XCh *str1, const String &str2)
bool isElement (dom::DOMNode *n)
bool isElement (dom::DOMNode *n, const String &tagname)
void abort (const String &exceptionString)

Static Protected Member Functions

void xmlInitialize ()

Protected Attributes

bool xmlMode
dom::DOMBuilder * parser
dom::DOMImplementation * impl
dom::DOMDocumentType * doctype
dom::DOMDocument * xmldoc
std::stack< dom::DOMNode * > xmlcontext
dom::DOMElement * lastAppendedElem
bool isoutput
bool aborted
std::istream * istream
std::ostream * ostream
PathName path

Static Protected Attributes

bool xmlInitialized
const String inputToConstErrorString
const String inputDuringOutputErrorString

Constructor & Destructor Documentation

base::Externalizer::Externalizer Externalizable::ExternalizationType  type,
ref< VFile archive
 

base::Externalizer::Externalizer Externalizable::ExternalizationType  type,
std::ios &  stream
 

virtual base::Externalizer::~Externalizer  )  [virtual]
 

base::Externalizer::Externalizer const Externalizer e  )  [inline, protected]
 

Definition at line 202 of file Externalizer.

References aborted, doctype, impl, isoutput, parser, xmlcontext, xmldoc, and xmlMode.


Member Function Documentation

void base::Externalizer::abort const String exceptionString  )  [protected]
 

void base::Externalizer::appendBreak dom::DOMNode *  n  )  [inline]
 

Definition at line 167 of file Externalizer.

References appendText(), Assert, newline, and xmlMode.

void base::Externalizer::appendBreak  )  [inline]
 

Definition at line 153 of file Externalizer.

References appendText(), Assert, newline, xmlcontext, and xmlMode.

void base::Externalizer::appendCDATA dom::DOMNode *  n,
const String text
 

void base::Externalizer::appendComment dom::DOMNode *  n,
const String comment
 

void base::Externalizer::appendElement dom::DOMNode *  n,
const String tagname,
bool  indenting = true
 

void base::Externalizer::appendElement dom::DOMElement *  e  )  [inline]
 

Definition at line 152 of file Externalizer.

References Assert, lastAppendedElem, xmlcontext, and xmlMode.

void base::Externalizer::appendNode dom::DOMNode *  n,
dom::DOMNode *  n2
[inline]
 

Definition at line 166 of file Externalizer.

References Assert, and xmlMode.

void base::Externalizer::appendProcessingInstruction dom::DOMNode *  n,
const String target,
const String data
 

void base::Externalizer::appendText dom::DOMNode *  n,
const String text
 

Referenced by appendBreak().

virtual String base::Externalizer::className  )  const [inline, virtual]
 

return the name of the object's class type. Must be defined by derived classes.

Implements base::Object.

Definition at line 105 of file Externalizer.

References base::String.

dom::DOMNode* base::Externalizer::context  )  [inline]
 

Definition at line 138 of file Externalizer.

References initXMLDoc(), xmlcontext, and xmlMode.

dom::DOMCDATASection* base::Externalizer::createCDATA const String text  ) 
 

dom::DOMComment* base::Externalizer::createComment const String comment  ) 
 

dom::DOMElement* base::Externalizer::createElement const String tagname,
bool  indenting = true
 

dom::DOMText* base::Externalizer::createText const String text  ) 
 

dom::DOMDocument* base::Externalizer::doc  )  [inline]
 

Definition at line 137 of file Externalizer.

References initXMLDoc(), xmldoc, and xmlMode.

String base::Externalizer::elementTagName dom::DOMNode *  n  )  [inline]
 

Definition at line 155 of file Externalizer.

References Assert, isElement(), base::String, and xmlMode.

bool base::Externalizer::equals const XCh str1,
const String str2
[protected]
 

void base::Externalizer::flush  ) 
 

flush output stream (no-op on input). Should use this before closing an output file before Externalizer goes out-of-scope.

PathName base::Externalizer::getArchivePath  )  const [inline]
 

return the filesystem path of the stream to which this Externalizer is attached; or the empty String (if unknown - i.e. instantiated from an iostream)

Definition at line 113 of file Externalizer.

References path.

String base::Externalizer::getContainedText dom::DOMNode *  n,
bool  removeIndentation = false
 

String base::Externalizer::getDefaultedElementAttribute dom::DOMElement *  e,
const String attrname,
const String defaultValue
 

String base::Externalizer::getElementAttribute dom::DOMElement *  e,
const String attrname,
bool  required = true
 

dom::DOMElement* base::Externalizer::getFirstChildElement dom::DOMNode *  n,
const String tagname,
bool  required = true
 

dom::DOMElement* base::Externalizer::getFirstElement dom::DOMNode *  n,
const String tagname,
bool  required = true
 

dom::DOMElement* base::Externalizer::getNextSiblingElement dom::DOMNode *  n,
const String tagname,
bool  required = true
 

void base::Externalizer::initXMLDoc const String rootElementName = ""  )  [protected]
 

Referenced by context(), and doc().

std::istream& base::Externalizer::input  )  [inline, protected]
 

Definition at line 209 of file Externalizer.

References Assert, isInput(), and istream.

Referenced by moreInput().

Externalizable::ExternalizationType base::Externalizer::ioType  )  [inline]
 

Definition at line 109 of file Externalizer.

References isOutput().

bool base::Externalizer::isElement dom::DOMNode *  n,
const String tagname
[protected]
 

bool base::Externalizer::isElement dom::DOMNode *  n  )  [inline, protected]
 

Definition at line 234 of file Externalizer.

Referenced by elementTagName().

bool base::Externalizer::isInput  )  const [inline]
 

true if this is an input serialization stream

Definition at line 108 of file Externalizer.

References isOutput().

Referenced by input(), and moreInput().

bool base::Externalizer::isNewline dom::DOMNode *  n  )  [protected]
 

bool base::Externalizer::isNumeric const String text  )  [static]
 

bool base::Externalizer::isOutput  )  const [inline]
 

true is this is an output serialization stream

Definition at line 107 of file Externalizer.

References isoutput.

Referenced by ioType(), isInput(), and output().

virtual bool base::Object::isSameKindAs const Object  )  const [inline, virtual, inherited]
 

Definition at line 47 of file Object.

dom::DOMElement* base::Externalizer::lastAppendedElement  )  [inline]
 

Definition at line 154 of file Externalizer.

References Assert, lastAppendedElem, and xmlMode.

bool base::Externalizer::moreInput  )  [inline]
 

Definition at line 117 of file Externalizer.

References Assert, input(), and isInput().

std::ostream& base::Externalizer::output  )  [inline, protected]
 

Definition at line 210 of file Externalizer.

References Assert, isOutput(), and ostream.

dom::DOMNode* base::Externalizer::popContext  )  [inline]
 

Definition at line 150 of file Externalizer.

References Assert, xmlcontext, and xmlMode.

void base::Externalizer::pushContext dom::DOMNode *  context  )  [inline]
 

Definition at line 149 of file Externalizer.

References Assert, xmlcontext, and xmlMode.

String base::Externalizer::readLine  ) 
 

read until end of line

String base::Externalizer::readLineFromStream std::istream &  istream  )  [inline, static]
 

Definition at line 126 of file Externalizer.

References base::String.

String base::Externalizer::readString SInt  maxLength = -1  ) 
 

read maxLength chars (or until end of context if -1)

Parameters:
maxLength  still input remaining in current context?

String base::Externalizer::removeChar const String text,
char  toRemove
[static]
 

void base::Externalizer::removeElement dom::DOMElement *  e  ) 
 

void base::Externalizer::setDocumentType const String name,
const String publicid,
const String sysid
 

if a DOCTYPE is to be set, always call setDocumentType() first on a new output Externalizer. Subsequent calls will be ignored. Only then can createElement() be called to create an element. createElement() must be the first 'write' method called on a new output Externalizer - in which case the element will be the root element of the document.

void base::Externalizer::setElementAttribute dom::DOMElement *  e,
const String attrname,
const String value
[inline]
 

Definition at line 158 of file Externalizer.

References base::String.

array<String> base::Externalizer::splitAtDelimiter const String line,
char  delimiter = ','
[static]
 

array<String> base::Externalizer::splitIntoLines const String text,
bool  removeBlankLines = true
[static]
 

base::Vector base::Externalizer::stringsToReals const array< String > &  strings,
bool  acceptUnits = true
[static]
 

base::Matrix base::Externalizer::toMatrix const String text  )  [static]
 

base::Matrix4 base::Externalizer::toMatrix4 const String text  )  [static]
 

Real base::Externalizer::toReal const String text,
bool  acceptUnits = true
[static]
 

String base::Externalizer::toString Real  v,
const String units = "m"
[static]
 

String base::Externalizer::toString const base::Matrix m  )  [static]
 

String base::Externalizer::toString const base::Vector v,
bool  commasep = false
[static]
 

String base::Externalizer::toString const base::Vector3 v  )  [static]
 

String base::Externalizer::toString const base::Matrix4 m  )  [static]
 

base::Vector base::Externalizer::toVector const String text,
bool  commasep = false,
bool  acceptUnits = true
[static]
 

base::Vector3 base::Externalizer::toVector3 const String text,
bool  acceptUnits = true
[static]
 

void base::Externalizer::writeComment const String comment  ) 
 

output a comment ('# ' in raw mode, xml comment in XML mode)

void base::Externalizer::writeLine const String line  ) 
 

write 'line' followed by end-of-line char

void base::Externalizer::writeString const String str  ) 
 

write String str (may contain end-of-line chars)

void base::Externalizer::xmlFormat dom::DOMNode *  n,
Int  indent
[protected]
 

void base::Externalizer::xmlInitialize  )  [static, protected]
 

dom::DOMDocument* base::Externalizer::xmlParseDocument  )  [protected]
 

void base::Externalizer::xmlReleaseDocument  )  [protected]
 

void base::Externalizer::xmlWriteDocument dom::DOMDocument *  doc  )  [protected]
 


Member Data Documentation

bool base::Externalizer::aborted [protected]
 

Definition at line 247 of file Externalizer.

Referenced by Externalizer().

dom::DOMDocumentType* base::Externalizer::doctype [protected]
 

Definition at line 222 of file Externalizer.

Referenced by Externalizer().

dom::DOMImplementation* base::Externalizer::impl [protected]
 

Definition at line 221 of file Externalizer.

Referenced by Externalizer().

const Int base::Externalizer::indentSpaces = 2 [static]
 

Definition at line 199 of file Externalizer.

const String base::Externalizer::inputDuringOutputErrorString [static, protected]
 

Definition at line 240 of file Externalizer.

const String base::Externalizer::inputToConstErrorString [static, protected]
 

Definition at line 239 of file Externalizer.

bool base::Externalizer::isoutput [protected]
 

Definition at line 246 of file Externalizer.

Referenced by Externalizer(), and isOutput().

std::istream* base::Externalizer::istream [protected]
 

Definition at line 249 of file Externalizer.

Referenced by input().

dom::DOMElement* base::Externalizer::lastAppendedElem [protected]
 

Definition at line 225 of file Externalizer.

Referenced by appendElement(), and lastAppendedElement().

const String base::Externalizer::newline [static]
 

Definition at line 198 of file Externalizer.

Referenced by appendBreak().

std::ostream* base::Externalizer::ostream [protected]
 

Definition at line 250 of file Externalizer.

Referenced by output().

dom::DOMBuilder* base::Externalizer::parser [protected]
 

Definition at line 220 of file Externalizer.

Referenced by Externalizer().

PathName base::Externalizer::path [protected]
 

Definition at line 251 of file Externalizer.

Referenced by getArchivePath().

std::stack<dom::DOMNode*> base::Externalizer::xmlcontext [protected]
 

Definition at line 224 of file Externalizer.

Referenced by appendBreak(), appendElement(), context(), Externalizer(), popContext(), and pushContext().

dom::DOMDocument* base::Externalizer::xmldoc [protected]
 

Definition at line 223 of file Externalizer.

Referenced by doc(), and Externalizer().

bool base::Externalizer::xmlInitialized [static, protected]
 

Definition at line 215 of file Externalizer.

bool base::Externalizer::xmlMode [protected]
 

Definition at line 212 of file Externalizer.

Referenced by appendBreak(), appendElement(), appendNode(), context(), doc(), elementTagName(), Externalizer(), lastAppendedElement(), popContext(), and pushContext().


The documentation for this class was generated from the following file:
Generated on Thu Jul 29 16:38:38 2004 for OpenSim by doxygen 1.3.6