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