program_name.h 1.7 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950
  1. //
  2. // Copyright 2019 The Abseil Authors.
  3. //
  4. // Licensed under the Apache License, Version 2.0 (the "License");
  5. // you may not use this file except in compliance with the License.
  6. // You may obtain a copy of the License at
  7. //
  8. // https://www.apache.org/licenses/LICENSE-2.0
  9. //
  10. // Unless required by applicable law or agreed to in writing, software
  11. // distributed under the License is distributed on an "AS IS" BASIS,
  12. // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  13. // See the License for the specific language governing permissions and
  14. // limitations under the License.
  15. #ifndef ABSL_FLAGS_INTERNAL_PROGRAM_NAME_H_
  16. #define ABSL_FLAGS_INTERNAL_PROGRAM_NAME_H_
  17. #include <string>
  18. #include "absl/base/config.h"
  19. #include "absl/strings/string_view.h"
  20. // --------------------------------------------------------------------
  21. // Program name
  22. namespace absl {
  23. ABSL_NAMESPACE_BEGIN
  24. namespace flags_internal {
  25. // Returns program invocation name or "UNKNOWN" if `SetProgramInvocationName()`
  26. // is never called. At the moment this is always set to argv[0] as part of
  27. // library initialization.
  28. std::string ProgramInvocationName();
  29. // Returns base name for program invocation name. For example, if
  30. // ProgramInvocationName() == "a/b/mybinary"
  31. // then
  32. // ShortProgramInvocationName() == "mybinary"
  33. std::string ShortProgramInvocationName();
  34. // Sets program invocation name to a new value. Should only be called once
  35. // during program initialization, before any threads are spawned.
  36. void SetProgramInvocationName(absl::string_view prog_name_str);
  37. } // namespace flags_internal
  38. ABSL_NAMESPACE_END
  39. } // namespace absl
  40. #endif // ABSL_FLAGS_INTERNAL_PROGRAM_NAME_H_