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