Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2025-12-16 09:40:53

0001 // Copyright 2022 The Abseil Authors.
0002 //
0003 // Licensed under the Apache License, Version 2.0 (the "License");
0004 // you may not use this file except in compliance with the License.
0005 // You may obtain a copy of the License at
0006 //
0007 //      https://www.apache.org/licenses/LICENSE-2.0
0008 //
0009 // Unless required by applicable law or agreed to in writing, software
0010 // distributed under the License is distributed on an "AS IS" BASIS,
0011 // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
0012 // See the License for the specific language governing permissions and
0013 // limitations under the License.
0014 //
0015 // -----------------------------------------------------------------------------
0016 // File: log/internal/structured.h
0017 // -----------------------------------------------------------------------------
0018 
0019 #ifndef ABSL_LOG_INTERNAL_STRUCTURED_H_
0020 #define ABSL_LOG_INTERNAL_STRUCTURED_H_
0021 
0022 #include <ostream>
0023 
0024 #include "absl/base/config.h"
0025 #include "absl/log/internal/log_message.h"
0026 #include "absl/strings/string_view.h"
0027 
0028 namespace absl {
0029 ABSL_NAMESPACE_BEGIN
0030 namespace log_internal {
0031 
0032 class ABSL_MUST_USE_RESULT AsLiteralImpl final {
0033  public:
0034   explicit AsLiteralImpl(absl::string_view str) : str_(str) {}
0035   AsLiteralImpl(const AsLiteralImpl&) = default;
0036   AsLiteralImpl& operator=(const AsLiteralImpl&) = default;
0037 
0038  private:
0039   absl::string_view str_;
0040 
0041   friend std::ostream& operator<<(std::ostream& os, AsLiteralImpl as_literal) {
0042     return os << as_literal.str_;
0043   }
0044   void AddToMessage(log_internal::LogMessage& m) {
0045     m.CopyToEncodedBuffer<log_internal::LogMessage::StringType::kLiteral>(str_);
0046   }
0047   friend log_internal::LogMessage& operator<<(log_internal::LogMessage& m,
0048                                               AsLiteralImpl as_literal) {
0049     as_literal.AddToMessage(m);
0050     return m;
0051   }
0052 };
0053 
0054 }  // namespace log_internal
0055 ABSL_NAMESPACE_END
0056 }  // namespace absl
0057 
0058 #endif  // ABSL_LOG_INTERNAL_STRUCTURED_H_