blob: cf71724e64841521cf4a58816af750d816d70132 [file] [log] [blame]
rvargas@google.com73eb5d02011-03-25 04:00:20 +09001// Copyright (c) 2011 The Chromium Authors. All rights reserved.
thestig@chromium.orgb6ba9432010-04-03 10:05:39 +09002// Use of this source code is governed by a BSD-style license that can be
3// found in the LICENSE file.
4
tfarina@chromium.org6d36c5d2010-08-03 12:00:50 +09005#ifndef BASE_ENVIRONMENT_H_
6#define BASE_ENVIRONMENT_H_
thakis@chromium.org01d14522010-07-27 08:08:24 +09007#pragma once
thestig@chromium.orgb6ba9432010-04-03 10:05:39 +09008
9#include <string>
10
rvargas@google.com73eb5d02011-03-25 04:00:20 +090011#include "base/base_api.h"
jhawkins@chromium.org8e73d062011-04-05 03:04:37 +090012#include "build/build_config.h"
thestig@chromium.orgb6ba9432010-04-03 10:05:39 +090013
14namespace base {
15
tfarina@chromium.org49c8f3a2010-07-21 11:59:28 +090016namespace env_vars {
17
18#if defined(OS_POSIX)
19extern const char kHome[];
20#endif
21
22} // namespace env_vars
23
rvargas@google.com73eb5d02011-03-25 04:00:20 +090024class BASE_API Environment {
thestig@chromium.orgb6ba9432010-04-03 10:05:39 +090025 public:
tfarina@chromium.org6d36c5d2010-08-03 12:00:50 +090026 virtual ~Environment();
erg@chromium.org493f5f62010-07-16 06:03:54 +090027
tfarina@chromium.orga5122652010-08-01 01:55:40 +090028 // Static factory method that returns the implementation that provide the
29 // appropriate platform-specific instance.
tfarina@chromium.org6d36c5d2010-08-03 12:00:50 +090030 static Environment* Create();
tfarina@chromium.orga5122652010-08-01 01:55:40 +090031
thestig@chromium.orgb6ba9432010-04-03 10:05:39 +090032 // Gets an environment variable's value and stores it in |result|.
33 // Returns false if the key is unset.
tfarina@chromium.org8f115a82010-08-07 11:57:59 +090034 virtual bool GetVar(const char* variable_name, std::string* result) = 0;
thestig@chromium.orgb6ba9432010-04-03 10:05:39 +090035
tfarina@chromium.org8f115a82010-08-07 11:57:59 +090036 // Syntactic sugar for GetVar(variable_name, NULL);
tfarina@chromium.orge7f05592010-08-05 08:43:20 +090037 virtual bool HasVar(const char* variable_name);
thestig@chromium.orgb6ba9432010-04-03 10:05:39 +090038
tfarina@chromium.orga5d6f662010-07-16 12:34:25 +090039 // Returns true on success, otherwise returns false.
tfarina@chromium.org5dc66732010-08-06 10:03:37 +090040 virtual bool SetVar(const char* variable_name,
tfarina@chromium.org08225be2010-07-08 22:32:51 +090041 const std::string& new_value) = 0;
42
tfarina@chromium.orga5122652010-08-01 01:55:40 +090043 // Returns true on success, otherwise returns false.
tfarina@chromium.org6b2d9cc2010-08-04 11:13:34 +090044 virtual bool UnSetVar(const char* variable_name) = 0;
thestig@chromium.orgb6ba9432010-04-03 10:05:39 +090045};
46
47} // namespace base
48
tfarina@chromium.org6d36c5d2010-08-03 12:00:50 +090049#endif // BASE_ENVIRONMENT_H_