|
Go to the documentation of this file.
33 : mMode(mode), mpStream(NULL), mFileName( "")
38 FD_DV( "TokenReader::Tokenreader(String, ...): " << rInString);
39 mpSStream= new std::istringstream(rInString, std::istringstream::in | std::istringstream::binary);
45 FD_DV( "TokenReader::Tokenreader(File, \"" << rInString << "\")");
46 mFStream.exceptions(std::ios::badbit|std::ios::failbit);
48 mFStream.open(rInString.c_str(), std::ios::in | std::ios::binary);
50 catch (std::ios::failure&) {
51 std::stringstream errstr;
52 errstr << "Exception opening/reading file \""<< rInString << "\"";
53 throw Exception( "TokenReader::TokenReader", errstr.str(), 1);
60 std::stringstream errstr;
61 errstr << "Invalid Mode / Not implemented";
62 throw Exception( "TokenReader::TokenReader(mode,instring)", errstr.str(), 1);
69 : mMode(File), mpStream(NULL), mFileName(rFilename)
72 FD_DV( "TokenReader::Tokenreader(File, \"" << rFilename << "\")");
73 mFStream.exceptions(std::ios::badbit|std::ios::failbit);
75 mFStream.open(rFilename.c_str(), std::ios::in | std::ios::binary);
77 catch (std::ios::failure&) {
78 std::stringstream errstr;
79 errstr << "Exception opening/reading file \""<< rFilename << "\"";
80 throw Exception( "TokenReader::TokenReader", errstr.str(), 1);
116 catch (std::ios::failure&) {
117 std::stringstream errstr;
118 errstr << "Exception opening/reading file in "<< FileLine();
119 throw Exception( "TokenReader::Rewind", errstr.str(), 1);
135 } catch (std::ios::failure&) {
136 std::stringstream errstr;
137 errstr << "Exception opening/reading file in "<< FileLine();
138 throw Exception( "TokenReader::Peek", errstr.str(), 1);
146 FD_DV( "TokenReader: Peek: " << token. Str());
163 if(!res) return false;
165 if(token. IsBegin( "br") || token. IsEnd( "br")) return true;
185 #ifdef FAUDES_CHECKED
191 #ifdef FAUDES_CHECKED
201 FD_DV( "TokenReader:Get(): " << token. Str());
215 FD_DV( "TokenReader::SeekBegin: " << rLabel << " at " << FileLine() << " level " << mLevel);
224 std::stringstream errstr;
225 errstr << "Section \"" << rLabel << "\" expected at " << FileLine() << " no more tokens";
226 throw Exception( "TokenReader::SeekBegin", errstr.str(), 51);
235 std::stringstream errstr;
236 errstr << "Section \"" << rLabel << "\" expected at " << FileLine()
237 << "current section ended unexpected. Found: " << rToken. StringValue() << " Type " << rToken. Type();
238 throw Exception( "TokenReader::SeekBegin", errstr.str(), 51);
256 FD_DV( "Looking for Section \"" << rLabel << "\"");
261 FD_DV( "section level " << level << " current pos " << startpos << " begin of section " << mLevelState[level].mStartPosition);
269 std::stringstream errstr;
270 errstr << "Section \"" << rLabel << "\" expected at " << FileLine() << ", no token at all";
271 throw Exception( "TokenReader::ReadBegin Peek", errstr.str(), 51);
279 if(( mFilePos>=startpos) && (repcnt==1)) {
280 std::stringstream errstr;
281 errstr << "Section \"" << rLabel << "\" expected at " << FileLine() << ", did not find begin label";
282 throw Exception( "TokenReader::ReadBegin: Missing", errstr.str(), 51);
286 std::stringstream errstr;
287 errstr << "Section \"" << rLabel << "\" expected at " << FileLine() << ", did not find begin label";
288 throw Exception( "TokenReader::ReadBegin: Missing", errstr.str(), 51);
305 catch (std::ios::failure&) {
306 std::stringstream errstr;
307 errstr << "Section \"" << rLabel << "\" expected at " << FileLine();
308 throw Exception( "TokenReader::ReadBegin Rewind", errstr.str(), 1);
315 FD_DV( "TokenReader::ExistsBegin(): looking for Section \"" << rLabel << "\"");
320 FD_DV( "section level " << level << " current pos " << startpos << " begin of section " << mLevelState[level].mStartPosition);
336 if(token. IsEnd() && ( mLevel == level) && (rwcnt==0)) {
343 if(rwcnt>1) return false;
355 catch (std::ios::failure&) {
356 std::stringstream errstr;
357 errstr << "IO Error while scanning Section \"" << rLabel << "\" at " << FileLine();
358 throw Exception( "TokenReader::ExistsBegin IO", errstr.str(), 1);
365 FD_DV( "TokenReader::ReadEnd: " << rLabel << " at " << FileLine() );
375 std::stringstream errstr;
376 errstr << "end of section \"" << rLabel << "\" expected at " << FileLine();
377 throw Exception( "TokenReader::ReadEnd", errstr.str(), 51);
386 std::stringstream errstr;
387 errstr << "end of Section \"" << rLabel << "\" expected at " << FileLine();
388 throw Exception( "TokenReader::ReadEnd", errstr.str(), 51);
399 if(level<0) return false;
401 if(level> mLevel) return false;
402 if(level== mLevel) return true;
420 std::stringstream errstr;
421 errstr << "section end \"" << rLabel << "\" expected at " << FileLine();
422 throw Exception( "TokenReader::Eos", errstr.str(), 51);
432 std::stringstream errstr;
433 errstr << "Integer expected at " << FileLine();
434 throw Exception( "TokenReader::TokenReader", errstr.str(), 50);
444 std::stringstream errstr;
445 errstr << "Float expected at " << FileLine();
446 throw Exception( "TokenReader::TokenReader", errstr.str(), 50);
456 std::stringstream errstr;
457 errstr << "String expected at " << FileLine();
458 throw Exception( "TokenReader::TokenReader", errstr.str(), 50);
469 std::stringstream errstr;
470 errstr << "Option expected at " << FileLine();
471 throw Exception( "TokenReader::TokenReader", errstr.str(), 50);
481 std::stringstream errstr;
482 errstr << "Binary string expected at " << FileLine();
483 throw Exception( "TokenReader::TokenReader", errstr.str(), 50);
495 std::stringstream errstr;
496 errstr << "Text element \""<< rLabel << "\" expected at " << FileLine();
497 throw Exception( "TokenReader::TokenReader", errstr.str(), 50);
503 std::stringstream errstr;
504 errstr << "Text expected at " << FileLine();
505 throw Exception( "TokenReader::TokenReader", errstr.str(), 50);
509 static const std::string line= "\n\r\v";
510 std::size_t pos1=rText.find_first_not_of(line);
511 if(pos1!=std::string::npos)
512 rText=rText.substr(pos1);
515 std::size_t pos2=rText.find_last_not_of(line);
516 if(pos2!=std::string::npos)
519 static const std::string white= " \t";
521 pos1=rText.find_first_not_of(white);
522 if(pos1!=std::string::npos)
523 rText=rText.substr(pos1);
526 std::size_t pos2=rText.find_last_not_of(white);
527 if(pos2!=std::string::npos)
532 if(!token. IsEnd(rLabel)) {
533 std::stringstream errstr;
534 errstr << "End of text element \""<< rLabel << "\" expected at " << FileLine();
535 throw Exception( "TokenReader::TokenReader", errstr.str(), 50);
546 std::stringstream errstr;
547 errstr << "Verbatim element \""<< rLabel << "\" expected at " << FileLine();
548 throw Exception( "TokenReader::TokenReader", errstr.str(), 50);
557 if(cnt>0 && !token. IsCdata()) break;
563 static const std::string line= "\n\r\v";
564 std::size_t pos1=rString.find_first_not_of(line);
565 if(pos1!=std::string::npos)
566 rString=rString.substr(pos1);
569 std::size_t pos2=rString.find_last_not_of(line);
570 if(pos2!=std::string::npos)
571 rString.erase(pos2+1);
574 if(!token. IsEnd(rLabel)) {
575 std::stringstream errstr;
576 errstr << "End of verbatim element \""<< rLabel << "\" expected at " << FileLine();
577 throw Exception( "TokenReader::TokenReader", errstr.str(), 50);
586 FD_DV( "TokenReader::ReadCharacterData(): tag in buffer");
594 std::stringstream errstr;
595 errstr << "Missformed character data at " << FileLine() << ": " << rData;
596 throw Exception( "TokenReader::TokenReader", errstr.str(), 50);
609 int clevel = Level();
621 if(! Peek(token)) break;
630 rSectionString=tw. Str();
libFAUDES 2.28a
--- 2016.09.13
--- c++ api documentaion by doxygen
|