OW_EnvVars.hpp

Go to the documentation of this file.
00001 /*******************************************************************************
00002 * Copyright (C) 2005 Novell, Inc. All rights reserved.
00003 *
00004 * Redistribution and use in source and binary forms, with or without
00005 * modification, are permitted provided that the following conditions are met:
00006 *
00007 *  - Redistributions of source code must retain the above copyright notice,
00008 *    this list of conditions and the following disclaimer.
00009 *
00010 *  - Redistributions in binary form must reproduce the above copyright notice,
00011 *    this list of conditions and the following disclaimer in the documentation
00012 *    and/or other materials provided with the distribution.
00013 *
00014 *  - Neither the name of Novell, Inc., nor the names of its
00015 *    contributors may be used to endorse or promote products derived from this
00016 *    software without specific prior written permission.
00017 *
00018 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS ``AS IS''
00019 * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
00020 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
00021 * ARE DISCLAIMED. IN NO EVENT SHALL Novell, Inc., OR THE 
00022 * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, 
00023 * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, 
00024 * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; 
00025 * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, 
00026 * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR 
00027 * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF 
00028 * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
00029 *******************************************************************************/
00030 
00035 #ifndef OW_ENVVARS_HPP__
00036 #define OW_ENVVARS_HPP__
00037 
00038 #include "OW_config.h"
00039 #include "OW_Map.hpp"
00040 #include "OW_String.hpp"
00041 
00042 namespace OW_NAMESPACE
00043 {
00044 
00048 class OW_COMMON_API EnvVars
00049 {
00050 public:
00051    enum EEnvVarFlag
00052    {
00053       E_CURRENT_ENVIRONMENT,
00054       E_EMPTY_ENVIRONMENT
00055    };
00056 
00061    EnvVars(EEnvVarFlag flag=E_EMPTY_ENVIRONMENT);
00069    EnvVars(const char* const envp[]);
00074    EnvVars(const EnvVars& arg);
00078    ~EnvVars();
00085    EnvVars& operator= (const EnvVars& arg);
00091    const char* const* getenvp() const;
00096    size_t size() const
00097    {
00098       return m_envMap.size();
00099    }
00109    String getValue(const String& key, const String& notFoundRetVal=String()) const;
00110 
00116    bool removeVar(const String& key);
00117 
00124    void setVar(const String& keyValue);
00125 
00132    void setVar(const String& key, const String& value);
00133 
00138    bool addVar(const String& name, const String& value);
00139 
00144    bool updateVar(const String& name, const String& value);
00145 
00146 private:
00147    typedef Map<String, String> EnvMap;
00148 
00149    void deleteEnvp() const;
00150    static void fillEnvMap(const char* const envp[], EnvMap& envMap);
00151 
00152    EnvMap m_envMap;
00153    mutable char** m_envp;
00154 };
00155 
00156 }  // End of OW_NAMESPACE
00157 
00158 #endif   // OW_ENVVARS_HPP__

Generated on Thu Feb 9 08:47:59 2006 for openwbem by  doxygen 1.4.6