program_name.cc
Go to the documentation of this file.
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 
17 
18 #include <string>
19 
22 
23 namespace absl {
24 namespace flags_internal {
25 
27 ABSL_CONST_INIT static std::string* program_name
28  GUARDED_BY(program_name_guard) = nullptr;
29 
30 std::string ProgramInvocationName() {
32 
33  return program_name ? *program_name : "UNKNOWN";
34 }
35 
38 
39  return program_name ? std::string(flags_internal::Basename(*program_name))
40  : "UNKNOWN";
41 }
42 
45 
46  if (!program_name)
47  program_name = new std::string(prog_name_str);
48  else
49  program_name->assign(prog_name_str.data(), prog_name_str.size());
50 }
51 
52 } // namespace flags_internal
53 } // namespace absl
#define ABSL_CONST_INIT
Definition: attributes.h:605
static ABSL_CONST_INIT absl::Mutex program_name_guard(absl::kConstInit)
Definition: algorithm.h:29
constexpr size_type size() const noexcept
Definition: string_view.h:260
std::string ProgramInvocationName()
Definition: program_name.cc:30
absl::string_view Basename(absl::string_view filename)
Definition: path_util.h:33
std::string ShortProgramInvocationName()
Definition: program_name.cc:36
constexpr const_pointer data() const noexcept
Definition: string_view.h:302
static ABSL_CONST_INIT std::string *program_name GUARDED_BY(program_name_guard)
void SetProgramInvocationName(absl::string_view prog_name_str)
Definition: program_name.cc:43


abseil_cpp
Author(s):
autogenerated on Mon Feb 28 2022 21:31:20