env.h 1.2 KB

1234567891011121314151617181920212223242526272829303132
  1. #pragma once
  2. #include <util/generic/string.h>
  3. /**
  4. * Search the environment list provided by the host environment for associated variable.
  5. *
  6. * @param key String identifying the name of the environmental variable to look for
  7. * @param def String that returns if environmental variable not found by key
  8. *
  9. * @return String that is associated with the matched environment variable or empty string if
  10. * such variable is missing.
  11. *
  12. * @note Use it only in pair with `SetEnv` as there may be inconsistency in their behaviour
  13. * otherwise.
  14. * @note Calls to `GetEnv` and `SetEnv` from different threads must be synchronized.
  15. * @see SetEnv
  16. */
  17. TString GetEnv(const TString& key, const TString& def = TString());
  18. /**
  19. * Add or change environment variable provided by the host environment.
  20. *
  21. * @key String identifying the name of the environment variable to set or change
  22. * @value Value to assign
  23. * @note Use it only in pair with `GetEnv` as there may be inconsistency in their behaviour
  24. * otherwise.
  25. * @note Calls to `GetEnv` and `SetEnv` from different threads must be synchronized.
  26. * @see GetEnv
  27. */
  28. void SetEnv(const TString& key, const TString& value);