CrystalSpace

Public API Reference

csutil/verbosity.h

Go to the documentation of this file.
00001 /*
00002     Copyright (C) 2005 by Eric Sunshine <[email protected]>
00003 
00004     This library is free software; you can redistribute it and/or
00005     modify it under the terms of the GNU Library General Public
00006     License as published by the Free Software Foundation; either
00007     version 2 of the License, or (at your option) any later version.
00008 
00009     This library is distributed in the hope that it will be useful,
00010     but WITHOUT ANY WARRANTY; without even the implied warranty of
00011     MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
00012     Library General Public License for more details.
00013 
00014     You should have received a copy of the GNU Library General Public
00015     License along with this library; if not, write to the Free
00016     Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
00017 */
00018 
00019 #ifndef __CS_CSUTIL_VERBOSITY_H__
00020 #define __CS_CSUTIL_VERBOSITY_H__
00021 
00025 #include "csextern.h"
00026 #include "iutil/verbositymanager.h"
00027 #include "csutil/strhash.h"
00028 #include "csutil/csstring.h"
00029 #include "csutil/scf_implementation.h"
00030 class csStringArray;
00031 
00103 class CS_CRYSTALSPACE_EXPORT csVerbosityParser
00104 {
00105 private:
00106   csStringHash flags;
00107 
00108   typedef csStringFast<128> Str;
00109   typedef bool (*SplitPredicate)(char c, size_t pos);
00110   static bool Split(char const*, char delim, SplitPredicate, bool empty_okay,
00111                     csStringArray&);
00112   static Str  Join(csStringArray const&, Str delim);
00113   static bool Error(char const* msg, char const* s, size_t pos);
00114   static bool ParseToggle(char const*&);
00115   static bool ParseFlag(char const*, csStringArray&, bool empty_okay);
00116   bool TestFlag(Str name, bool& enable) const;
00117   void Copy(csVerbosityParser const& v) { flags = v.flags; }
00118 
00119 public:
00134   csVerbosityParser(char const* flags = 0);
00135   
00139   csVerbosityParser(csVerbosityParser const& v) { Copy(v); }
00140 
00144   ~csVerbosityParser() {}
00145 
00149   csVerbosityParser& operator=(csVerbosityParser const& v)
00150   { Copy(v); return *this; }
00151 
00162   void Parse(char const* flags);
00163 
00184   bool Enabled(char const* flag = 0, bool fuzzy = true) const;
00185 
00192   CS_DEPRECATED_METHOD_MSG("Use Enabled() instead")
00193   bool CheckFlag(char const* major, char const* minor) const
00194   {
00195     Str flag; flag << major << '.' << minor;
00196     return Enabled(flag);
00197   }
00198 };
00199 
00219 CS_CRYSTALSPACE_EXPORT csVerbosityParser csParseVerbosity (
00220   int argc, char const* const argv[]);
00221   
00234 CS_CRYSTALSPACE_EXPORT bool csCheckVerbosity (
00235   int argc, char const* const argv[], char const* flag = 0, bool fuzzy = true);
00236   
00244 CS_DEPRECATED_METHOD
00245 CS_CRYSTALSPACE_EXPORT bool csCheckVerbosity (
00246   int argc, char const* const argv[], char const* major, char const* minor);
00247 
00248 #include "csutil/win32/msvc_deprecated_warn_off.h"
00249 
00260 class CS_CRYSTALSPACE_EXPORT csVerbosityManager : 
00261   public scfImplementation1<csVerbosityManager, iVerbosityManager>
00262 {
00263 private:
00264   csVerbosityParser vp;
00265 public:
00266 
00272   csVerbosityManager(char const* flags = 0) 
00273     : scfImplementationType (this), vp(flags)
00274   { }
00276   virtual ~csVerbosityManager() { }
00277 
00283   virtual void Parse(char const* flags) { vp.Parse(flags); }
00284 
00296   virtual bool Enabled(char const* flag = 0, bool fuzzy = true) const
00297   { return vp.Enabled(flag, fuzzy); }
00298 
00305   CS_DEPRECATED_METHOD_MSG("Use Enabled() instead")
00306   virtual bool CheckFlag(char const* major, char const* minor) const
00307   {
00308     csStringFast<128> flag; flag << major << '.' << minor;
00309     return Enabled(flag);
00310   }
00311 };
00312 
00313 #include "csutil/win32/msvc_deprecated_warn_on.h"
00314 
00315 #endif // __CS_CSUTIL_VERBOSITY_H__

Generated for Crystal Space by doxygen 1.4.7