blob: 0cd570de8a924d27f1854c6a3e7396fa7c497269 [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 Afanasyev2a7f7202014-04-23 14:25:29 -070014namespace CryptoPP {
15class BufferedTransformation;
16}
Alexander Afanasyev0ea6e082013-12-26 15:16:37 -080017
Jeff Thompsonc0573432013-09-19 17:41:36 -070018namespace ndn {
19
Alexander Afanasyev2a7f7202014-04-23 14:25:29 -070020class OID
21{
Jeff Thompsonc0573432013-09-19 17:41:36 -070022public:
Alexander Afanasyevfdbfc6d2014-04-14 15:12:11 -070023 OID ()
Jeff Thompsonc0573432013-09-19 17:41:36 -070024 {
25 }
Alexander Afanasyevfdbfc6d2014-04-14 15:12:11 -070026
27 OID(const char* oid);
Alexander Afanasyev049f8f72013-12-26 19:07:15 -080028
Jeff Thompsonc0573432013-09-19 17:41:36 -070029 OID(const std::string& oid);
30
31 OID(const std::vector<int>& oid)
Alexander Afanasyevfdbfc6d2014-04-14 15:12:11 -070032 : m_oid(oid)
Jeff Thompsonc0573432013-09-19 17:41:36 -070033 {
34 }
35
Alexander Afanasyevfdbfc6d2014-04-14 15:12:11 -070036 const std::vector<int>&
Jeff Thompsonc0573432013-09-19 17:41:36 -070037 getIntegerList() const
38 {
Alexander Afanasyevfdbfc6d2014-04-14 15:12:11 -070039 return m_oid;
Jeff Thompsonc0573432013-09-19 17:41:36 -070040 }
41
42 void
43 setIntegerList(const std::vector<int>& value){
Alexander Afanasyevfdbfc6d2014-04-14 15:12:11 -070044 m_oid = value;
Jeff Thompsonc0573432013-09-19 17:41:36 -070045 }
46
Alexander Afanasyevfdbfc6d2014-04-14 15:12:11 -070047 std::string
Jeff Thompson6c729a22013-12-20 10:37:59 -080048 toString() const;
Jeff Thompsonc0573432013-09-19 17:41:36 -070049
Jeff Thompson6c729a22013-12-20 10:37:59 -080050 bool operator == (const OID& oid) const
Jeff Thompsonc0573432013-09-19 17:41:36 -070051 {
52 return equal(oid);
53 }
54
Jeff Thompson6c729a22013-12-20 10:37:59 -080055 bool operator != (const OID& oid) const
Jeff Thompsonc0573432013-09-19 17:41:36 -070056 {
57 return !equal(oid);
58 }
Alexander Afanasyev0ea6e082013-12-26 15:16:37 -080059
60 void
Alexander Afanasyevfdbfc6d2014-04-14 15:12:11 -070061 encode(CryptoPP::BufferedTransformation& out) const;
Alexander Afanasyev0ea6e082013-12-26 15:16:37 -080062
63 void
Alexander Afanasyevfdbfc6d2014-04-14 15:12:11 -070064 decode(CryptoPP::BufferedTransformation& in);
Jeff Thompsonc0573432013-09-19 17:41:36 -070065
Alexander Afanasyev049f8f72013-12-26 19:07:15 -080066
67private:
68 void
Alexander Afanasyevfdbfc6d2014-04-14 15:12:11 -070069 construct(const std::string& value);
70
Alexander Afanasyev049f8f72013-12-26 19:07:15 -080071 bool
72 equal(const OID& oid) const;
73
74private:
Alexander Afanasyevfdbfc6d2014-04-14 15:12:11 -070075 std::vector<int> m_oid;
Jeff Thompsonc0573432013-09-19 17:41:36 -070076};
77
78}
79
80#endif