Began refactoring the entire source tree.
[aesalon.git] / include / monitor / config / Parser.h
blob38d217252e8b9a65f5f92fd3f49c27d1bfc62224
1 /**
2 Aesalon, a tool to visualize a program's behaviour at run-time.
3 Copyright (C) 2010, Aesalon Development Team.
5 Aesalon is distributed under the terms of the GNU GPLv3. For more
6 licensing information, see the file LICENSE included with the distribution.
8 @file include/monitor/config/Parser.h
12 #ifndef AesalonMonitor_Config_Parser_H
13 #define AesalonMonitor_Config_Parser_H
15 #include <iosfwd>
17 #include "Vault.h"
19 namespace Monitor {
20 namespace Config {
22 class ConcreteVault;
24 class Parser {
25 private:
26 std::ifstream *m_stream;
28 enum TokenType {
29 WORD,
30 QUOTED_WORD,
31 SYMBOL,
32 END_OF_FILE
34 public:
35 /** Parses a single configuration file.
36 @note Assumes @a configFile is an absolute path.
38 void parse(ConcreteVault *vault, const std::string &configFile);
39 /** Parses a directory's worth of module configuration files.
40 @note Assumes @a directory is absolute.
42 void parseDirectory(ConcreteVault *vault, const std::string &directory);
43 private:
44 void openFile(const std::string &configFile);
45 std::string nextToken(TokenType &type);
46 std::string expectNextToken(TokenType expected);
47 void expectNextSymbol(const std::string &symbol);
48 void skipWhitespace();
49 void closeFile();
51 const char *nameOf(TokenType type) const;
54 } // namespace Config
55 } // namespace Monitor
57 #endif