blob: ebad820e5f7b38237208388e88a9f37a2611aafa [file] [log] [blame]
[email protected]f5661ca2011-03-24 19:00:201// Copyright (c) 2011 The Chromium Authors. All rights reserved.
[email protected]9bc8cff2010-04-03 01:05:392// Use of this source code is governed by a BSD-style license that can be
3// found in the LICENSE file.
4
[email protected]76b90d312010-08-03 03:00:505#ifndef BASE_ENVIRONMENT_H_
6#define BASE_ENVIRONMENT_H_
[email protected]32b76ef2010-07-26 23:08:247#pragma once
[email protected]9bc8cff2010-04-03 01:05:398
9#include <string>
10
[email protected]f5661ca2011-03-24 19:00:2011#include "base/base_api.h"
[email protected]9bc8cff2010-04-03 01:05:3912#include "base/basictypes.h"
13
14namespace base {
15
[email protected]574f6f0c2010-07-21 02:59:2816namespace env_vars {
17
18#if defined(OS_POSIX)
19extern const char kHome[];
20#endif
21
22} // namespace env_vars
23
[email protected]f5661ca2011-03-24 19:00:2024class BASE_API Environment {
[email protected]9bc8cff2010-04-03 01:05:3925 public:
[email protected]76b90d312010-08-03 03:00:5026 virtual ~Environment();
[email protected]3a3d47472010-07-15 21:03:5427
[email protected]fc586c72010-07-31 16:55:4028 // Static factory method that returns the implementation that provide the
29 // appropriate platform-specific instance.
[email protected]76b90d312010-08-03 03:00:5030 static Environment* Create();
[email protected]fc586c72010-07-31 16:55:4031
[email protected]9bc8cff2010-04-03 01:05:3932 // Gets an environment variable's value and stores it in |result|.
33 // Returns false if the key is unset.
[email protected]3ba7e082010-08-07 02:57:5934 virtual bool GetVar(const char* variable_name, std::string* result) = 0;
[email protected]9bc8cff2010-04-03 01:05:3935
[email protected]3ba7e082010-08-07 02:57:5936 // Syntactic sugar for GetVar(variable_name, NULL);
[email protected]9432ade2010-08-04 23:43:2037 virtual bool HasVar(const char* variable_name);
[email protected]9bc8cff2010-04-03 01:05:3938
[email protected]e9032c62010-07-16 03:34:2539 // Returns true on success, otherwise returns false.
[email protected]c87bcf002010-08-06 01:03:3740 virtual bool SetVar(const char* variable_name,
[email protected]ac7264c2010-07-08 13:32:5141 const std::string& new_value) = 0;
42
[email protected]fc586c72010-07-31 16:55:4043 // Returns true on success, otherwise returns false.
[email protected]4fae3162010-08-04 02:13:3444 virtual bool UnSetVar(const char* variable_name) = 0;
[email protected]9bc8cff2010-04-03 01:05:3945};
46
47} // namespace base
48
[email protected]76b90d312010-08-03 03:00:5049#endif // BASE_ENVIRONMENT_H_