[email protected] | 9bc8cff | 2010-04-03 01:05:39 | [diff] [blame] | 1 | // Copyright (c) 2010 The Chromium Authors. All rights reserved. |
2 | // Use of this source code is governed by a BSD-style license that can be | ||||
3 | // found in the LICENSE file. | ||||
4 | |||||
[email protected] | 76b90d31 | 2010-08-03 03:00:50 | [diff] [blame] | 5 | #ifndef BASE_ENVIRONMENT_H_ |
6 | #define BASE_ENVIRONMENT_H_ | ||||
[email protected] | 32b76ef | 2010-07-26 23:08:24 | [diff] [blame] | 7 | #pragma once |
[email protected] | 9bc8cff | 2010-04-03 01:05:39 | [diff] [blame] | 8 | |
9 | #include <string> | ||||
10 | |||||
11 | #include "base/basictypes.h" | ||||
12 | |||||
13 | namespace base { | ||||
14 | |||||
[email protected] | 574f6f0c | 2010-07-21 02:59:28 | [diff] [blame] | 15 | namespace env_vars { |
16 | |||||
17 | #if defined(OS_POSIX) | ||||
18 | extern const char kHome[]; | ||||
19 | #endif | ||||
20 | |||||
21 | } // namespace env_vars | ||||
22 | |||||
[email protected] | 76b90d31 | 2010-08-03 03:00:50 | [diff] [blame] | 23 | class Environment { |
[email protected] | 9bc8cff | 2010-04-03 01:05:39 | [diff] [blame] | 24 | public: |
[email protected] | 76b90d31 | 2010-08-03 03:00:50 | [diff] [blame] | 25 | virtual ~Environment(); |
[email protected] | 3a3d4747 | 2010-07-15 21:03:54 | [diff] [blame] | 26 | |
[email protected] | fc586c7 | 2010-07-31 16:55:40 | [diff] [blame] | 27 | // Static factory method that returns the implementation that provide the |
28 | // appropriate platform-specific instance. | ||||
[email protected] | 76b90d31 | 2010-08-03 03:00:50 | [diff] [blame] | 29 | static Environment* Create(); |
[email protected] | fc586c7 | 2010-07-31 16:55:40 | [diff] [blame] | 30 | |
[email protected] | 9bc8cff | 2010-04-03 01:05:39 | [diff] [blame] | 31 | // Gets an environment variable's value and stores it in |result|. |
32 | // Returns false if the key is unset. | ||||
33 | virtual bool GetEnv(const char* variable_name, std::string* result) = 0; | ||||
34 | |||||
35 | // Syntactic sugar for GetEnv(variable_name, NULL); | ||||
[email protected] | 9432ade | 2010-08-04 23:43:20 | [diff] [blame] | 36 | virtual bool HasVar(const char* variable_name); |
[email protected] | 9bc8cff | 2010-04-03 01:05:39 | [diff] [blame] | 37 | |
[email protected] | e9032c6 | 2010-07-16 03:34:25 | [diff] [blame] | 38 | // Returns true on success, otherwise returns false. |
[email protected] | c87bcf00 | 2010-08-06 01:03:37 | [diff] [blame^] | 39 | virtual bool SetVar(const char* variable_name, |
[email protected] | ac7264c | 2010-07-08 13:32:51 | [diff] [blame] | 40 | const std::string& new_value) = 0; |
41 | |||||
[email protected] | fc586c7 | 2010-07-31 16:55:40 | [diff] [blame] | 42 | // Returns true on success, otherwise returns false. |
[email protected] | 4fae316 | 2010-08-04 02:13:34 | [diff] [blame] | 43 | virtual bool UnSetVar(const char* variable_name) = 0; |
[email protected] | 9bc8cff | 2010-04-03 01:05:39 | [diff] [blame] | 44 | }; |
45 | |||||
46 | } // namespace base | ||||
47 | |||||
[email protected] | 76b90d31 | 2010-08-03 03:00:50 | [diff] [blame] | 48 | #endif // BASE_ENVIRONMENT_H_ |