From: <sv...@ww...> - 2004-09-26 07:49:51
|
Author: mkrose Date: 2004-09-26 00:49:34 -0700 (Sun, 26 Sep 2004) New Revision: 1254 Modified: trunk/CSP/SimCore/Util/SConscript trunk/CSP/SimCore/Util/SimpleConfig.cpp trunk/CSP/SimCore/Util/SimpleConfig.h Log: Fix include paths and minor cleanups; add SimpleConfig to build under SimCore. Browse at: https://www.zerobar.net/viewcvs/viewcvs.cgi?view=rev&rev=1254 Modified: trunk/CSP/SimCore/Util/SConscript =================================================================== --- trunk/CSP/SimCore/Util/SConscript 2004-09-26 07:43:00 UTC (rev 1253) +++ trunk/CSP/SimCore/Util/SConscript 2004-09-26 07:49:34 UTC (rev 1254) @@ -19,6 +19,7 @@ Import('env build') SOURCES = [ + 'SimpleConfig.cpp', 'StringTools.cpp', 'SynchronousUpdate.cpp' ] Modified: trunk/CSP/SimCore/Util/SimpleConfig.cpp =================================================================== --- trunk/CSP/SimCore/Util/SimpleConfig.cpp 2004-09-26 07:43:00 UTC (rev 1253) +++ trunk/CSP/SimCore/Util/SimpleConfig.cpp 2004-09-26 07:49:34 UTC (rev 1254) @@ -1,17 +1,17 @@ -// Combat Simulator Project - FlightSim Demo -// Copyright (C) 2002 The Combat Simulator Project +// Combat Simulator Project +// Copyright (C) 2002, 2004 The Combat Simulator Project // http://csp.sourceforge.net -// +// // 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. @@ -22,7 +22,7 @@ * * There are a number of aspects of these classes that are not ideal, * however the interface is simple enough to be stable and the - * implementation can be "purified" later (if desired) without + * implementation can be "purified" later (if desired) without * affecting its use. * * @author Mark Rose <mr...@st...> @@ -36,7 +36,7 @@ #define snprintf _snprintf #endif -#include "SimpleConfig.h" +#include <SimCore/Util/SimpleConfig.h> #include <algorithm> #include <string> @@ -93,7 +93,7 @@ // class ConfigError -ConfigError::ConfigError(const std::string &msg, const std::string &filename, +ConfigError::ConfigError(const std::string &msg, const std::string &filename, int line_no, const std::string &line): Error(msg) { char lstr[20]; @@ -115,7 +115,7 @@ public: ConfigElement() {} virtual ~ConfigElement() {} - virtual void write(std::ostream &os) const {} + virtual void write(std::ostream &) const {} }; // internal class for storing config comments @@ -282,7 +282,7 @@ std::string value = Trim(line.substr(eq+1)); _addValue(section, key, value); } - } + } } } @@ -301,7 +301,7 @@ ConfigValue *v = _find(section, key); if (v) { return atoi(v->getValue().c_str()); - } else + } else if (set) { setInt(section, key, default_); } @@ -317,7 +317,7 @@ } else { return false; } - } else + } else if (set) { setBool(section, key, default_); } @@ -329,7 +329,7 @@ ConfigValue *v = _find(section, key); if (v) { return atof(v->getValue().c_str()); - } else + } else if (set) { setFloat(section, key, default_); } @@ -341,7 +341,7 @@ ConfigValue *v = _find(section, key); if (v) { return v->getValue(); - } else + } else if (set) { setString(section, key, default_); } @@ -353,7 +353,7 @@ std::string native = simdata::ospath::filter(default_); if (v) { return simdata::ospath::filter(v->getValue()); - } else + } else if (set) { setString(section, key, native); } @@ -471,8 +471,8 @@ // This is a rather ugly and slow way to delete a section. It // can leave stay comments in the middle of sections, but will // remove the section entirely, even if it is multiply declared. -// This whole function was a bit of an afterthought, since it -// isn't very likely to be used in the application this class +// This whole function was a bit of an afterthought, since it +// isn't very likely to be used in the application this class // was written for. Sorry to all the purists out there. :-( void SimpleConfig::delSection(std::string const §ion_name) { ConfigDictionary::iterator i = m_last.find(section_name); Modified: trunk/CSP/SimCore/Util/SimpleConfig.h =================================================================== --- trunk/CSP/SimCore/Util/SimpleConfig.h 2004-09-26 07:43:00 UTC (rev 1253) +++ trunk/CSP/SimCore/Util/SimpleConfig.h 2004-09-26 07:49:34 UTC (rev 1254) @@ -1,17 +1,17 @@ -// Combat Simulator Project - FlightSim Demo -// Copyright (C) 2002 The Combat Simulator Project +// Combat Simulator Project +// Copyright (C) 2002, 2004 The Combat Simulator Project // http://csp.sourceforge.net -// +// // 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. @@ -22,15 +22,15 @@ * * There are a number of aspects of these classes that are not ideal, * however the interface is simple enough to be stable and the - * implementation can be "purified" later (if desired) without + * implementation can be "purified" later (if desired) without * affecting its use. * * @author Mark Rose <mr...@st...> */ -#ifndef __SIMPLECONFIG_H__ -#define __SIMPLECONFIG_H__ +#ifndef __SIMCORE_UTIL_SIMPLECONFIG_H__ +#define __SIMCORE_UTIL_SIMPLECONFIG_H__ # if defined(_MSC_VER) && (_MSC_VER <= 1200) #pragma warning (disable : 4786) @@ -46,7 +46,7 @@ /** * Basic exception class. * - * The error message will automatically be dumped to stderr when the object + * The error message will automatically be dumped to stderr when the object * is destroyed unless the clear() method is called. * * @author Mark Rose <mr...@st...> @@ -64,7 +64,7 @@ * Maybe a little too fancy, but the clear() is needed so that * multiple automatic copies yield only a single error message. */ - Error(const Error &e): m_msg(e.m_msg), + Error(const Error &e): m_msg(e.m_msg), m_fullerror(e.m_fullerror), m_display(e.m_display) { e.clear(); } @@ -108,7 +108,7 @@ /** * Set the error information. */ - ConfigError(const std::string &msg, const std::string &filename, + ConfigError(const std::string &msg, const std::string &filename, int line_no, const std::string &line); /** @@ -146,7 +146,7 @@ * * This will often be created as a global object so that configuration * data can be accessed and saved throughout the program. - * + * * @author Mark Rose <mr...@st...> */ class SimpleConfig { @@ -198,7 +198,7 @@ void addComment(const std::string &comment); /** - * Open a new configuration file. Any changes to the previous file are saved + * Open a new configuration file. Any changes to the previous file are saved * first. */ bool open(const std::string &fn); @@ -364,8 +364,8 @@ ConfigDictionary m_dict, m_last; ElementList m_elements; - void _addComment(const std::string &comment); - void _addSection(const std::string §ion); + void _addComment(const std::string &comment); + void _addSection(const std::string §ion); std::string _hash_index(const std::string §ion, const std::string &key) const; void _addValue(const std::string §ion, const std::string &key, const std::string &value); void _parse(std::istream &is); @@ -374,5 +374,5 @@ }; -#endif // __SIMPLECONFIG_H__ +#endif // __SIMCORE_UTIL_SIMPLECONFIG_H__ |