blob: ac83de37108651e98e315698b6a7723277f1f437 [file] [log] [blame]
[email protected]9bc8cff2010-04-03 01:05:391// 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]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
11#include "base/basictypes.h"
12
13namespace base {
14
[email protected]574f6f0c2010-07-21 02:59:2815namespace env_vars {
16
17#if defined(OS_POSIX)
18extern const char kHome[];
19#endif
20
21} // namespace env_vars
22
[email protected]76b90d312010-08-03 03:00:5023class Environment {
[email protected]9bc8cff2010-04-03 01:05:3924 public:
[email protected]76b90d312010-08-03 03:00:5025 virtual ~Environment();
[email protected]3a3d47472010-07-15 21:03:5426
[email protected]fc586c72010-07-31 16:55:4027 // Static factory method that returns the implementation that provide the
28 // appropriate platform-specific instance.
[email protected]76b90d312010-08-03 03:00:5029 static Environment* Create();
[email protected]fc586c72010-07-31 16:55:4030
[email protected]9bc8cff2010-04-03 01:05:3931 // 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]9432ade2010-08-04 23:43:2036 virtual bool HasVar(const char* variable_name);
[email protected]9bc8cff2010-04-03 01:05:3937
[email protected]e9032c62010-07-16 03:34:2538 // Returns true on success, otherwise returns false.
[email protected]c87bcf002010-08-06 01:03:3739 virtual bool SetVar(const char* variable_name,
[email protected]ac7264c2010-07-08 13:32:5140 const std::string& new_value) = 0;
41
[email protected]fc586c72010-07-31 16:55:4042 // Returns true on success, otherwise returns false.
[email protected]4fae3162010-08-04 02:13:3443 virtual bool UnSetVar(const char* variable_name) = 0;
[email protected]9bc8cff2010-04-03 01:05:3944};
45
46} // namespace base
47
[email protected]76b90d312010-08-03 03:00:5048#endif // BASE_ENVIRONMENT_H_