#include <OSGStandardStringConversionState.h>

Public Member Functions | |
Constructors | |
| StandardStringConversionState (UInt32 indent=DefaultIndent, UInt32 width=DefaultWidth) | |
Destructor | |
| virtual | ~StandardStringConversionState (void) |
Get | |
| UInt32 | getIndent (void) const |
| UInt32 | getWidth (void) const |
Set | |
| void | setIndent (UInt32 newIndent) |
| void | setWidth (UInt32 newWidth) |
Handle Fields | |
| virtual std::string & | beginField (const Field *pF, std::string &outStr) |
| virtual std::string & | addValueStr (std::string &value, std::string &outStr) |
| virtual std::string & | endField (const Field *pF, std::string &outStr) |
Static Public Attributes | |
Constants | |
| static const UInt32 | DefaultIndent = 0 |
| static const UInt32 | DefaultWidth = 80 |
Protected Types | |
| typedef StringConversionStateBase | Inherited |
Protected Attributes | |
Member | |
| Indenter | _indent |
| UInt32 | _width |
| UInt32 | _lineLength |
| bool | _noLineBreakHint |
| bool | _multiFieldHint |
| std::string | _mfSeparator |
| UInt32 | _mfSepLength |
| UInt32 | _lastMFSepStart |
Private Member Functions | |
| StandardStringConversionState (const StandardStringConversionState &source) | |
| prohibit default function (move to 'public' if needed) | |
| StandardStringConversionState & | operator= (const StandardStringConversionState &source) |
| prohibit default function (move to 'public' if needed) | |
Definition at line 63 of file OSGStandardStringConversionState.h.
typedef StringConversionStateBase osg::StandardStringConversionState::Inherited [protected] |
Definition at line 126 of file OSGStandardStringConversionState.h.
| StandardStringConversionState::StandardStringConversionState | ( | UInt32 | indent = DefaultIndent, |
|
| UInt32 | width = DefaultWidth | |||
| ) |
Definition at line 62 of file OSGStandardStringConversionState.cpp.
00063 : 00064 Inherited ( ), 00065 00066 _indent (indent), 00067 _width (width ), 00068 00069 _lineLength ( 0), 00070 _noLineBreakHint(false ), 00071 _multiFieldHint (false ), 00072 _mfSeparator (", " ), 00073 _mfSepLength ( 2), 00074 _lastMFSepStart ( 0) 00075 { 00076 }
| StandardStringConversionState::~StandardStringConversionState | ( | void | ) | [virtual] |
| osg::StandardStringConversionState::StandardStringConversionState | ( | const StandardStringConversionState & | source | ) | [private] |
| UInt32 osg::StandardStringConversionState::getIndent | ( | void | ) | const [inline] |
Definition at line 48 of file OSGStandardStringConversionState.inl.
References _indent, and osg::Indenter::getIndent().
00049 { 00050 return _indent.getIndent(); 00051 }
| UInt32 osg::StandardStringConversionState::getWidth | ( | void | ) | const [inline] |
Definition at line 54 of file OSGStandardStringConversionState.inl.
References _width.
00055 { 00056 return _width; 00057 }
| void osg::StandardStringConversionState::setIndent | ( | UInt32 | newIndent | ) | [inline] |
Definition at line 60 of file OSGStandardStringConversionState.inl.
References _indent, and osg::Indenter::setIndent().
Referenced by osg::OSGWriter::writeField().
00061 { 00062 _indent.setIndent(newIndent); 00063 }
| void osg::StandardStringConversionState::setWidth | ( | UInt32 | newWidth | ) | [inline] |
Definition at line 66 of file OSGStandardStringConversionState.inl.
References _width.
Referenced by osg::OSGWriter::writeField().
00067 { 00068 _width = newWidth; 00069 }
| std::string & StandardStringConversionState::beginField | ( | const Field * | pF, | |
| std::string & | outStr | |||
| ) | [virtual] |
beginField. StandardStringConversionState adds _indent many spaces before the values of a field.
Implements osg::StringConversionStateBase.
Definition at line 93 of file OSGStandardStringConversionState.cpp.
References _indent, _lastMFSepStart, _lineLength, _multiFieldHint, _noLineBreakHint, osg::Field::getCardinality(), osg::TypeBase::getCName(), osg::Field::getContentType(), osg::FieldType::MULTI_FIELD, and osg::Indenter::str().
00096 { 00097 _lineLength = 0; 00098 _lastMFSepStart = 0; 00099 00100 if(pF->getCardinality() == FieldType::MULTI_FIELD) 00101 { 00102 _multiFieldHint = true; 00103 } 00104 else 00105 { 00106 _multiFieldHint = false; 00107 } 00108 00109 if(strstr(pF->getContentType().getCName(), "String") != NULL) 00110 { 00111 _noLineBreakHint = true; 00112 } 00113 else 00114 { 00115 _noLineBreakHint = false; 00116 } 00117 00118 outStr.append(_indent.str()); 00119 return outStr; 00120 }
| std::string & StandardStringConversionState::addValueStr | ( | std::string & | value, | |
| std::string & | outStr | |||
| ) | [virtual] |
addValueStr. StandardStringConversionState formats fields with indention and a limitation on the width of the rows.
Implements osg::StringConversionStateBase.
Definition at line 126 of file OSGStandardStringConversionState.cpp.
References _indent, _lastMFSepStart, _lineLength, _mfSeparator, _mfSepLength, _multiFieldHint, _noLineBreakHint, _width, osg::StringTokenizer::getNext(), osg::StringTokenizer::hasNext(), and osg::Indenter::str().
00128 { 00129 UInt32 valLength = value.length(); 00130 00131 if(_noLineBreakHint) 00132 { 00133 if(_lineLength+valLength > _width) 00134 { 00135 outStr.append("\n"); 00136 _lineLength = 0; 00137 outStr.append(_indent.str()); 00138 } 00139 00140 outStr.append(value); 00141 _lineLength += valLength; 00142 } 00143 else 00144 { 00145 StringTokenizer tokens(value); 00146 std::string token; 00147 00148 bool first = true; 00149 00150 while(tokens.hasNext() == true) 00151 { 00152 token = tokens.getNext(); 00153 UInt32 tokenLength = token.length(); 00154 00155 if(_lineLength + tokenLength > _width) 00156 { 00157 outStr.append("\n"); 00158 _lineLength = 0; 00159 outStr.append(_indent.str()); 00160 first = true; 00161 } 00162 00163 if(first == true) 00164 { 00165 first = false; 00166 } 00167 else 00168 { 00169 outStr.append(" "); 00170 } 00171 00172 outStr.append(token); 00173 00174 _lineLength += tokenLength+1; 00175 } 00176 } 00177 00178 if(_multiFieldHint == true) 00179 { 00180 _lastMFSepStart = outStr.length(); 00181 outStr.append(_mfSeparator); 00182 _lineLength += _mfSepLength; 00183 } 00184 00185 return outStr; 00186 }
| std::string & StandardStringConversionState::endField | ( | const Field * | pF, | |
| std::string & | outStr | |||
| ) | [virtual] |
endField. StandardStringConversionState removes the last MultiField- Separator-String appended to outStr.
Implements osg::StringConversionStateBase.
Definition at line 193 of file OSGStandardStringConversionState.cpp.
References _lastMFSepStart, _mfSepLength, and _multiFieldHint.
00196 { 00197 if(_multiFieldHint == true) 00198 { 00199 outStr = outStr.erase(_lastMFSepStart, _mfSepLength); 00200 } 00201 00202 return outStr; 00203 }
| StandardStringConversionState& osg::StandardStringConversionState::operator= | ( | const StandardStringConversionState & | source | ) | [private] |
const UInt32 osg::StandardStringConversionState::DefaultIndent = 0 [static] |
Definition at line 75 of file OSGStandardStringConversionState.h.
const UInt32 osg::StandardStringConversionState::DefaultWidth = 80 [static] |
Definition at line 76 of file OSGStandardStringConversionState.h.
Indenter osg::StandardStringConversionState::_indent [protected] |
Definition at line 132 of file OSGStandardStringConversionState.h.
Referenced by addValueStr(), beginField(), getIndent(), and setIndent().
UInt32 osg::StandardStringConversionState::_width [protected] |
Definition at line 133 of file OSGStandardStringConversionState.h.
Referenced by addValueStr(), getWidth(), and setWidth().
Definition at line 135 of file OSGStandardStringConversionState.h.
Referenced by addValueStr(), and beginField().
bool osg::StandardStringConversionState::_noLineBreakHint [protected] |
Definition at line 137 of file OSGStandardStringConversionState.h.
Referenced by addValueStr(), and beginField().
bool osg::StandardStringConversionState::_multiFieldHint [protected] |
Definition at line 138 of file OSGStandardStringConversionState.h.
Referenced by addValueStr(), beginField(), and endField().
std::string osg::StandardStringConversionState::_mfSeparator [protected] |
Definition at line 141 of file OSGStandardStringConversionState.h.
Referenced by addValueStr(), and endField().
Definition at line 142 of file OSGStandardStringConversionState.h.
Referenced by addValueStr(), beginField(), and endField().
1.5.5