blob: 308da8ecf04cf9c5dd1caab923f2bc4026957994 [file] [log] [blame]
Jeff Thompsonc0573432013-09-19 17:41:36 -07001/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil -*- */
2/**
3 * Copyright (C) 2013 Regents of the University of California.
4 * @author: Yingdi Yu <yingdi@cs.ucla.edu>
5 * @author: Jeff Thompson <jefft0@remap.ucla.edu>
6 * See COPYING for copyright and distribution information.
7 */
8
9#ifndef NDN_OID_HPP
Jeff Thompsone589c3f2013-10-12 17:30:50 -070010#define NDN_OID_HPP
Jeff Thompsonc0573432013-09-19 17:41:36 -070011
Alexander Afanasyeve2dcdfd2014-02-07 15:53:28 -080012#include "../common.hpp"
Jeff Thompsonc0573432013-09-19 17:41:36 -070013
Alexander Afanasyev0ea6e082013-12-26 15:16:37 -080014namespace CryptoPP { class BufferedTransformation; }
15
Jeff Thompsonc0573432013-09-19 17:41:36 -070016namespace ndn {
17
18class OID {
19public:
20 OID ()
21 {
22 }
23
Alexander Afanasyev049f8f72013-12-26 19:07:15 -080024 OID(const char *oid);
25
Jeff Thompsonc0573432013-09-19 17:41:36 -070026 OID(const std::string& oid);
27
28 OID(const std::vector<int>& oid)
29 : oid_(oid)
30 {
31 }
32
33 const std::vector<int> &
34 getIntegerList() const
35 {
36 return oid_;
37 }
38
39 void
40 setIntegerList(const std::vector<int>& value){
41 oid_ = value;
42 }
43
44 std::string
Jeff Thompson6c729a22013-12-20 10:37:59 -080045 toString() const;
Jeff Thompsonc0573432013-09-19 17:41:36 -070046
Jeff Thompson6c729a22013-12-20 10:37:59 -080047 bool operator == (const OID& oid) const
Jeff Thompsonc0573432013-09-19 17:41:36 -070048 {
49 return equal(oid);
50 }
51
Jeff Thompson6c729a22013-12-20 10:37:59 -080052 bool operator != (const OID& oid) const
Jeff Thompsonc0573432013-09-19 17:41:36 -070053 {
54 return !equal(oid);
55 }
Alexander Afanasyev0ea6e082013-12-26 15:16:37 -080056
57 void
58 encode(CryptoPP::BufferedTransformation &out) const;
59
60 void
61 decode(CryptoPP::BufferedTransformation &in);
Jeff Thompsonc0573432013-09-19 17:41:36 -070062
Alexander Afanasyev049f8f72013-12-26 19:07:15 -080063
64private:
65 void
66 construct(const std::string &value);
67
68 bool
69 equal(const OID& oid) const;
70
71private:
Jeff Thompsonc0573432013-09-19 17:41:36 -070072 std::vector<int> oid_;
73};
74
75}
76
77#endif