csutil/verbosity.h Source File (Crystal Space 2.0 Public API Reference)

| ## Public API Reference

- Main Page
- Related Pages
- Modules
- Namespaces
- Classes
- Files

- File List
- File Members

csutil/verbosity.h
Go to the documentation of this file.

    00001 /*
    00002     Copyright (C) 2005 by Eric Sunshine <sunshine@sunshineco.com>
    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 };
    00186
    00206 CS_CRYSTALSPACE_EXPORT csVerbosityParser csParseVerbosity (
    00207   int argc, char const* const argv[]);
    00208
    00221 CS_CRYSTALSPACE_EXPORT bool csCheckVerbosity (
    00222   int argc, char const* const argv[], char const* flag = 0, bool fuzzy = true);
    00223
    00231 CS_DEPRECATED_METHOD
    00232 CS_CRYSTALSPACE_EXPORT bool csCheckVerbosity (
    00233   int argc, char const* const argv[], char const* major, char const* minor);
    00234
    00235 #include "csutil/deprecated_warn_off.h"
    00236
    00247 class CS_CRYSTALSPACE_EXPORT csVerbosityManager :
    00248   public scfImplementation1<csVerbosityManager, iVerbosityManager>
    00249 {
    00250 private:
    00251   csVerbosityParser vp;
    00252 public:
    00253
    00259   csVerbosityManager(char const* flags = 0)
    00260     : scfImplementationType (this), vp(flags)
    00261   { }
    00263   virtual ~csVerbosityManager() { }
    00264
    00270   virtual void Parse(char const* flags) { vp.Parse(flags); }
    00271
    00283   virtual bool Enabled(char const* flag = 0, bool fuzzy = true) const
    00284   { return vp.Enabled(flag, fuzzy); }
    00285
    00286 };
    00287
    00288 #include "csutil/deprecated_warn_on.h"
    00289
    00290 #endif // __CS_CSUTIL_VERBOSITY_H__