25 #include "RDBComment.h" 44 getline( is, line,
'\n' );
48 }
catch (
RDBErr& rdberr ) {
49 rdberr.set_message(
"operator>>(istream&,RDBComment&): " );
53 throw(
RDBErr(
"operator>>(istream&,RDBComment&): unexpected exception caught" ) );
81 0 != rdbcomment._keyword.size( )
83 0 != rdbcomment._value.size( )
89 ) << rdbcomment._comment;
103 const string& comment
109 }
catch (
RDBErr& rdberr ) {
110 rdberr.set_message(
"RDBComment::RDBComment(string&)" );
114 throw(
RDBErr(
"RDBComment::RDBComment(string&): unexpected exception caught" ) );
154 if (
this != &rdbcomment ) {
155 _comment = rdbcomment._comment;
156 _keyword = rdbcomment._keyword;
157 _value = rdbcomment._value;
173 const string& comment
191 const string& comment
194 size_t pos = comment.find_first_not_of(
" " );
196 if (
'#' != comment[0] ||
' ' != comment[1] ) {
197 throw(
RDBErr(
"RDBComment::setComment(string&): Leading characters not `# '" ) );
200 }
else if ( comment.npos != pos ) {
201 if (
'#' != comment[pos] ) {
202 throw(
RDBErr(
"RDBComment::setComment(string&): First non-space character not `#'" ) );
206 throw(
RDBErr(
"RDBComment::setComment(string&): No comment found" ) );
223 const string& comment
226 size_t pos = comment.find_first_not_of(
" " );
233 if (
'#' == _comment[pos] ) {
234 _comment.erase( 0, pos + 1 );
239 if (
':' == _comment[0] ) {
240 _comment.erase( 0, 1 );
242 pos = _comment.find(
"=", 0 );
243 if ( pos > _comment.size( ) )
244 pos = _comment.size( );
247 _keyword.erase( pos );
249 size_t wspos = _keyword.find_first_not_of(
" " );
250 _keyword.erase( 0, wspos );
251 wspos = _keyword.find_last_not_of(
" " );
252 _keyword.erase( wspos + 1 );
255 _value.replace( 0, pos+1,
"" );
257 wspos = _value.find_first_not_of(
" " );
258 _value.erase( 0, wspos );
259 wspos = _value.find_last_not_of(
" " );
260 _value.erase( wspos + 1 );
263 pos = _comment.find_first_not_of(
"\t " );
264 if ( _comment.npos != pos ) {
265 _comment.erase( 0, pos );
279 const string& keyword
283 setComment(
string(
"#:") + keyword +
" = " + _value );
285 }
catch (
RDBErr& rdberr ) {
286 rdberr.set_message(
"RDBComment::setKeyword(string&): " );
290 throw(
RDBErr(
"RDBComment::setKeyword(string&): unexpected exception caught" ) );
307 setComment(
string(
"#:") + _keyword +
" = " + value );
309 }
catch (
RDBErr& rdberr ) {
310 rdberr.set_message(
"RDBComment::setValue(string&): " );
314 throw(
RDBErr(
"RDBComment::setValue(string&): unexpected exception caught" ) );
330 (0 != _keyword.size( ) || 0 != _value.size( ))
The parent class for all RDB related exceptions.