libdballe  7.19
core/defs.h
Go to the documentation of this file.
1 #ifndef DBA_MSG_DEFS_H
2 #define DBA_MSG_DEFS_H
3 
8 #include <dballe/types.h>
9 #include <limits.h>
10 #include <string>
11 #include <iosfwd>
12 
13 namespace dballe {
14 
19 class Ident
20 {
21 protected:
22  char* value = nullptr;
23 
24 public:
25  Ident() = default;
26  Ident(const char* value);
27  Ident(const Ident& o);
28  Ident(Ident&& o);
29  ~Ident();
30  Ident& operator=(const Ident& o);
31  Ident& operator=(Ident&& o);
32  Ident& operator=(const char* o);
33  Ident& operator=(const std::string& o);
34  const char* get() const { return value; }
35  void clear();
36  int compare(const Ident& o) const;
37  int compare(const char* o) const;
38  int compare(const std::string& o) const;
39  template<typename T> bool operator==(const T& o) const { return compare(o) == 0; }
40  template<typename T> bool operator!=(const T& o) const { return compare(o) != 0; }
41  template<typename T> bool operator<(const T& o) const { return compare(o) < 0; }
42  template<typename T> bool operator<=(const T& o) const { return compare(o) <= 0; }
43  template<typename T> bool operator>(const T& o) const { return compare(o) > 0; }
44  template<typename T> bool operator>=(const T& o) const { return compare(o) >= 0; }
45 
46  bool is_missing() const { return value == nullptr; }
47 
48  operator const char*() const { return value; }
49  operator std::string() const;
50 };
51 
52 }
53 #endif
Common base types used by most of DB-All.e code.
Copyright (C) 2008–2010 ARPA-SIM urpsim@smr.arpa.emr.it
Definition: cmdline.h:17
A station identifier, that can be any string (including the empty string) or a missing value...
Definition: core/defs.h:19