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