blob: 977641897484c1c791a445b3a0bc565e683700f7 [file] [log] [blame]
// Copyright 2018 The Chromium OS Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#ifndef SHILL_SHIMS_ENVIRONMENT_H_
#define SHILL_SHIMS_ENVIRONMENT_H_
#include <map>
#include <string>
#include <base/macros.h>
#include <base/no_destructor.h>
namespace shill {
namespace shims {
// Environment access utilities.
class Environment {
public:
virtual ~Environment();
// This is a singleton -- use Environment::GetInstance()->Foo().
static Environment* GetInstance();
// Sets |value| to the value of environment variable |name| and returns
// true. Returns false if variable |name| is not set.
virtual bool GetVariable(const std::string& name, std::string* value);
// Parses and returns the environment as a name->value string map.
virtual std::map<std::string, std::string> AsMap();
protected:
Environment();
Environment(const Environment&) = delete;
Environment& operator=(const Environment&) = delete;
private:
friend class base::NoDestructor<Environment>;
};
} // namespace shims
} // namespace shill
#endif // SHILL_SHIMS_ENVIRONMENT_H_