Toshihiro Shimizu 890ddd
#include "tenv.h"
Toshihiro Shimizu 890ddd
#include "tsystem.h"
Toshihiro Shimizu 890ddd
#include "tconvert.h"
Toshihiro Shimizu 890ddd
#include "tfilepath_io.h"
shun-iwasawa f39ea0
#include "tversion.h"
Toshihiro Shimizu 890ddd
Campbell Barton e6d9f6
#include <qdir></qdir>
Toshihiro Shimizu 890ddd
#include <qsettings></qsettings>
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
#ifdef LEVO_MACOSX
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
#include "macofflinegl.h"
Toshihiro Shimizu 890ddd
#include "tofflinegl.h"
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
// Imposto l'offlineGL usando AGL (per togliere la dipendenza da X)
Toshihiro Shimizu 890ddd
Shinya Kitaoka 120a6e
TOfflineGL::Imp *MacOfflineGenerator1(const TDimension &dim) {
Shinya Kitaoka 120a6e
  return new MacImplementation(dim);
Toshihiro Shimizu 890ddd
}
Toshihiro Shimizu 890ddd
#endif
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
#include <map></map>
tomosu eea0ac
#include <sstream></sstream>
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
using namespace TEnv;
shun-iwasawa f39ea0
using namespace TVER;
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
//=========================================================
Toshihiro Shimizu 890ddd
//
Toshihiro Shimizu 890ddd
// root dir
Toshihiro Shimizu 890ddd
//
Toshihiro Shimizu 890ddd
//=========================================================
Toshihiro Shimizu 890ddd
Shinya Kitaoka 120a6e
namespace {
shun-iwasawa e3b189
const std::map<std::string, std::string=""> systemPathMap{</std::string,>
shun-iwasawa 7f4819
    {"LIBRARY", "library"}, {"STUDIOPALETTE", "studiopalette"},
shun-iwasawa 7f4819
    {"FXPRESETS", "fxs"},   {"PROFILES", "profiles"},
shun-iwasawa 7f4819
    {"CONFIG", "config"},   {"PROJECTS", "projects"}};
Toshihiro Shimizu 890ddd
Shinya Kitaoka 120a6e
class EnvGlobals {  // singleton
Toshihiro Shimizu 890ddd
shun-iwasawa f39ea0
  ToonzVersion m_version;
manongjohn fba662
  std::string m_applicationFileName;  // May differ from application name
Shinya Kitaoka 120a6e
  std::string m_applicationVersion;
Shinya Kitaoka 120a6e
  std::string m_applicationFullName;
Shinya Kitaoka 120a6e
  std::string m_moduleName;
Shinya Kitaoka 120a6e
  std::string m_rootVarName;
Shinya Kitaoka 120a6e
  std::string m_systemVarPrefix;
Jeremy Bullock 46512f
  std::string m_workingDirectory;
Shinya Kitaoka 120a6e
  TFilePath m_registryRoot;
Shinya Kitaoka 120a6e
  TFilePath m_envFile;
Shinya Kitaoka 120a6e
  TFilePath *m_stuffDir;
Shinya Kitaoka 120a6e
  TFilePath *m_dllRelativeDir;
Jeremy Bullock 46512f
  bool m_isPortable = false;
Toshihiro Shimizu 890ddd
shun-iwasawa e3b189
  // path values specified with command line arguments
shun-iwasawa e3b189
  std::map<std::string, std::string=""> m_argPathValues;</std::string,>
shun-iwasawa e3b189
shun-iwasawa f39ea0
  EnvGlobals() : m_stuffDir(0) {
shun-iwasawa f39ea0
    setWorkingDirectory();
shun-iwasawa f39ea0
    init();
shun-iwasawa f39ea0
  }
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
public:
Shinya Kitaoka 120a6e
  ~EnvGlobals() { delete m_stuffDir; }
Toshihiro Shimizu 890ddd
Shinya Kitaoka 120a6e
  static EnvGlobals *instance() {
Shinya Kitaoka 120a6e
    static EnvGlobals _instance;
Shinya Kitaoka 120a6e
    return &_instance;
Shinya Kitaoka 120a6e
  }
Toshihiro Shimizu 890ddd
Shinya Kitaoka 120a6e
  TFilePath getSystemVarPath(std::string varName) {
Shinya Kitaoka 9f5a1b
#ifdef _WIN32
Shinya Kitaoka 120a6e
    return m_registryRoot + varName;
Toshihiro Shimizu 890ddd
#else
Shinya Kitaoka 120a6e
    QString settingsPath;
Campbell Barton e6d9f6
Campbell Barton e6d9f6
#ifdef MACOSX
manongjohn fba662
    settingsPath = QString::fromStdString(getApplicationFileName()) +
shun-iwasawa f39ea0
                   QString(".app") +
shun-iwasawa f39ea0
                   QString("/Contents/Resources/SystemVar.ini");
Shinya Kitaoka 120a6e
#else /* Generic Unix */
Shinya Kitaoka 120a6e
    // TODO: use QStandardPaths::ConfigLocation when we drop Qt4
Shinya Kitaoka 120a6e
    settingsPath = QDir::homePath();
Shinya Kitaoka 120a6e
    settingsPath.append("/.config/");
Shinya Kitaoka 120a6e
    settingsPath.append(getApplicationName().c_str());
Shinya Kitaoka 120a6e
    settingsPath.append("/SystemVar.ini");
Campbell Barton e6d9f6
#endif
Campbell Barton e6d9f6
Shinya Kitaoka 120a6e
    QSettings settings(settingsPath, QSettings::IniFormat);
Shinya Kitaoka 120a6e
    QString qStr      = QString::fromStdString(varName);
Shinya Kitaoka 120a6e
    QString systemVar = settings.value(qStr).toString();
Shinya Kitaoka 120a6e
    // printf("getSystemVarPath: path:%s key:%s var:%s\n",
Shinya Kitaoka 120a6e
    // settingsPath.toStdString().data(), varName.data(),
Shinya Kitaoka 120a6e
    // systemVar.toStdString().data());
Shinya Kitaoka 120a6e
    return TFilePath(systemVar.toStdWString());
Toshihiro Shimizu 890ddd
#endif
Shinya Kitaoka 120a6e
  }
Toshihiro Shimizu 890ddd
Shinya Kitaoka 120a6e
  TFilePath getRootVarPath() { return getSystemVarPath(m_rootVarName); }
Toshihiro Shimizu 890ddd
Shinya Kitaoka 120a6e
  std::string getSystemVarValue(std::string varName) {
shun-iwasawa e3b189
    if (getIsPortable()) return "";
Shinya Kitaoka 9f5a1b
#ifdef _WIN32
Shinya Kitaoka 120a6e
    return TSystem::getSystemValue(getSystemVarPath(varName)).toStdString();
Toshihiro Shimizu 890ddd
#else
Shinya Kitaoka 120a6e
    TFilePath systemVarPath = getSystemVarPath(varName);
Shinya Kitaoka 120a6e
    if (systemVarPath.isEmpty()) {
Shinya Kitaoka 120a6e
      std::cout << "varName:" << varName << " TOONZROOT not set..."
Shinya Kitaoka 120a6e
                << std::endl;
Shinya Kitaoka 120a6e
      return "";
Shinya Kitaoka 120a6e
    }
Shinya Kitaoka 120a6e
    return ::to_string(systemVarPath);
Toshihiro Shimizu 890ddd
/*
Shinya Kitaoka 120a6e
                        char *value = getenv(varName.c_str());
Shinya Kitaoka 120a6e
                        if (!value)
Shinya Kitaoka 120a6e
                                {
Shinya Kitaoka 120a6e
                                std::cout << varName << " not set, returning
Shinya Kitaoka 120a6e
   TOONZROOT" << std::endl;
Toshihiro Shimizu 890ddd
        //value = getenv("TOONZROOT");
Toshihiro Shimizu 890ddd
                        value="";
Toshihiro Shimizu 890ddd
                        std::cout << "!!!value= "<< value << std::endl;
Shinya Kitaoka 120a6e
                        if (!value)
Shinya Kitaoka 120a6e
                                        {
Shinya Kitaoka 120a6e
                                        std::cout << varName << "TOONZROOT not
Shinya Kitaoka 120a6e
   set..." << std::endl;
Shinya Kitaoka 120a6e
                                        //exit(-1);
Shinya Kitaoka 120a6e
                                        return "";
Shinya Kitaoka 120a6e
                                        }
Shinya Kitaoka 120a6e
                                }
Toshihiro Shimizu 890ddd
      return string(value);
Shinya Kitaoka 120a6e
        */
Toshihiro Shimizu 890ddd
#endif
Shinya Kitaoka 120a6e
  }
Shinya Kitaoka 120a6e
shun-iwasawa f39ea0
  TFilePath getSystemVarPathValue(std::string varName) {
shun-iwasawa f39ea0
    // return if the path is registered by command line argument
shun-iwasawa f39ea0
    std::string argVar = getArgPathValue(varName);
shun-iwasawa f39ea0
    if (argVar != "") return TFilePath(argVar);
shun-iwasawa f39ea0
    return TFilePath(getSystemVarValue(varName));
shun-iwasawa f39ea0
  }
shun-iwasawa f39ea0
Shinya Kitaoka 120a6e
  TFilePath getStuffDir() {
Shinya Kitaoka 120a6e
    if (m_stuffDir) return *m_stuffDir;
Jeremy Bullock 46512f
    if (m_isPortable)
Jeremy Bullock 46512f
      return TFilePath((getWorkingDirectory() + "\\portablestuff\\"));
Jeremy Bullock 46512f
Shinya Kitaoka 120a6e
    return TFilePath(getSystemVarValue(m_rootVarName));
Shinya Kitaoka 120a6e
  }
Shinya Kitaoka 120a6e
  void setStuffDir(const TFilePath &stuffDir) {
Shinya Kitaoka 120a6e
    delete m_stuffDir;
Shinya Kitaoka 120a6e
    m_stuffDir = new TFilePath(stuffDir);
Shinya Kitaoka 120a6e
  }
Shinya Kitaoka 120a6e
Shinya Kitaoka 120a6e
  void updateEnvFile() {
Shinya Kitaoka 120a6e
    TFilePath profilesDir =
Shinya Kitaoka 120a6e
        getSystemVarPathValue(getSystemVarPrefix() + "PROFILES");
shun-iwasawa e3b189
    if (profilesDir == TFilePath())
shun-iwasawa e3b189
      profilesDir = getStuffDir() + systemPathMap.at("PROFILES");
Shinya Kitaoka 120a6e
    m_envFile =
Shinya Kitaoka 120a6e
        profilesDir + "env" + (TSystem::getUserName().toStdString() + ".env");
Shinya Kitaoka 120a6e
  }
Shinya Kitaoka 120a6e
shun-iwasawa f39ea0
  void init() {
shun-iwasawa f39ea0
    if (m_version.getAppRevision() != 0) {
shun-iwasawa f39ea0
      m_applicationVersion = m_version.getAppVersionString() + "." +
shun-iwasawa f39ea0
                             m_version.getAppRevisionString();
Shinya Kitaoka 120a6e
    } else {
shun-iwasawa f39ea0
      m_applicationVersion = m_version.getAppVersionString();
Shinya Kitaoka 120a6e
    }
shun-iwasawa f39ea0
shun-iwasawa f39ea0
    m_applicationFullName = m_version.getAppName() + " " + m_applicationVersion;
13b034
    if (m_version.hasAppNote())
13b034
      m_applicationFullName += " " + m_version.getAppNote();
shun-iwasawa 4d00d0
shun-iwasawa 4d00d0
    m_moduleName  = m_version.getAppName();
shun-iwasawa 4d00d0
    m_rootVarName = toUpper(m_version.getAppName()) + "ROOT";
Shinya Kitaoka 9f5a1b
#ifdef _WIN32
shun-iwasawa f39ea0
    // from v1.3, registry root is moved to SOFTWARE\\OpenToonz\\OpenToonz
shun-iwasawa f39ea0
    m_registryRoot =
shun-iwasawa f39ea0
        TFilePath("SOFTWARE\\OpenToonz\\") + m_version.getAppName();
Toshihiro Shimizu 890ddd
#endif
shun-iwasawa f39ea0
    m_systemVarPrefix = m_version.getAppName();
Shinya Kitaoka 120a6e
    updateEnvFile();
Shinya Kitaoka 120a6e
  }
Shinya Kitaoka 120a6e
manongjohn fba662
  void setApplicationFileName(std::string appFileName) {
manongjohn fba662
    m_applicationFileName = appFileName;
manongjohn e4c3c8
    setWorkingDirectory();
manongjohn fba662
  }
manongjohn fba662
  std::string getApplicationFileName() { return m_applicationFileName; }
shun-iwasawa f39ea0
  std::string getApplicationName() { return m_version.getAppName(); }
Shinya Kitaoka 120a6e
  std::string getApplicationVersion() { return m_applicationVersion; }
Shinya Kitaoka 120a6e
  std::string getApplicationVersionWithoutRevision() {
shun-iwasawa f39ea0
    return m_version.getAppVersionString();
Shinya Kitaoka 120a6e
  }
Shinya Kitaoka 120a6e
Shinya Kitaoka 120a6e
  TFilePath getEnvFile() { return m_envFile; }
shun_iwasawa 3e2518
  TFilePath getTemplateEnvFile() {
shun_iwasawa 3e2518
    return m_envFile.getParentDir() + TFilePath("template.env");
shun_iwasawa 3e2518
  }
Shinya Kitaoka 120a6e
Shinya Kitaoka 120a6e
  void setApplicationFullName(std::string applicationFullName) {
Shinya Kitaoka 120a6e
    m_applicationFullName = applicationFullName;
Shinya Kitaoka 120a6e
  }
Shinya Kitaoka 120a6e
  std::string getApplicationFullName() { return m_applicationFullName; }
Shinya Kitaoka 120a6e
Shinya Kitaoka 120a6e
  void setModuleName(std::string moduleName) { m_moduleName = moduleName; }
Shinya Kitaoka 120a6e
  std::string getModuleName() { return m_moduleName; }
Shinya Kitaoka 120a6e
Shinya Kitaoka 120a6e
  void setRootVarName(std::string varName) {
Shinya Kitaoka 120a6e
    m_rootVarName = varName;
Shinya Kitaoka 120a6e
    updateEnvFile();
Shinya Kitaoka 120a6e
  }
Shinya Kitaoka 120a6e
  std::string getRootVarName() { return m_rootVarName; }
Shinya Kitaoka 120a6e
shun-iwasawa acd6b8
  void setSystemVarPrefix(std::string prefix) {
shun-iwasawa acd6b8
    m_systemVarPrefix = prefix;
shun-iwasawa acd6b8
    updateEnvFile();
shun-iwasawa acd6b8
  }
shun-iwasawa e3b189
  std::string getSystemVarPrefix() { return m_systemVarPrefix; }
Jeremy Bullock 46512f
Jeremy Bullock 46512f
  void setWorkingDirectory() {
Jeremy Bullock 46512f
    QString workingDirectoryTmp  = QDir::currentPath();
Jeremy Bullock 46512f
    QByteArray ba                = workingDirectoryTmp.toLatin1();
Jeremy Bullock 46512f
    const char *workingDirectory = ba.data();
Jeremy Bullock 46512f
    m_workingDirectory           = workingDirectory;
Jeremy Bullock 46512f
Jeremy Bullock 46512f
    // check if portable
Jeremy Bullock 46512f
    TFilePath portableCheck =
Jeremy Bullock 46512f
        TFilePath(m_workingDirectory + "\\portablestuff\\");
Jeremy Bullock 46512f
    TFileStatus portableStatus(portableCheck);
Jeremy Bullock 46512f
    m_isPortable = portableStatus.doesExist();
manongjohn 65b0ff
manongjohn 65b0ff
#ifdef MACOSX
manongjohn 65b0ff
    // macOS 10.12 (Sierra) translocates applications before running them
manongjohn 65b0ff
    // depending on how it was installed. This separates the app from the
manongjohn 65b0ff
    // portablestuff folder and we don't know where it is so we stop treating it
manongjohn 65b0ff
    // as a portable. Placing portablestuff inside OpenToonz.app will keep
manongjohn 65b0ff
    // everything together when it translocates.
manongjohn 65b0ff
    if (!m_isPortable) {
manongjohn fba662
      portableCheck =
manongjohn fba662
          TFilePath(m_workingDirectory + "\\" + getApplicationFileName() +
manongjohn fba662
                    ".app\\portablestuff\\");
manongjohn 65b0ff
      portableStatus = TFileStatus(portableCheck);
manongjohn 65b0ff
      m_isPortable   = portableStatus.doesExist();
manongjohn 65b0ff
      if (m_isPortable)
manongjohn e4c3c8
        m_workingDirectory =
manongjohn e4c3c8
            portableCheck.getParentDir().getQString().toStdString();
manongjohn 65b0ff
    }
manongjohn 65b0ff
#endif
Jeremy Bullock 46512f
  }
Jeremy Bullock 46512f
  std::string getWorkingDirectory() { return m_workingDirectory; }
Jeremy Bullock 46512f
Jeremy Bullock 46512f
  bool getIsPortable() { return m_isPortable; }
Shinya Kitaoka 120a6e
Shinya Kitaoka 120a6e
  void setDllRelativeDir(const TFilePath &dllRelativeDir) {
Shinya Kitaoka 120a6e
    delete m_dllRelativeDir;
Shinya Kitaoka 120a6e
    m_dllRelativeDir = new TFilePath(dllRelativeDir);
Shinya Kitaoka 120a6e
  }
Shinya Kitaoka 120a6e
Shinya Kitaoka 120a6e
  TFilePath getDllRelativeDir() {
Shinya Kitaoka 120a6e
    if (m_dllRelativeDir) return *m_dllRelativeDir;
Shinya Kitaoka 120a6e
    return TFilePath(".");
Shinya Kitaoka 120a6e
  }
shun-iwasawa e3b189
shun-iwasawa e3b189
  void setArgPathValue(std::string key, std::string value) {
shun-iwasawa e3b189
    m_argPathValues.emplace(key, value);
shun-iwasawa e3b189
    if (key == m_systemVarPrefix + "PROFILES") updateEnvFile();
shun-iwasawa e3b189
  }
shun-iwasawa e3b189
shun-iwasawa e3b189
  std::string getArgPathValue(std::string key) {
shun-iwasawa e3b189
    decltype(m_argPathValues)::iterator it = m_argPathValues.find(key);
shun-iwasawa e3b189
    if (it != m_argPathValues.end())
shun-iwasawa e3b189
      return it->second;
shun-iwasawa e3b189
    else
shun-iwasawa e3b189
      return "";
shun-iwasawa e3b189
  }
Toshihiro Shimizu 890ddd
};
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
/*
Toshihiro Shimizu 890ddd
TFilePath EnvGlobals::getSystemPath(int id)
Toshihiro Shimizu 890ddd
{
Toshihiro Shimizu 890ddd
  std::map<int, tfilepath="">::iterator it = m_systemPaths.find(id);</int,>
Toshihiro Shimizu 890ddd
  if(it != m_systemPaths.end()) return it->second;
Toshihiro Shimizu 890ddd
  switch(id)
Toshihiro Shimizu 890ddd
    {
tomosu eea0ac
     case StuffDir:        return TFilePath();
Toshihiro Shimizu 890ddd
     case ConfigDir:       return getSystemPath(StuffDir) + "config";
Toshihiro Shimizu 890ddd
     case ProfilesDir:      return getSystemPath(StuffDir) + "profiles";
tomosu eea0ac
     default: return TFilePath();
Toshihiro Shimizu 890ddd
    }
Toshihiro Shimizu 890ddd
}
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
void EnvGlobals::setSystemPath(int id, const TFilePath &fp)
Toshihiro Shimizu 890ddd
{
Toshihiro Shimizu 890ddd
  m_systemPaths[id] = fp;
Toshihiro Shimizu 890ddd
}
Toshihiro Shimizu 890ddd
*/
Toshihiro Shimizu 890ddd
Shinya Kitaoka 120a6e
}  // namespace
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
//=========================================================
Toshihiro Shimizu 890ddd
//
Toshihiro Shimizu 890ddd
// Variable::Imp
Toshihiro Shimizu 890ddd
//
Toshihiro Shimizu 890ddd
//=========================================================
Toshihiro Shimizu 890ddd
Shinya Kitaoka 120a6e
class Variable::Imp {
Toshihiro Shimizu 890ddd
public:
Shinya Kitaoka 120a6e
  std::string m_name;
Shinya Kitaoka 120a6e
  std::string m_value;
Shinya Kitaoka 120a6e
  bool m_loaded, m_defaultDefined, m_assigned;
Shinya Kitaoka 120a6e
Shinya Kitaoka 120a6e
  Imp(std::string name)
Shinya Kitaoka 120a6e
      : m_name(name)
Shinya Kitaoka 120a6e
      , m_value("")
Shinya Kitaoka 120a6e
      , m_loaded(false)
Shinya Kitaoka 120a6e
      , m_defaultDefined(false)
Shinya Kitaoka 120a6e
      , m_assigned(false) {}
Toshihiro Shimizu 890ddd
};
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
//=========================================================
Toshihiro Shimizu 890ddd
//
luz paz 6454c4
// variable manager (singleton)
Toshihiro Shimizu 890ddd
//
Toshihiro Shimizu 890ddd
//=========================================================
Toshihiro Shimizu 890ddd
Shinya Kitaoka 120a6e
namespace {
Toshihiro Shimizu 890ddd
Shinya Kitaoka 120a6e
class VariableSet {
Shinya Kitaoka 120a6e
  std::map<std::string, *="" variable::imp=""> m_variables;</std::string,>
Shinya Kitaoka 120a6e
  bool m_loaded;
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
public:
Shinya Kitaoka 120a6e
  VariableSet() : m_loaded(false) {}
Shinya Kitaoka 120a6e
Shinya Kitaoka 120a6e
  ~VariableSet() {
Shinya Kitaoka 120a6e
    std::map<std::string, *="" variable::imp="">::iterator it;</std::string,>
Shinya Kitaoka 120a6e
    for (it = m_variables.begin(); it != m_variables.end(); ++it)
Shinya Kitaoka 120a6e
      delete it->second;
Shinya Kitaoka 120a6e
  }
Shinya Kitaoka 120a6e
Shinya Kitaoka 120a6e
  static VariableSet *instance() {
Shinya Kitaoka 120a6e
    static VariableSet instance;
Shinya Kitaoka 120a6e
    return &instance;
Shinya Kitaoka 120a6e
  }
Shinya Kitaoka 120a6e
Shinya Kitaoka 120a6e
  Variable::Imp *getImp(std::string name) {
Shinya Kitaoka 120a6e
    std::map<std::string, *="" variable::imp="">::iterator it;</std::string,>
Shinya Kitaoka 120a6e
    it = m_variables.find(name);
Shinya Kitaoka 120a6e
    if (it == m_variables.end()) {
Shinya Kitaoka 120a6e
      Variable::Imp *imp = new Variable::Imp(name);
Shinya Kitaoka 120a6e
      m_variables[name]  = imp;
Shinya Kitaoka 120a6e
      return imp;
Shinya Kitaoka 120a6e
    } else
Shinya Kitaoka 120a6e
      return it->second;
Shinya Kitaoka 120a6e
  }
Shinya Kitaoka 120a6e
Shinya Kitaoka 120a6e
  void commit() {
Shinya Kitaoka 120a6e
    // save();
Shinya Kitaoka 120a6e
  }
Shinya Kitaoka 120a6e
Shinya Kitaoka 120a6e
  void loadIfNeeded() {
Shinya Kitaoka 120a6e
    if (m_loaded) return;
Shinya Kitaoka 120a6e
    m_loaded = true;
Shinya Kitaoka 120a6e
    try {
Shinya Kitaoka 120a6e
      load();
Shinya Kitaoka 120a6e
    } catch (...) {
Shinya Kitaoka 120a6e
    }
Shinya Kitaoka 120a6e
  }
Shinya Kitaoka 120a6e
Shinya Kitaoka 120a6e
  void load();
Shinya Kitaoka 120a6e
  void save();
Toshihiro Shimizu 890ddd
};
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
//-------------------------------------------------------------------
Toshihiro Shimizu 890ddd
Shinya Kitaoka 120a6e
void VariableSet::load() {
Campbell Barton e6d9f6
#ifndef WIN32
Shinya Kitaoka 120a6e
  EnvGlobals::instance()->updateEnvFile();
Toshihiro Shimizu 890ddd
#endif
Shinya Kitaoka 120a6e
  TFilePath fp = EnvGlobals::instance()->getEnvFile();
Shinya Kitaoka 120a6e
  if (fp == TFilePath()) return;
shun_iwasawa 3e2518
  // if the personal env is not found, then try to find the template
shun_iwasawa 3e2518
  if (!TFileStatus(fp).doesExist())
shun_iwasawa 3e2518
    fp = EnvGlobals::instance()->getTemplateEnvFile();
Shinya Kitaoka 120a6e
  Tifstream is(fp);
shun_iwasawa 3e2518
  if (!is.isOpen()) return;
Shinya Kitaoka 120a6e
  char buffer[1024];
Shinya Kitaoka 120a6e
  while (is.getline(buffer, sizeof(buffer))) {
Shinya Kitaoka 120a6e
    char *s = buffer;
Shinya Kitaoka 120a6e
    while (*s == ' ') s++;
Shinya Kitaoka 120a6e
    char *t = s;
Rozhuk Ivan 823a31
    while (('a' <= *s && *s <= 'z') || ('A' <= *s && *s <= 'Z') ||
Rozhuk Ivan 823a31
           ('0' <= *s && *s <= '9') || *s == '_')
Shinya Kitaoka 120a6e
      s++;
Shinya Kitaoka 120a6e
    std::string name(t, s - t);
Shinya Kitaoka 120a6e
    if (name.size() == 0) continue;
Shinya Kitaoka 120a6e
    while (*s == ' ') s++;
Shinya Kitaoka 120a6e
    if (*s != '\"') continue;
Shinya Kitaoka 120a6e
    s++;
Shinya Kitaoka 120a6e
    std::string value;
Shinya Kitaoka 120a6e
    while (*s != '\n' && *s != '\0' && *s != '\"') {
Shinya Kitaoka 120a6e
      if (*s != '\\')
Shinya Kitaoka 120a6e
        value.push_back(*s);
Shinya Kitaoka 120a6e
      else {
Shinya Kitaoka 120a6e
        s++;
Shinya Kitaoka 120a6e
        if (*s == '\\')
Shinya Kitaoka 120a6e
          value.push_back('\\');
Shinya Kitaoka 120a6e
        else if (*s == '"')
Shinya Kitaoka 120a6e
          value.push_back('"');
Shinya Kitaoka 120a6e
        else if (*s == 'n')
Shinya Kitaoka 120a6e
          value.push_back('\n');
Shinya Kitaoka 120a6e
        else
Shinya Kitaoka 120a6e
          continue;
Shinya Kitaoka 120a6e
      }
Shinya Kitaoka 120a6e
      s++;
Shinya Kitaoka 120a6e
    }
Shinya Kitaoka 120a6e
    Variable::Imp *imp = getImp(name);
Shinya Kitaoka 120a6e
    imp->m_value       = value;
Shinya Kitaoka 120a6e
    imp->m_loaded      = true;
Shinya Kitaoka 120a6e
  }
Toshihiro Shimizu 890ddd
}
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
//-------------------------------------------------------------------
Toshihiro Shimizu 890ddd
Shinya Kitaoka 120a6e
void VariableSet::save() {
Shinya Kitaoka 120a6e
  TFilePath fp = EnvGlobals::instance()->getEnvFile();
Shinya Kitaoka 120a6e
  if (fp == TFilePath()) return;
Shinya Kitaoka 120a6e
  bool exists = TFileStatus(fp.getParentDir()).doesExist();
Shinya Kitaoka 120a6e
  if (!exists) {
Shinya Kitaoka 120a6e
    try {
Shinya Kitaoka 120a6e
      TSystem::mkDir(fp.getParentDir());
Shinya Kitaoka 120a6e
    } catch (...) {
Shinya Kitaoka 120a6e
      return;
Shinya Kitaoka 120a6e
    }
Shinya Kitaoka 120a6e
  }
Shinya Kitaoka 120a6e
  Tofstream os(fp);
Shinya Kitaoka 120a6e
  if (!os) return;
Shinya Kitaoka 120a6e
  std::map<std::string, *="" variable::imp="">::iterator it;</std::string,>
Shinya Kitaoka 120a6e
  for (it = m_variables.begin(); it != m_variables.end(); ++it) {
Shinya Kitaoka 120a6e
    os << it->first << " \"";
Shinya Kitaoka 120a6e
    std::string s = it->second->m_value;
Shinya Kitaoka 120a6e
    for (int i = 0; i < (int)s.size(); i++)
Shinya Kitaoka 120a6e
      if (s[i] == '\"')
Shinya Kitaoka 120a6e
        os << "\\\"";
Shinya Kitaoka 120a6e
      else if (s[i] == '\\')
Shinya Kitaoka 120a6e
        os << "\\\\";
Shinya Kitaoka 120a6e
      else if (s[i] == '\n')
Shinya Kitaoka 120a6e
        os << "\\n";
Shinya Kitaoka 120a6e
      else
Shinya Kitaoka 120a6e
        os.put(s[i]);
Shinya Kitaoka 120a6e
    os << "\"" << std::endl;
Shinya Kitaoka 120a6e
  }
Toshihiro Shimizu 890ddd
}
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
//-------------------------------------------------------------------
Toshihiro Shimizu 890ddd
Shinya Kitaoka 120a6e
}  // namespace
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
//=========================================================
Toshihiro Shimizu 890ddd
Shinya Kitaoka 3bfa54
Variable::Variable(std::string name)
Shinya Kitaoka 120a6e
    : m_imp(VariableSet::instance()->getImp(name)) {}
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
//-------------------------------------------------------------------
Toshihiro Shimizu 890ddd
Shinya Kitaoka 3bfa54
Variable::Variable(std::string name, std::string defaultValue)
Shinya Kitaoka 120a6e
    : m_imp(VariableSet::instance()->getImp(name)) {
Shinya Kitaoka 120a6e
  // assert(!m_imp->m_defaultDefined);
shun-iwasawa 7f4819
  m_imp->m_defaultDefined = true;
Shinya Kitaoka 120a6e
  if (!m_imp->m_loaded) m_imp->m_value = defaultValue;
Toshihiro Shimizu 890ddd
}
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
//-------------------------------------------------------------------
Toshihiro Shimizu 890ddd
Shinya Kitaoka 120a6e
Variable::~Variable() {}
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
//-------------------------------------------------------------------
Toshihiro Shimizu 890ddd
Shinya Kitaoka 120a6e
std::string Variable::getName() const { return m_imp->m_name; }
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
//-------------------------------------------------------------------
Toshihiro Shimizu 890ddd
Shinya Kitaoka 120a6e
std::string Variable::getValue() const {
Shinya Kitaoka 120a6e
  VariableSet::instance()->loadIfNeeded();
Shinya Kitaoka 120a6e
  return m_imp->m_value;
Toshihiro Shimizu 890ddd
}
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
//-------------------------------------------------------------------
Toshihiro Shimizu 890ddd
Shinya Kitaoka 120a6e
void Variable::assignValue(std::string value) {
Shinya Kitaoka 120a6e
  VariableSet *vs = VariableSet::instance();
Shinya Kitaoka 120a6e
  vs->loadIfNeeded();
Shinya Kitaoka 120a6e
  m_imp->m_value = value;
Shinya Kitaoka 120a6e
  try {
Shinya Kitaoka 120a6e
    vs->commit();
Shinya Kitaoka 120a6e
  } catch (...) {
Shinya Kitaoka 120a6e
  }
Toshihiro Shimizu 890ddd
}
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
//===================================================================
Toshihiro Shimizu 890ddd
manongjohn fba662
void TEnv::setApplicationFileName(std::string appFileName) {
manongjohn fba662
  TFilePath fp(appFileName);
manongjohn 273f30
#ifdef MACOSX
manongjohn 273f30
  if (fp.getWideName().find(L".app"))
manongjohn 273f30
    for (int i = 0; i < 3; i++) fp = fp.getParentDir();
Rozhuk Ivan ac51ab
#elif defined(LINUX) || defined(FREEBSD)
manongjohn 273f30
  if (fp.getWideName().find(L".appimage"))
manongjohn 273f30
    for (int i = 0; i < 2; i++) fp = fp.getParentDir();
manongjohn 273f30
#endif
manongjohn fba662
  EnvGlobals::instance()->setApplicationFileName(fp.getName());
manongjohn fba662
}
manongjohn fba662
manongjohn fba662
std::string TEnv::getApplicationFileName() {
manongjohn fba662
  return EnvGlobals::instance()->getApplicationFileName();
manongjohn fba662
}
manongjohn fba662
Shinya Kitaoka 120a6e
std::string TEnv::getApplicationName() {
Shinya Kitaoka 120a6e
  return EnvGlobals::instance()->getApplicationName();
Toshihiro Shimizu 890ddd
}
Toshihiro Shimizu 890ddd
Shinya Kitaoka 120a6e
std::string TEnv::getApplicationVersion() {
Shinya Kitaoka 120a6e
  return EnvGlobals::instance()->getApplicationVersion();
Toshihiro Shimizu 890ddd
}
Toshihiro Shimizu 890ddd
Shinya Kitaoka 120a6e
void TEnv::setApplicationFullName(std::string applicationFullName) {
Shinya Kitaoka 120a6e
  EnvGlobals::instance()->setApplicationFullName(applicationFullName);
Toshihiro Shimizu 890ddd
}
Toshihiro Shimizu 890ddd
Shinya Kitaoka 120a6e
std::string TEnv::getApplicationFullName() {
Shinya Kitaoka 120a6e
  return EnvGlobals::instance()->getApplicationFullName();
Toshihiro Shimizu 890ddd
}
Toshihiro Shimizu 890ddd
Shinya Kitaoka 120a6e
void TEnv::setModuleName(std::string moduleName) {
Shinya Kitaoka 120a6e
  EnvGlobals::instance()->setModuleName(moduleName);
Toshihiro Shimizu 890ddd
}
Toshihiro Shimizu 890ddd
Shinya Kitaoka 120a6e
std::string TEnv::getModuleName() {
Shinya Kitaoka 120a6e
  return EnvGlobals::instance()->getModuleName();
Toshihiro Shimizu 890ddd
}
Toshihiro Shimizu 890ddd
Shinya Kitaoka 120a6e
void TEnv::setRootVarName(std::string varName) {
Shinya Kitaoka 120a6e
  EnvGlobals::instance()->setRootVarName(varName);
Toshihiro Shimizu 890ddd
}
Toshihiro Shimizu 890ddd
Shinya Kitaoka 120a6e
std::string TEnv::getRootVarName() {
Shinya Kitaoka 120a6e
  return EnvGlobals::instance()->getRootVarName();
Toshihiro Shimizu 890ddd
}
Toshihiro Shimizu 890ddd
Shinya Kitaoka 120a6e
TFilePath TEnv::getRootVarPath() {
Shinya Kitaoka 120a6e
  return EnvGlobals::instance()->getRootVarPath();
Toshihiro Shimizu 890ddd
}
Toshihiro Shimizu 890ddd
Shinya Kitaoka 120a6e
std::string TEnv::getSystemVarStringValue(std::string varName) {
Shinya Kitaoka 120a6e
  return EnvGlobals::instance()->getSystemVarValue(varName);
Toshihiro Shimizu 890ddd
}
Toshihiro Shimizu 890ddd
Shinya Kitaoka 120a6e
TFilePath TEnv::getSystemVarPathValue(std::string varName) {
shun-iwasawa f39ea0
  return EnvGlobals::instance()->getSystemVarPathValue(varName);
Toshihiro Shimizu 890ddd
}
Toshihiro Shimizu 890ddd
Shinya Kitaoka 120a6e
TFilePathSet TEnv::getSystemVarPathSetValue(std::string varName) {
Shinya Kitaoka 120a6e
  TFilePathSet lst;
shun-iwasawa e3b189
  EnvGlobals *eg = EnvGlobals::instance();
shun-iwasawa e3b189
  // if the path is registered by command line argument, then use it
shun-iwasawa 7f4819
  std::string value = eg->getArgPathValue(varName);
shun-iwasawa e3b189
  if (value == "") value = eg->getSystemVarValue(varName);
shun-iwasawa 7f4819
  int len = (int)value.size();
shun-iwasawa 7f4819
  int i   = 0;
shun-iwasawa 7f4819
  int j   = value.find(';');
Shinya Kitaoka 120a6e
  while (j != std::string::npos) {
Shinya Kitaoka 120a6e
    std::string s = value.substr(i, j - i);
Shinya Kitaoka 120a6e
    lst.push_back(TFilePath(s));
Shinya Kitaoka 120a6e
    i = j + 1;
Shinya Kitaoka 120a6e
    if (i >= len) return lst;
Shinya Kitaoka 120a6e
    j = value.find(';', i);
Shinya Kitaoka 120a6e
  }
Shinya Kitaoka 120a6e
  if (i < len) lst.push_back(TFilePath(value.substr(i)));
Shinya Kitaoka 120a6e
  return lst;
Toshihiro Shimizu 890ddd
}
Toshihiro Shimizu 890ddd
Shinya Kitaoka 120a6e
void TEnv::setSystemVarPrefix(std::string varName) {
Shinya Kitaoka 120a6e
  EnvGlobals::instance()->setSystemVarPrefix(varName);
Toshihiro Shimizu 890ddd
}
Toshihiro Shimizu 890ddd
Shinya Kitaoka 120a6e
std::string TEnv::getSystemVarPrefix() {
Shinya Kitaoka 120a6e
  return EnvGlobals::instance()->getSystemVarPrefix();
Toshihiro Shimizu 890ddd
}
Toshihiro Shimizu 890ddd
Shinya Kitaoka 120a6e
TFilePath TEnv::getStuffDir() {
Shinya Kitaoka 120a6e
  //#ifdef MACOSX
Shinya Kitaoka 120a6e
  // return TFilePath("/Applications/Toonz 5.0/Toonz 5.0 stuff");
Shinya Kitaoka 120a6e
  //#else
Shinya Kitaoka 120a6e
  return EnvGlobals::instance()->getStuffDir();
Shinya Kitaoka 120a6e
  //#endif
Shinya Kitaoka 120a6e
}
Shinya Kitaoka 120a6e
Jeremy Bullock 46512f
bool TEnv::getIsPortable() { return EnvGlobals::instance()->getIsPortable(); }
Jeremy Bullock 46512f
Shinya Kitaoka 120a6e
TFilePath TEnv::getConfigDir() {
Shinya Kitaoka 120a6e
  TFilePath configDir = getSystemVarPathValue(getSystemVarPrefix() + "CONFIG");
shun-iwasawa e3b189
  if (configDir == TFilePath())
shun-iwasawa e3b189
    configDir = getStuffDir() + systemPathMap.at("CONFIG");
Shinya Kitaoka 120a6e
  return configDir;
Toshihiro Shimizu 890ddd
}
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
/*TFilePath TEnv::getProfilesDir()
Toshihiro Shimizu 890ddd
{
Toshihiro Shimizu 890ddd
  TFilePath fp(getStuffDir());
Toshihiro Shimizu 890ddd
  return fp != TFilePath() ? fp + "profiles" : fp;
Toshihiro Shimizu 890ddd
}
Toshihiro Shimizu 890ddd
*/
Shinya Kitaoka 120a6e
void TEnv::setStuffDir(const TFilePath &stuffDir) {
Shinya Kitaoka 120a6e
  EnvGlobals::instance()->setStuffDir(stuffDir);
Toshihiro Shimizu 890ddd
}
Toshihiro Shimizu 890ddd
Shinya Kitaoka 120a6e
void TEnv::saveAllEnvVariables() { VariableSet::instance()->save(); }
Toshihiro Shimizu 890ddd
shun-iwasawa e3b189
bool TEnv::setArgPathValue(std::string key, std::string value) {
shun-iwasawa e3b189
  EnvGlobals *eg = EnvGlobals::instance();
shun-iwasawa e3b189
  // in case of "-TOONZROOT" , set the all unregistered paths
shun-iwasawa e3b189
  if (key == getRootVarName()) {
shun-iwasawa e3b189
    TFilePath rootPath(value);
shun-iwasawa e3b189
    eg->setStuffDir(rootPath);
shun-iwasawa e3b189
    for (auto itr = systemPathMap.begin(); itr != systemPathMap.end(); ++itr) {
shun-iwasawa e3b189
      std::string k   = getSystemVarPrefix() + (*itr).first;
shun-iwasawa e3b189
      std::string val = value + "\\" + (*itr).second;
shun-iwasawa e3b189
      // set all unregistered values
shun-iwasawa e3b189
      if (eg->getArgPathValue(k) == "") eg->setArgPathValue(k, val);
shun-iwasawa e3b189
    }
shun-iwasawa e3b189
    return true;
shun-iwasawa e3b189
  } else {
shun-iwasawa e3b189
    for (auto itr = systemPathMap.begin(); itr != systemPathMap.end(); ++itr) {
shun-iwasawa e3b189
      // found the corresponding registry key
shun-iwasawa e3b189
      if (key == getSystemVarPrefix() + (*itr).first) {
shun-iwasawa e3b189
        eg->setArgPathValue(key, value);
shun-iwasawa e3b189
        return true;
shun-iwasawa e3b189
      }
shun-iwasawa e3b189
    }
shun-iwasawa e3b189
    // registry key not found. failed to register
shun-iwasawa e3b189
    return false;
shun-iwasawa e3b189
  }
shun-iwasawa e3b189
}
shun-iwasawa e3b189
shun-iwasawa e3b189
const std::map<std::string, std::string=""> &TEnv::getSystemPathMap() {</std::string,>
shun-iwasawa e3b189
  return systemPathMap;
shun-iwasawa e3b189
}
shun-iwasawa e3b189
Toshihiro Shimizu 890ddd
/*
Toshihiro Shimizu 890ddd
void TEnv::defineSystemPath(SystemFileId id, const TFilePath ®istryName)
Toshihiro Shimizu 890ddd
{
Toshihiro Shimizu 890ddd
  string s = TSystem::getSystemValue(registryName);
Toshihiro Shimizu 890ddd
  if(s=="") return;
Toshihiro Shimizu 890ddd
  EnvGlobals::instance()->setSystemPath(id, TFilePath(s));
Toshihiro Shimizu 890ddd
}
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
//---------------------------------------------------------
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
TFilePath TEnv::getSystemPath(SystemFileId id)
Toshihiro Shimizu 890ddd
{
Toshihiro Shimizu 890ddd
  return EnvGlobals::instance()->getSystemPath(id);
Toshihiro Shimizu 890ddd
}
Toshihiro Shimizu 890ddd
*/
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
//=========================================================
Toshihiro Shimizu 890ddd
//
Toshihiro Shimizu 890ddd
// Variabili tipizzate
Toshihiro Shimizu 890ddd
//
Toshihiro Shimizu 890ddd
//=========================================================
Toshihiro Shimizu 890ddd
Shinya Kitaoka 120a6e
namespace {
Toshihiro Shimizu 890ddd
Shinya Kitaoka 120a6e
std::istream &operator>>(std::istream &is, TFilePath &path) {
Shinya Kitaoka 120a6e
  std::string s;
Shinya Kitaoka 120a6e
  is >> s;
Shinya Kitaoka 120a6e
  return is;
Toshihiro Shimizu 890ddd
}
Toshihiro Shimizu 890ddd
Shinya Kitaoka 120a6e
std::istream &operator>>(std::istream &is, TRect &rect) {
Shinya Kitaoka 120a6e
  return is >> rect.x0 >> rect.y0 >> rect.x1 >> rect.y1;
Toshihiro Shimizu 890ddd
}
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
template <class t=""></class>
Shinya Kitaoka 120a6e
std::string toString2(T value) {
Shinya Kitaoka 120a6e
  std::ostringstream ss;
Shinya Kitaoka 120a6e
  ss << value << '\0';
Shinya Kitaoka 120a6e
  return ss.str();
Toshihiro Shimizu 890ddd
}
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
template <>
Shinya Kitaoka 120a6e
std::string toString2(TRect value) {
Shinya Kitaoka 120a6e
  std::ostringstream ss;
shun-iwasawa 4d00d0
  ss << value.x0 << " " << value.y0 << " " << value.x1 << " " << value.y1;
Shinya Kitaoka 120a6e
  return ss.str();
Toshihiro Shimizu 890ddd
}
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
template <class t=""></class>
Shinya Kitaoka 120a6e
void fromString(std::string s, T &value) {
Shinya Kitaoka 120a6e
  if (s.empty()) return;
Shinya Kitaoka 120a6e
  std::istringstream is(s);
Shinya Kitaoka 120a6e
  is >> value;
Toshihiro Shimizu 890ddd
}
Toshihiro Shimizu 890ddd
Shinya Kitaoka 120a6e
void fromString(std::string s, std::string &value) { value = s; }
Toshihiro Shimizu 890ddd
Shinya Kitaoka 120a6e
}  // namespace
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
//-------------------------------------------------------------------
Toshihiro Shimizu 890ddd
Shinya Kitaoka 120a6e
IntVar::IntVar(std::string name, int defValue)
Shinya Kitaoka 120a6e
    : Variable(name, std::to_string(defValue)) {}
