]> git.stg.codes - stg.git/blob - projects/stargazer/plugins/other/smux/types.h
Use std::lock_guard instead of STG_LOCKER.
[stg.git] / projects / stargazer / plugins / other / smux / types.h
1 #pragma once
2
3 #pragma GCC diagnostic push
4 #pragma GCC diagnostic ignored "-Wold-style-cast"
5 #include "stg/OBJECT_IDENTIFIER.h"
6 #pragma GCC diagnostic pop
7
8 #include <string>
9 #include <vector>
10 #include <iostream>
11
12 class OID
13 {
14     public:
15         explicit OID(const std::string & str);
16         OID(const char * str, size_t length);
17         explicit OID(const std::vector<uint32_t> & arcs);
18         OID(const uint32_t * arcs, size_t length);
19         explicit OID(OBJECT_IDENTIFIER_t * oid);
20         OID(const OID & rvalue);
21         ~OID();
22
23         bool addSuffix(const char * suffix, size_t length);
24         bool addSuffix(const std::string & suffix);
25         bool addSuffix(const uint32_t * suffix, size_t length);
26         bool addSuffix(const std::vector<uint32_t> & suffix);
27         bool addSuffix(uint32_t a, uint32_t b);
28
29         OID copyWithSuffix(const char * suffix, size_t length) const;
30         OID copyWithSuffix(const std::string & suffix) const;
31         OID copyWithSuffix(const uint32_t * suffix, size_t length) const;
32         OID copyWithSuffix(const std::vector<uint32_t> & suffix) const;
33         OID copyWithSuffix(uint32_t a, uint32_t b) const;
34
35         std::string ToString() const;
36         const std::vector<uint32_t> & ToVector() const { return arcs; }
37         void ToOID(OBJECT_IDENTIFIER_t * oid) const;
38
39         OID & operator=(const OID & rvalue);
40         bool operator==(const OID & rvalue) const;
41         bool operator!=(const OID & rvalue) const { return !operator==(rvalue); }
42         bool operator<(const OID & rvalue) const;
43         bool operator>(const OID & rvalue) const
44         { return !operator==(rvalue) && !operator<(rvalue); }
45
46         bool PrefixLess(const OID & rvalue) const;
47
48         friend std::ostream & operator<<(std::ostream & stream, const OID & oid);
49
50     private:
51         std::vector<uint32_t> arcs;
52 };
53
54 inline
55 bool PrefixLess(const OID & a, const OID & b)
56 {
57 return a.PrefixLess(b);
58 }