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