libzypp  17.38.17
JsonNull.h
Go to the documentation of this file.
1 /*---------------------------------------------------------------------\
2 | ____ _ __ __ ___ |
3 | |__ / \ / / . \ . \ |
4 | / / \ V /| _/ _/ |
5 | / /__ | | | | | | |
6 | /_____||_| |_| |_| |
7 | |
8 \---------------------------------------------------------------------*/
9 #ifndef ZYPP_CORE_PARSER_JSON_JSON_NULL_DEFINED
10 #define ZYPP_CORE_PARSER_JSON_JSON_NULL_DEFINED
11 
12 #include <string_view>
13 #include <string>
14 #include <ostream>
15 
16 #include <zypp-core/Globals.h>
17 
18 namespace zypp::json {
19 
20  static constexpr std::string_view nullJSON ("null");
21 
22  class ZYPP_API Null {
23 
24  public:
25  Null() = default;
26  Null(std::nullptr_t){}
27 
28  ~Null() = default;
29 
30  Null( const Null & ) = default;
31  Null( Null && ) = default;
32  Null &operator=(const Null &) = default;
33  Null &operator=(Null &&) = default;
34 
36  std::string asJSON() const
37  { return std::string(nullJSON); }
38 
40  std::ostream & dumpOn( std::ostream & str ) const
41  { return str << nullJSON; }
42 
43  // comparison
44  bool operator==( const Null & ) const { return true; }
45 
46  };
47 
49  inline ZYPP_API std::ostream & operator<<( std::ostream & str, const Null & obj )
50  {
51  return obj.dumpOn( str );
52  }
53 }
54 
55 #endif
ZYPP_API std::ostream & operator<<(std::ostream &str, const Bool &obj)
relates: Bool Stream output
Definition: JsonBool.h:59
Null(std::nullptr_t)
Definition: JsonNull.h:26
String related utilities and Regular expression matching.
const Arch Arch_empty ZYPP_API
relates: Arch This is an empty Arch represented by an empty string.
Definition: Arch.h:173
Provides API related macros.
std::string asJSON() const
JSON representation.
Definition: JsonNull.h:36
static constexpr std::string_view nullJSON("null")
std::ostream & dumpOn(std::ostream &str) const
Stream output.
Definition: JsonNull.h:40
bool operator==(const Null &) const
Definition: JsonNull.h:44