Shinya Kitaoka 3bfa54
IntVar::IntVar(std::string name) : Variable(name) {}
Shinya Kitaoka 120a6e
IntVar::operator int() const {
Shinya Kitaoka 120a6e
  int v;
Shinya Kitaoka 120a6e
  fromString(getValue(), v);
Shinya Kitaoka 120a6e
  return v;
Toshihiro Shimizu 890ddd
}
Shinya Kitaoka 9eb50d
void IntVar::operator=(int v) { assignValue(std::to_string(v)); }
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
//-------------------------------------------------------------------
Toshihiro Shimizu 890ddd
Shinya Kitaoka 120a6e
DoubleVar::DoubleVar(std::string name, double defValue)
Shinya Kitaoka 120a6e
    : Variable(name, std::to_string(defValue)) {}
Shinya Kitaoka 3bfa54
DoubleVar::DoubleVar(std::string name) : Variable(name) {}
Shinya Kitaoka 120a6e
DoubleVar::operator double() const {
Shinya Kitaoka 120a6e
  double v;
Shinya Kitaoka 120a6e
  fromString(getValue(), v);
Shinya Kitaoka 120a6e
  return v;
Toshihiro Shimizu 890ddd
}
Shinya Kitaoka 9eb50d
void DoubleVar::operator=(double v) { assignValue(std::to_string(v)); }
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
//-------------------------------------------------------------------
Toshihiro Shimizu 890ddd
Shinya Kitaoka 120a6e
StringVar::StringVar(std::string name, const std::string &defValue)
Shinya Kitaoka 120a6e
    : Variable(name, defValue) {}
