|
@@ -434,41 +434,107 @@ int ClassNames::getBackgroundClass () const
|
|
|
|
|
|
void ClassNames::restore ( istream & is, int format )
|
|
|
{
|
|
|
- maxClassNo = -1;
|
|
|
- while ( ! is.eof() )
|
|
|
+ this->maxClassNo = -1;
|
|
|
+
|
|
|
+ if ( is.good() )
|
|
|
{
|
|
|
- std::string mytext;
|
|
|
- std::string mycode;
|
|
|
- int myclassno;
|
|
|
-
|
|
|
- if ( ! ( is >> mytext ) ) break;
|
|
|
- if ( mytext == "end" ) break;
|
|
|
- if ( ! ( is >> mycode ) ) break;
|
|
|
- if ( ! ( is >> myclassno ) ) break;
|
|
|
-
|
|
|
- tbl_code_text.insert ( pair<string, string> ( mycode, mytext ) );
|
|
|
- tbl_text_code.insert ( pair<string, string> ( mytext, mycode ) );
|
|
|
- tbl_classno_code.insert ( pair<int, string> ( myclassno, mycode ) );
|
|
|
- tbl_code_classno.insert ( pair<string, int> ( mycode, myclassno ) );
|
|
|
-
|
|
|
- if ( myclassno > maxClassNo ) maxClassNo = myclassno;
|
|
|
+
|
|
|
+ std::string tmp;
|
|
|
+ is >> tmp; //class name
|
|
|
+
|
|
|
+ bool b_endOfBlock ( false ) ;
|
|
|
+
|
|
|
+ while ( !b_endOfBlock )
|
|
|
+ {
|
|
|
+ is >> tmp; // start of block
|
|
|
+
|
|
|
+ if ( this->isEndTag( tmp, "ClassNames" ) )
|
|
|
+ {
|
|
|
+ b_endOfBlock = true;
|
|
|
+ continue;
|
|
|
+ }
|
|
|
+
|
|
|
+ tmp = this->removeStartTag ( tmp );
|
|
|
+ if ( tmp.compare("content") == 0 )
|
|
|
+ {
|
|
|
+ is >> tmp; // size:
|
|
|
+ int mySize ( 0 );
|
|
|
+ is >> mySize;
|
|
|
+ this->tbl_code_text.clear();
|
|
|
+ this->tbl_text_code.clear();
|
|
|
+ this->tbl_classno_code.clear();
|
|
|
+ this->tbl_code_classno.clear();
|
|
|
+
|
|
|
+ for ( int i = 0; i < mySize; i++ )
|
|
|
+ {
|
|
|
+ std::string mytext;
|
|
|
+ is >> mytext;
|
|
|
+ std::string mycode;
|
|
|
+ is >> mycode;
|
|
|
+ int myclassno;
|
|
|
+ is >> myclassno;
|
|
|
+
|
|
|
+ this->tbl_code_text.insert ( std::pair<std::string, std::string> ( mycode, mytext ) );
|
|
|
+ this->tbl_text_code.insert ( std::pair<std::string, std::string> ( mytext, mycode ) );
|
|
|
+ this->tbl_classno_code.insert ( std::pair<int, std::string> ( myclassno, mycode ) );
|
|
|
+ this->tbl_code_classno.insert ( std::pair<std::string, int> ( mycode, myclassno ) );
|
|
|
+
|
|
|
+ if ( myclassno > this->maxClassNo )
|
|
|
+ this->maxClassNo = myclassno;
|
|
|
+ }
|
|
|
+
|
|
|
+ is >> tmp; // end of block
|
|
|
+ tmp = this->removeEndTag ( tmp );
|
|
|
+ }
|
|
|
+ else
|
|
|
+ {
|
|
|
+ std::cerr << "WARNING -- unexpected ClassNames object -- " << tmp << " -- for restoration... aborting" << std::endl;
|
|
|
+ throw;
|
|
|
+ }
|
|
|
+ }
|
|
|
}
|
|
|
+ else
|
|
|
+ {
|
|
|
+ std::cerr << "ClassNames::restore -- InStream not initialized - restoring not possible!" << std::endl;
|
|
|
+ throw;
|
|
|
+ }
|
|
|
}
|
|
|
|
|
|
void ClassNames::store ( ostream & os, int format ) const
|
|
|
{
|
|
|
assert ( tbl_classno_code.size() == tbl_code_classno.size() );
|
|
|
- for ( map<int, string>::const_iterator i = tbl_classno_code.begin() ;
|
|
|
- i != tbl_classno_code.end();
|
|
|
- i++ )
|
|
|
+
|
|
|
+ if (os.good())
|
|
|
{
|
|
|
- int myclassno = i->first;
|
|
|
- std::string mycode = i->second;
|
|
|
- std::string mytext = text ( myclassno );
|
|
|
-
|
|
|
- os << mytext << "\t" << mycode << "\t" << myclassno << endl;
|
|
|
+ // show starting point
|
|
|
+ os << this->createStartTag( "ClassNames" ) << std::endl;
|
|
|
+
|
|
|
+ os.precision (numeric_limits<double>::digits10 + 1);
|
|
|
+
|
|
|
+ os << this->createStartTag( "content" ) << std::endl;
|
|
|
+ os << "size: " << this->tbl_classno_code.size() << std::endl;
|
|
|
+
|
|
|
+ for ( std::map< int, std::string >::const_iterator iIt = this->tbl_classno_code.begin();
|
|
|
+ iIt != this->tbl_classno_code.end();
|
|
|
+ iIt++
|
|
|
+ )
|
|
|
+ {
|
|
|
+ int myclassno = iIt->first;
|
|
|
+ std::string mycode = iIt->second;
|
|
|
+ std::string mytext = text ( myclassno );
|
|
|
+
|
|
|
+ os << mytext << " " << mycode << " " << myclassno << endl;
|
|
|
+ }
|
|
|
+ os << this->createEndTag( "content" ) << std::endl;
|
|
|
+
|
|
|
+ // done
|
|
|
+ os << this->createEndTag( "ClassNames" ) << std::endl;
|
|
|
}
|
|
|
- os << "end" << endl;
|
|
|
+ else
|
|
|
+ {
|
|
|
+ std::cerr << "OutStream not initialized - storing not possible!" << std::endl;
|
|
|
+ }
|
|
|
+
|
|
|
}
|
|
|
|
|
|
void ClassNames::clear ()
|