25 #include "RDBComment.h" 44 getline( is, line,
'\n' );
48 }
catch (
RDBErr& rdberr ) {
49 rdberr.set_message(
"operator>>(std::istream&,RDBComment&): " );
53 throw(
RDBErr(
"operator>>(std::istream&,RDBComment&): unexpected exception caught" ) );
81 0 != rdbcomment._keyword.size( )
83 0 != rdbcomment._value.size( )
89 ) << rdbcomment._comment;
103 const std::string& comment
109 }
catch (
RDBErr& rdberr ) {
110 rdberr.set_message(
"RDBComment::RDBComment(std::string&)" );
114 throw(
RDBErr(
"RDBComment::RDBComment(std::string&): unexpected exception caught" ) );
154 if (
this != &rdbcomment ) {
155 _comment = rdbcomment._comment;
156 _keyword = rdbcomment._keyword;
157 _value = rdbcomment._value;
173 const std::string& comment
191 const std::string& comment
194 size_t pos = comment.find_first_not_of(
" " );
196 if (
'#' != comment[0] ||
' ' != comment[1] ) {
197 throw(
RDBErr(
"RDBComment::setComment(std::string&): Leading characters not `# '" ) );
200 }
else if ( comment.npos != pos ) {
201 if (
'#' != comment[pos] ) {
202 throw(
RDBErr(
"RDBComment::setComment(std::string&): First non-space character not `#'" ) );
206 throw(
RDBErr(
"RDBComment::setComment(std::string&): No comment found" ) );
223 const std::string& comment
226 if ( comment.size() == 0 )
229 size_t pos = comment.find_first_not_of(
" " );
236 if (
'#' == _comment[pos] ) {
237 _comment.erase( 0, pos + 1 );
242 if (
':' == _comment[0] ) {
243 _comment.erase( 0, 1 );
245 pos = _comment.find(
"=", 0 );
246 if ( pos > _comment.size( ) )
247 pos = _comment.size( );
250 _keyword.erase( pos );
252 size_t wspos = _keyword.find_first_not_of(
" " );
253 _keyword.erase( 0, wspos );
254 wspos = _keyword.find_last_not_of(
" " );
255 _keyword.erase( wspos + 1 );
258 _value.replace( 0, pos+1,
"" );
260 wspos = _value.find_first_not_of(
" " );
261 _value.erase( 0, wspos );
262 wspos = _value.find_last_not_of(
" " );
263 _value.erase( wspos + 1 );
266 pos = _comment.find_first_not_of(
"\t " );
267 if ( _comment.npos != pos ) {
268 _comment.erase( 0, pos );
282 const std::string& keyword
286 setComment( std::string(
"#:") + keyword +
" = " + _value );
288 }
catch (
RDBErr& rdberr ) {
289 rdberr.set_message(
"RDBComment::setKeyword(std::string&): " );
293 throw(
RDBErr(
"RDBComment::setKeyword(std::string&): unexpected exception caught" ) );
306 const std::string& value
310 setComment( std::string(
"#:") + _keyword +
" = " + value );
312 }
catch (
RDBErr& rdberr ) {
313 rdberr.set_message(
"RDBComment::setValue(std::string&): " );
317 throw(
RDBErr(
"RDBComment::setValue(std::string&): unexpected exception caught" ) );
333 (0 != _keyword.size( ) || 0 != _value.size( ))
The parent class for all RDB related exceptions.