Jeff Thompson | c057343 | 2013-09-19 17:41:36 -0700 | [diff] [blame] | 1 | /* -*- 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 Thompson | e589c3f | 2013-10-12 17:30:50 -0700 | [diff] [blame] | 10 | #define NDN_OID_HPP |
Jeff Thompson | c057343 | 2013-09-19 17:41:36 -0700 | [diff] [blame] | 11 | |
| 12 | #include <vector> |
| 13 | #include <string> |
| 14 | |
Alexander Afanasyev | 0ea6e08 | 2013-12-26 15:16:37 -0800 | [diff] [blame] | 15 | namespace CryptoPP { class BufferedTransformation; } |
| 16 | |
Jeff Thompson | c057343 | 2013-09-19 17:41:36 -0700 | [diff] [blame] | 17 | namespace ndn { |
| 18 | |
| 19 | class OID { |
| 20 | public: |
| 21 | OID () |
| 22 | { |
| 23 | } |
| 24 | |
Alexander Afanasyev | 049f8f7 | 2013-12-26 19:07:15 -0800 | [diff] [blame^] | 25 | OID(const char *oid); |
| 26 | |
Jeff Thompson | c057343 | 2013-09-19 17:41:36 -0700 | [diff] [blame] | 27 | OID(const std::string& oid); |
| 28 | |
| 29 | OID(const std::vector<int>& oid) |
| 30 | : oid_(oid) |
| 31 | { |
| 32 | } |
| 33 | |
| 34 | const std::vector<int> & |
| 35 | getIntegerList() const |
| 36 | { |
| 37 | return oid_; |
| 38 | } |
| 39 | |
| 40 | void |
| 41 | setIntegerList(const std::vector<int>& value){ |
| 42 | oid_ = value; |
| 43 | } |
| 44 | |
| 45 | std::string |
Jeff Thompson | 6c729a2 | 2013-12-20 10:37:59 -0800 | [diff] [blame] | 46 | toString() const; |
Jeff Thompson | c057343 | 2013-09-19 17:41:36 -0700 | [diff] [blame] | 47 | |
Jeff Thompson | 6c729a2 | 2013-12-20 10:37:59 -0800 | [diff] [blame] | 48 | bool operator == (const OID& oid) const |
Jeff Thompson | c057343 | 2013-09-19 17:41:36 -0700 | [diff] [blame] | 49 | { |
| 50 | return equal(oid); |
| 51 | } |
| 52 | |
Jeff Thompson | 6c729a2 | 2013-12-20 10:37:59 -0800 | [diff] [blame] | 53 | bool operator != (const OID& oid) const |
Jeff Thompson | c057343 | 2013-09-19 17:41:36 -0700 | [diff] [blame] | 54 | { |
| 55 | return !equal(oid); |
| 56 | } |
Alexander Afanasyev | 0ea6e08 | 2013-12-26 15:16:37 -0800 | [diff] [blame] | 57 | |
| 58 | void |
| 59 | encode(CryptoPP::BufferedTransformation &out) const; |
| 60 | |
| 61 | void |
| 62 | decode(CryptoPP::BufferedTransformation &in); |
Jeff Thompson | c057343 | 2013-09-19 17:41:36 -0700 | [diff] [blame] | 63 | |
Alexander Afanasyev | 049f8f7 | 2013-12-26 19:07:15 -0800 | [diff] [blame^] | 64 | |
| 65 | private: |
| 66 | void |
| 67 | construct(const std::string &value); |
| 68 | |
| 69 | bool |
| 70 | equal(const OID& oid) const; |
| 71 | |
| 72 | private: |
Jeff Thompson | c057343 | 2013-09-19 17:41:36 -0700 | [diff] [blame] | 73 | std::vector<int> oid_; |
| 74 | }; |
| 75 | |
| 76 | } |
| 77 | |
| 78 | #endif |