abseil-cpp/absl/flags/internal/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 
16 #include "absl/flags/internal/program_name.h"
17 
18 #include <string>
19 
20 #include "absl/base/attributes.h"
21 #include "absl/base/config.h"
22 #include "absl/base/const_init.h"
23 #include "absl/base/thread_annotations.h"
24 #include "absl/flags/internal/path_util.h"
25 #include "absl/strings/string_view.h"
26 #include "absl/synchronization/mutex.h"
27 
28 namespace absl {
30 namespace flags_internal {
31 
33 ABSL_CONST_INIT static std::string* program_name
35 
38 
39  return program_name ? *program_name : "UNKNOWN";
40 }
41 
44 
45  return program_name ? std::string(flags_internal::Basename(*program_name))
46  : "UNKNOWN";
47 }
48 
51 
52  if (!program_name)
53  program_name = new std::string(prog_name_str);
54  else
55  program_name->assign(prog_name_str.data(), prog_name_str.size());
56 }
57 
58 } // namespace flags_internal
60 } // namespace absl
absl::flags_internal::ProgramInvocationName
std::string ProgramInvocationName()
Definition: abseil-cpp/absl/flags/internal/program_name.cc:36
absl::flags_internal::ShortProgramInvocationName
std::string ShortProgramInvocationName()
Definition: abseil-cpp/absl/flags/internal/program_name.cc:42
ABSL_CONST_INIT
#define ABSL_CONST_INIT
Definition: abseil-cpp/absl/base/attributes.h:716
absl::Mutex
Definition: abseil-cpp/absl/synchronization/mutex.h:131
absl::string_view
Definition: abseil-cpp/absl/strings/string_view.h:167
testing::internal::string
::std::string string
Definition: bloaty/third_party/protobuf/third_party/googletest/googletest/include/gtest/internal/gtest-port.h:881
absl::flags_internal::program_name_guard
static ABSL_CONST_INIT absl::Mutex program_name_guard(absl::kConstInit)
absl::kConstInit
@ kConstInit
Definition: abseil-cpp/absl/base/const_init.h:70
ABSL_NAMESPACE_END
#define ABSL_NAMESPACE_END
Definition: third_party/abseil-cpp/absl/base/config.h:171
absl::MutexLock
Definition: abseil-cpp/absl/synchronization/mutex.h:525
ABSL_NAMESPACE_BEGIN
#define ABSL_NAMESPACE_BEGIN
Definition: third_party/abseil-cpp/absl/base/config.h:170
absl::flags_internal::ABSL_GUARDED_BY
static ABSL_CONST_INIT std::string *program_name ABSL_GUARDED_BY(program_name_guard)
absl::string_view::size
constexpr size_type size() const noexcept
Definition: abseil-cpp/absl/strings/string_view.h:277
absl::flags_internal::Basename
absl::string_view Basename(absl::string_view filename)
Definition: abseil-cpp/absl/flags/internal/path_util.h:34
absl::flags_internal::SetProgramInvocationName
void SetProgramInvocationName(absl::string_view prog_name_str)
Definition: abseil-cpp/absl/flags/internal/program_name.cc:49
absl
Definition: abseil-cpp/absl/algorithm/algorithm.h:31
absl::string_view::data
constexpr const_pointer data() const noexcept
Definition: abseil-cpp/absl/strings/string_view.h:336


grpc
Author(s):
autogenerated on Fri May 16 2025 02:59:46