view libvtv/testsuite/libvtv.cc/environment.cc @ 158:494b0b89df80 default tip

...
author Shinji KONO <kono@ie.u-ryukyu.ac.jp>
date Mon, 25 May 2020 18:13:55 +0900
parents 04ced10e8804
children
line wrap: on
line source

// { dg-do run }

extern "C" int printf(const char *, ...);

class Environment {
 public:
  virtual ~Environment();

  // Static factory method that returns the implementation that provide the
  // appropriate platform-specific instance.
  static Environment* Create();

  // Gets an environment variable's value and stores it in |result|.
  // Returns false if the key is unset.
  virtual bool GetVar(const char* variable_name, char* result) = 0;
};

class EnvironmentImpl : public Environment {
 public:
  virtual bool GetVar(const char* variable_name, char* result) {
      return true;
  }
};

Environment::~Environment() {}

// static
Environment* Environment::Create() {
  return new EnvironmentImpl();
}

int main()
{
  char * null = 0;
  Environment * env = Environment::Create();
  env->GetVar(0, null);
  printf("%p\n", env);
}