blob: e7b1beb8a26035f313831bac0864103a98a47b2e [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:
Alexander Afanasyevfdbfc6d2014-04-14 15:12:11 -070020 OID ()
Jeff Thompsonc0573432013-09-19 17:41:36 -070021 {
22 }
Alexander Afanasyevfdbfc6d2014-04-14 15:12:11 -070023
24 OID(const char* oid);
Alexander Afanasyev049f8f72013-12-26 19:07:15 -080025
Jeff Thompsonc0573432013-09-19 17:41:36 -070026 OID(const std::string& oid);
27
28 OID(const std::vector<int>& oid)
Alexander Afanasyevfdbfc6d2014-04-14 15:12:11 -070029 : m_oid(oid)
Jeff Thompsonc0573432013-09-19 17:41:36 -070030 {
31 }
32
Alexander Afanasyevfdbfc6d2014-04-14 15:12:11 -070033 const std::vector<int>&
Jeff Thompsonc0573432013-09-19 17:41:36 -070034 getIntegerList() const
35 {
Alexander Afanasyevfdbfc6d2014-04-14 15:12:11 -070036 return m_oid;
Jeff Thompsonc0573432013-09-19 17:41:36 -070037 }
38
39 void
40 setIntegerList(const std::vector<int>& value){
Alexander Afanasyevfdbfc6d2014-04-14 15:12:11 -070041 m_oid = value;
Jeff Thompsonc0573432013-09-19 17:41:36 -070042 }
43
Alexander Afanasyevfdbfc6d2014-04-14 15:12:11 -070044 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
Alexander Afanasyevfdbfc6d2014-04-14 15:12:11 -070058 encode(CryptoPP::BufferedTransformation& out) const;
Alexander Afanasyev0ea6e082013-12-26 15:16:37 -080059
60 void
Alexander Afanasyevfdbfc6d2014-04-14 15:12:11 -070061 decode(CryptoPP::BufferedTransformation& in);
Jeff Thompsonc0573432013-09-19 17:41:36 -070062
Alexander Afanasyev049f8f72013-12-26 19:07:15 -080063
64private:
65 void
Alexander Afanasyevfdbfc6d2014-04-14 15:12:11 -070066 construct(const std::string& value);
67
Alexander Afanasyev049f8f72013-12-26 19:07:15 -080068 bool
69 equal(const OID& oid) const;
70
71private:
Alexander Afanasyevfdbfc6d2014-04-14 15:12:11 -070072 std::vector<int> m_oid;
Jeff Thompsonc0573432013-09-19 17:41:36 -070073};
74
75}
76
77#endif