summaryrefslogtreecommitdiff
path: root/2004/i/nono/src/config
diff options
context:
space:
mode:
authorschodet2004-03-21 17:15:46 +0000
committerschodet2004-03-21 17:15:46 +0000
commit1be0aec720c1e3f1ffebc2844245933ac7d1c0a9 (patch)
tree25377ef2e1b1d64bc17a830ea213f67f7d41f0a0 /2004/i/nono/src/config
parent677ad16bf96efd9487e7659b15dafc718cd53b46 (diff)
Add: Logger.
Diffstat (limited to '2004/i/nono/src/config')
-rw-r--r--2004/i/nono/src/config/config.cc18
-rw-r--r--2004/i/nono/src/config/config.h2
2 files changed, 19 insertions, 1 deletions
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);