From: Dominic L. <ma...@us...> - 2006-06-06 21:44:46
|
Update of /cvsroot/robotflow/RobotFlow/Audio/src In directory sc8-pr-cvs9.sourceforge.net:/tmp/cvs-serv30466/src Modified Files: SourceInfo.cpp Log Message: now able to read and pring to iostreams Index: SourceInfo.cpp =================================================================== RCS file: /cvsroot/robotflow/RobotFlow/Audio/src/SourceInfo.cpp,v retrieving revision 1.2 retrieving revision 1.3 diff -C2 -d -r1.2 -r1.3 *** SourceInfo.cpp 27 Jun 2005 22:44:01 -0000 1.2 --- SourceInfo.cpp 6 Jun 2006 19:59:48 -0000 1.3 *************** *** 2,6 **** --- 2,10 ---- #include "SourceInfo.h" #include "Vector.h" + #include "ObjectParser.h" + #include <string> + #include <iostream> + using namespace std; using namespace FD; *************** *** 17,18 **** --- 21,60 ---- out << ">" << std::endl; } + + void SourceInfo::readFrom(std::istream &in) + { + string tag; + + while (1) { + char ch; + in >> ch; + if (ch == '>') break; + + else if (ch != '<') { + throw new ParsingException ("SourceInfo::readFrom : Parse error: '<' expected"); + } + in >> tag; + + if (tag == "x") { + in >> x[0] >> x[1] >> x[2]; + } + else if (tag == "strength") { + in >> strength; + } + else if (tag == "age") { + in >> age; + } + else if (tag == "source_id") { + in >> source_id; + } + else { + throw new ParsingException ("SourceInfo::readFrom : Unknown argument: " + tag); + } + + if (!in) throw new ParsingException ("SourceInfo::readFrom : Parse error trying to build " + tag); + + in >> tag; + if (tag != ">") + throw new ParsingException ("SourceInfo::readFrom : Parse error: '>' expected "); + } + } |