diff options
author | unknown <tomas@poseidon.(none)> | 2004-08-27 11:48:27 +0000 |
---|---|---|
committer | unknown <tomas@poseidon.(none)> | 2004-08-27 11:48:27 +0000 |
commit | 987fc113959189c59e8f6e99d8d5364d9d62bc89 (patch) | |
tree | 553669a934f12f62a64ba7fd2729840a40015ef3 /ndb/src/mgmsrv/InitConfigFileParser.hpp | |
parent | 6566af8c3599d6ca6f3110a02d4e8476d386888e (diff) | |
download | mariadb-git-987fc113959189c59e8f6e99d8d5364d9d62bc89.tar.gz |
see respective file
ndb/src/mgmsrv/InitConfigFileParser.hpp:
Rename: ndb/src/common/mgmcommon/InitConfigFileParser.hpp -> ndb/src/mgmsrv/InitConfigFileParser.hpp
ndb/src/mgmsrv/InitConfigFileParser.cpp:
Rename: ndb/src/common/mgmcommon/InitConfigFileParser.cpp -> ndb/src/mgmsrv/InitConfigFileParser.cpp
ndb/src/mgmsrv/ConfigInfo.hpp:
Rename: ndb/src/common/mgmcommon/ConfigInfo.hpp -> ndb/src/mgmsrv/ConfigInfo.hpp
ndb/src/common/mgmcommon/Makefile.am:
moved files to mgmsrv
ndb/src/mgmclient/CommandInterpreter.cpp:
added shutdown command
ndb/src/mgmclient/CommandInterpreter.hpp:
added shutdown command
ndb/src/mgmsrv/Config.cpp:
.
ndb/src/mgmsrv/Config.hpp:
.
ndb/src/mgmsrv/ConfigInfo.cpp:
wait with this
ndb/src/mgmsrv/Makefile.am:
moved files to mgmsrv
ndb/test/include/NdbBackup.hpp:
backup not necessarily in file system path
ndb/test/ndbapi/testDict.cpp:
compile error
ndb/test/src/NdbBackup.cpp:
aligned with new config param
Diffstat (limited to 'ndb/src/mgmsrv/InitConfigFileParser.hpp')
-rw-r--r-- | ndb/src/mgmsrv/InitConfigFileParser.hpp | 127 |
1 files changed, 127 insertions, 0 deletions
diff --git a/ndb/src/mgmsrv/InitConfigFileParser.hpp b/ndb/src/mgmsrv/InitConfigFileParser.hpp new file mode 100644 index 00000000000..1ea0a094ccd --- /dev/null +++ b/ndb/src/mgmsrv/InitConfigFileParser.hpp @@ -0,0 +1,127 @@ +/* Copyright (C) 2003 MySQL AB + + This program is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 2 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program; if not, write to the Free Software + Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ + +#ifndef InitConfigFileParser_H +#define InitConfigFileParser_H + +#include <ndb_global.h> + +#include <Properties.hpp> +#include <ConfigValues.hpp> + +class Config; +class ConfigInfo; + +/** + * @class InitConfigFileParser + * @brief Reads initial config file and returns Config object + * + * This class contains one public method InitConfigFileParser::parseConfig, + * which reads an initial configuration file and returns a Config + * object if the config file has correct syntax and semantic. + */ +class InitConfigFileParser { +public: + /** + * Constructor + */ + InitConfigFileParser(); + ~InitConfigFileParser(); + + /** + * Reads the initial configuration file, checks syntax and semantic + * and stores internally the values of all parameters. + * + * @returns Config or NULL on failure + * @note must be freed by caller + */ + Config * parseConfig(FILE * file); + Config * parseConfig(const char * filename); + + /** + * Parser context struct + */ + enum ContextSectionType { Undefined, Section, DefaultSection }; + + /** + * Context = Which section in init config file we are currently parsing + */ + struct Context { + Context(const ConfigInfo *); + ~Context(); + + ContextSectionType type; ///< Section type (e.g. default section,section) + char fname[256]; ///< Section name occuring in init config file + char pname[256]; ///< Section name stored in properties object + Uint32 m_lineno; ///< Current line no in config file + Uint32 m_sectionLineno; ///< Where did current section start + + const ConfigInfo * m_info; // The config info + Properties * m_config; // The config object + Properties * m_defaults; // The user defaults + + Properties * m_currentSection; // The current section I'm in + const Properties * m_userDefaults; // The defaults of this section + const Properties * m_systemDefaults; // The syst. defaults for this section + const Properties * m_currentInfo; // The "info" for this section + + Properties m_userProperties; // User properties (temporary values) + ConfigValuesFactory m_configValues; // + + public: + void reportError(const char * msg, ...); + void reportWarning(const char * msg, ...); + }; + + static bool convertStringToUint64(const char* s, Uint64& val, Uint32 log10base = 0); + static bool convertStringToBool(const char* s, bool& val); + +private: + /** + * Check if line only contains space/comments + * @param line: The line to check + * @return true if spaces/comments only, false otherwise + */ + bool isEmptyLine(const char* line) const; + + /** + * Checks if line contains a section header + * @param line: String to search + * @return section header if matching some section header, NULL otherwise + */ + char* parseSectionHeader(const char* line) const; + + /** + * Checks if line contains a default header + * @param line: String to search + * @return section header if matching some section header, NULL otherwise + */ + char* parseDefaultSectionHeader(const char* line) const; + + bool parseNameValuePair(Context&, const char* line); + bool storeNameValuePair(Context&, const char* fname, const char* value); + + bool storeSection(Context&); + + const Properties* getSection(const char * name, const Properties* src); + + /** + * Information about parameters (min, max values etc) + */ + ConfigInfo* m_info; +}; + +#endif // InitConfigFileParser_H |