rvargas@google.com | 73eb5d0 | 2011-03-25 04:00:20 +0900 | [diff] [blame] | 1 | // Copyright (c) 2011 The Chromium Authors. All rights reserved. |
thestig@chromium.org | b6ba943 | 2010-04-03 10:05:39 +0900 | [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 | |
tfarina@chromium.org | 6d36c5d | 2010-08-03 12:00:50 +0900 | [diff] [blame] | 5 | #ifndef BASE_ENVIRONMENT_H_ |
| 6 | #define BASE_ENVIRONMENT_H_ |
thakis@chromium.org | 01d1452 | 2010-07-27 08:08:24 +0900 | [diff] [blame] | 7 | #pragma once |
thestig@chromium.org | b6ba943 | 2010-04-03 10:05:39 +0900 | [diff] [blame] | 8 | |
| 9 | #include <string> |
| 10 | |
rvargas@google.com | 73eb5d0 | 2011-03-25 04:00:20 +0900 | [diff] [blame] | 11 | #include "base/base_api.h" |
jhawkins@chromium.org | 8e73d06 | 2011-04-05 03:04:37 +0900 | [diff] [blame] | 12 | #include "build/build_config.h" |
thestig@chromium.org | b6ba943 | 2010-04-03 10:05:39 +0900 | [diff] [blame] | 13 | |
| 14 | namespace base { |
| 15 | |
tfarina@chromium.org | 49c8f3a | 2010-07-21 11:59:28 +0900 | [diff] [blame] | 16 | namespace env_vars { |
| 17 | |
| 18 | #if defined(OS_POSIX) |
evan@chromium.org | 3e20889 | 2011-05-03 02:54:14 +0900 | [diff] [blame] | 19 | BASE_API extern const char kHome[]; |
tfarina@chromium.org | 49c8f3a | 2010-07-21 11:59:28 +0900 | [diff] [blame] | 20 | #endif |
| 21 | |
| 22 | } // namespace env_vars |
| 23 | |
rvargas@google.com | 73eb5d0 | 2011-03-25 04:00:20 +0900 | [diff] [blame] | 24 | class BASE_API Environment { |
thestig@chromium.org | b6ba943 | 2010-04-03 10:05:39 +0900 | [diff] [blame] | 25 | public: |
tfarina@chromium.org | 6d36c5d | 2010-08-03 12:00:50 +0900 | [diff] [blame] | 26 | virtual ~Environment(); |
erg@chromium.org | 493f5f6 | 2010-07-16 06:03:54 +0900 | [diff] [blame] | 27 | |
tfarina@chromium.org | a512265 | 2010-08-01 01:55:40 +0900 | [diff] [blame] | 28 | // Static factory method that returns the implementation that provide the |
| 29 | // appropriate platform-specific instance. |
tfarina@chromium.org | 6d36c5d | 2010-08-03 12:00:50 +0900 | [diff] [blame] | 30 | static Environment* Create(); |
tfarina@chromium.org | a512265 | 2010-08-01 01:55:40 +0900 | [diff] [blame] | 31 | |
thestig@chromium.org | b6ba943 | 2010-04-03 10:05:39 +0900 | [diff] [blame] | 32 | // Gets an environment variable's value and stores it in |result|. |
| 33 | // Returns false if the key is unset. |
tfarina@chromium.org | 8f115a8 | 2010-08-07 11:57:59 +0900 | [diff] [blame] | 34 | virtual bool GetVar(const char* variable_name, std::string* result) = 0; |
thestig@chromium.org | b6ba943 | 2010-04-03 10:05:39 +0900 | [diff] [blame] | 35 | |
tfarina@chromium.org | 8f115a8 | 2010-08-07 11:57:59 +0900 | [diff] [blame] | 36 | // Syntactic sugar for GetVar(variable_name, NULL); |
tfarina@chromium.org | e7f0559 | 2010-08-05 08:43:20 +0900 | [diff] [blame] | 37 | virtual bool HasVar(const char* variable_name); |
thestig@chromium.org | b6ba943 | 2010-04-03 10:05:39 +0900 | [diff] [blame] | 38 | |
tfarina@chromium.org | a5d6f66 | 2010-07-16 12:34:25 +0900 | [diff] [blame] | 39 | // Returns true on success, otherwise returns false. |
tfarina@chromium.org | 5dc6673 | 2010-08-06 10:03:37 +0900 | [diff] [blame] | 40 | virtual bool SetVar(const char* variable_name, |
tfarina@chromium.org | 08225be | 2010-07-08 22:32:51 +0900 | [diff] [blame] | 41 | const std::string& new_value) = 0; |
| 42 | |
tfarina@chromium.org | a512265 | 2010-08-01 01:55:40 +0900 | [diff] [blame] | 43 | // Returns true on success, otherwise returns false. |
tfarina@chromium.org | 6b2d9cc | 2010-08-04 11:13:34 +0900 | [diff] [blame] | 44 | virtual bool UnSetVar(const char* variable_name) = 0; |
thestig@chromium.org | b6ba943 | 2010-04-03 10:05:39 +0900 | [diff] [blame] | 45 | }; |
| 46 | |
| 47 | } // namespace base |
| 48 | |
tfarina@chromium.org | 6d36c5d | 2010-08-03 12:00:50 +0900 | [diff] [blame] | 49 | #endif // BASE_ENVIRONMENT_H_ |