• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 // Copyright 2023 The Pigweed Authors
2 //
3 // Licensed under the Apache License, Version 2.0 (the "License"); you may not
4 // use this file except in compliance with the License. You may obtain a copy of
5 // the License at
6 //
7 //     https://www.apache.org/licenses/LICENSE-2.0
8 //
9 // Unless required by applicable law or agreed to in writing, software
10 // distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
11 // WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
12 // License for the specific language governing permissions and limitations under
13 // the License.
14 
15 // This file contains a minimal fake implementation of Inspect to enable code to
16 // compile when Inspect is not supported.
17 
18 #pragma once
19 
20 #include <string>
21 
22 namespace inspect {
23 
24 template <typename T>
25 class Property {
26  public:
27   explicit operator bool() const { return false; }
Set(const T & value)28   void Set(const T& value) {}
Add(T value)29   void Add(T value) {}
Subtract(T value)30   void Subtract(T value) {}
31 };
32 
33 class StringProperty final : public Property<std::string> {};
34 class BoolProperty final : public Property<bool> {};
35 class IntProperty final : public Property<int64_t> {};
36 class UintProperty final : public Property<uint64_t> {};
37 class DoubleProperty final : public Property<double> {};
38 
39 class Node final {
40  public:
41   Node() = default;
42 
43   explicit operator bool() const { return false; }
44 
CreateChild(std::string_view name)45   Node CreateChild(std::string_view name) { return Node(); }
46 
UniqueName(const std::string & prefix)47   std::string UniqueName(const std::string& prefix) { return ""; }
48 
CreateString(std::string_view name,const std::string & value)49   StringProperty CreateString(std::string_view name, const std::string& value) {
50     return {};
51   }
52 
53   template <typename T>
CreateString(std::string_view name,const std::string & value,T * list)54   void CreateString(std::string_view name, const std::string& value, T* list) {}
55 
RecordString(std::string_view name,const std::string & value)56   void RecordString(std::string_view name, const std::string& value) {}
57 
CreateBool(std::string_view name,bool value)58   BoolProperty CreateBool(std::string_view name, bool value) { return {}; }
59 
RecordBool(std::string_view name,bool value)60   void RecordBool(std::string_view name, bool value) {}
61 
CreateInt(std::string_view,int64_t value)62   IntProperty CreateInt(std::string_view, int64_t value) { return {}; }
63 
RecordInt(std::string_view name,int64_t value)64   void RecordInt(std::string_view name, int64_t value) {}
65 
CreateUint(std::string_view,uint64_t value)66   UintProperty CreateUint(std::string_view, uint64_t value) { return {}; }
67 
RecordUint(std::string_view name,uint64_t value)68   void RecordUint(std::string_view name, uint64_t value) {}
69 
CreateDouble(std::string_view,double value)70   DoubleProperty CreateDouble(std::string_view, double value) { return {}; }
71 
RecordDouble(std::string_view name,double value)72   void RecordDouble(std::string_view name, double value) {}
73 };
74 
75 class Inspector final {
76  public:
GetRoot()77   Node& GetRoot() { return node_; }
78 
79  private:
80   Node node_;
81 };
82 
83 }  // namespace inspect
84