From 1be0aec720c1e3f1ffebc2844245933ac7d1c0a9 Mon Sep 17 00:00:00 2001 From: schodet Date: Sun, 21 Mar 2004 17:15:46 +0000 Subject: Add: Logger. --- 2004/i/nono/src/config/config.cc | 18 +++++++++++++++++- 2004/i/nono/src/config/config.h | 2 ++ 2 files changed, 19 insertions(+), 1 deletion(-) (limited to '2004/i/nono/src/config') diff --git a/2004/i/nono/src/config/config.cc b/2004/i/nono/src/config/config.cc index 4755677..9a88494 100644 --- a/2004/i/nono/src/config/config.cc +++ b/2004/i/nono/src/config/config.cc @@ -39,7 +39,7 @@ Config::Config (const char *filename) #else if (config_yyopen (filename, 0, 0) == -1) #endif - throw ErreurConfig (filename, "Erreur d'ouverture.\n"); + m_type = 0; } // Destructeur. @@ -69,6 +69,16 @@ Config::getId (void) return config_yylval.id; } +void +Config::getId (std::string &s) +{ + if (m_type == -1) m_type = config_yylex (); + if (m_type != ID) + throw ErreurConfig (m_filename.c_str (), "Identificateur attendu.\n"); + m_type = -1; + s = config_yylval.id; +} + bool Config::getBool (void) { @@ -143,6 +153,12 @@ Config::noId (void) "Identificateur inconnu.\n"); } +void +Config::throwError (const char *msg) +{ + throw ErreurConfig (m_filename.c_str (), msg); +} + // Appellé par le lexer pour changer de fichier. bool Config::wrap_handler (void *p) diff --git a/2004/i/nono/src/config/config.h b/2004/i/nono/src/config/config.h index f56d558..f6f22df 100644 --- a/2004/i/nono/src/config/config.h +++ b/2004/i/nono/src/config/config.h @@ -41,6 +41,7 @@ class Config int getNum (void); Config &operator>> (int &num) { num = getNum (); return *this; } const char *getId (void); + void getId (std::string &s); bool getBool (void); Config &operator>> (bool &b) { b = getBool (); return *this; } double getFloat (void); @@ -59,6 +60,7 @@ class Config bool eof (void); // Lance une erreur, on a pas trouvé ce qu'on voulais. void noId (void); + void throwError (const char *msg); private: // Appellé par le lexer pour changer de fichier. static bool wrap_handler (void *p); -- cgit v1.2.3