Shinya Kitaoka 3bfa54
StringVar::StringVar(std::string name) : Variable(name) {}
Shinya Kitaoka 120a6e
StringVar::operator std::string() const {
Shinya Kitaoka 120a6e
  std::string v;
Shinya Kitaoka 120a6e
  fromString(getValue(), v);
Shinya Kitaoka 120a6e
  return v;
Toshihiro Shimizu 890ddd
}
Shinya Kitaoka 3bfa54
void StringVar::operator=(const std::string &v) { assignValue(v); }
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
//-------------------------------------------------------------------
Toshihiro Shimizu 890ddd
Shinya Kitaoka 120a6e
FilePathVar::FilePathVar(std::string name, const TFilePath &defValue)
Shinya Kitaoka 120a6e
    : Variable(name, ::to_string(defValue)) {}
Shinya Kitaoka 3bfa54
FilePathVar::FilePathVar(std::string name) : Variable(name) {}
Shinya Kitaoka 120a6e
FilePathVar::operator TFilePath() const {
Shinya Kitaoka 120a6e
  std::string v;
Shinya Kitaoka 120a6e
  fromString(getValue(), v);
Shinya Kitaoka 120a6e
  return TFilePath(v);
Toshihiro Shimizu 890ddd
}
Shinya Kitaoka 9eb50d
void FilePathVar::operator=(const TFilePath &v) { assignValue(::to_string(v)); }
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
//-------------------------------------------------------------------
Toshihiro Shimizu 890ddd
Shinya Kitaoka 120a6e
RectVar::RectVar(std::string name, const TRect &defValue)
Shinya Kitaoka 120a6e
    : Variable(name, toString2(defValue)) {}
Shinya Kitaoka 3bfa54
RectVar::RectVar(std::string name) : Variable(name) {}
Shinya Kitaoka 120a6e
RectVar::operator TRect() const {
Shinya Kitaoka 120a6e
  TRect v;
Shinya Kitaoka 120a6e
  fromString(getValue(), v);
Shinya Kitaoka 120a6e
  return v;
Toshihiro Shimizu 890ddd
}
Toshihiro Shimizu 890ddd
void RectVar::operator=(const TRect &v) { assignValue(toString2(v)); }
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
//=========================================================