You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

91 lines
2.7 KiB

  1. /*
  2. * This program source code file is part of KiCad, a free EDA CAD application.
  3. *
  4. * Copyright (C) 2018 KiCad Developers, see AUTHORS.txt for contributors.
  5. *
  6. * This program is free software: you can redistribute it and/or modify it
  7. * under the terms of the GNU General Public License as published by the
  8. * Free Software Foundation, either version 3 of the License, or (at your
  9. * option) any later version.
  10. *
  11. * This program is distributed in the hope that it will be useful, but
  12. * WITHOUT ANY WARRANTY; without even the implied warranty of
  13. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
  14. * General Public License for more details.
  15. *
  16. * You should have received a copy of the GNU General Public License along
  17. * with this program. If not, see <http://www.gnu.org/licenses/>.
  18. */
  19. /**
  20. * @file env_vars.h
  21. * Functions related to environment variables, including help functions
  22. */
  23. #ifndef ENV_VARS_H
  24. #define ENV_VARS_H
  25. #include <wx/string.h>
  26. #include <vector>
  27. #include <core/optional.h>
  28. using ENV_VAR_LIST = std::vector<wxString>;
  29. /**
  30. * Determine if an environment variable is "predefined", i.e. if the
  31. * name of the variable is special to KiCad, and isn't just a user-specified
  32. * substitution name.
  33. * @param aEnvVar the variable to check
  34. * @return true if predefined
  35. */
  36. bool IsEnvVarImmutable( const wxString& aEnvVar );
  37. /**
  38. * Get the list of pre-defined environment variables.
  39. */
  40. const ENV_VAR_LIST& GetPredefinedEnvVars();
  41. /**
  42. * Look up long-form help text for a given environment variable.
  43. *
  44. * This is intended for use in more verbose help resources (as opposed to
  45. * tooltip text)
  46. *
  47. * @param aEnvVar The variable to look up
  48. * @return A string with help for that variable. Empty if
  49. * no help available for this variable.
  50. */
  51. wxString LookUpEnvVarHelp( const wxString& aEnvVar );
  52. /**
  53. * Get an environment variable as a specific type, if set correctly
  54. *
  55. * @param aEnvVarName the name of the environment variable
  56. * @return an OPT containing the value, if set and parseable, otherwise empty.
  57. */
  58. template <typename VAL_TYPE>
  59. OPT<VAL_TYPE> GetEnvVar( const wxString& aEnvVarName );
  60. /**
  61. * Get a string environment variable, if it is set.
  62. *
  63. * @param aEnvVarName the name of the environment variable
  64. * @return an OPT containing the value, if set, otherwise empty.
  65. */
  66. template<>
  67. OPT<wxString> GetEnvVar( const wxString& aEnvVarName );
  68. /**
  69. * Get a double from an environment variable, if set
  70. *
  71. * @param aEnvVarName the name of the environment variable
  72. * @return an OPT containing the value, if set and parseable as a double,
  73. * otherwise empty.
  74. */
  75. template <>
  76. OPT<double> GetEnvVar( const wxString& aEnvVarName );
  77. #endif /* ENV_VARS_H */