blob: b9b41e0532bd2493fe9b9327c62d854b1db491aa [file] [log] [blame]
Jeff Thompsonc0573432013-09-19 17:41:36 -07001/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil -*- */
2/**
Alexander Afanasyevdfa52c42014-04-24 21:10:11 -07003 * Copyright (c) 2013-2014, Regents of the University of California.
4 * All rights reserved.
5 *
6 * This file is part of ndn-cxx library (NDN C++ library with eXperimental eXtensions).
7 * See AUTHORS.md for complete list of ndn-cxx authors and contributors.
8 *
9 * This file licensed under New BSD License. See COPYING for detailed information about
10 * ndn-cxx library copyright, permissions, and redistribution restrictions.
Jeff Thompsonc0573432013-09-19 17:41:36 -070011 */
12
13#ifndef NDN_OID_HPP
Jeff Thompsone589c3f2013-10-12 17:30:50 -070014#define NDN_OID_HPP
Jeff Thompsonc0573432013-09-19 17:41:36 -070015
Alexander Afanasyeve2dcdfd2014-02-07 15:53:28 -080016#include "../common.hpp"
Jeff Thompsonc0573432013-09-19 17:41:36 -070017
Alexander Afanasyev2a7f7202014-04-23 14:25:29 -070018namespace CryptoPP {
19class BufferedTransformation;
20}
Alexander Afanasyev0ea6e082013-12-26 15:16:37 -080021
Jeff Thompsonc0573432013-09-19 17:41:36 -070022namespace ndn {
23
Alexander Afanasyev2a7f7202014-04-23 14:25:29 -070024class OID
25{
Jeff Thompsonc0573432013-09-19 17:41:36 -070026public:
Alexander Afanasyevfdbfc6d2014-04-14 15:12:11 -070027 OID ()
Jeff Thompsonc0573432013-09-19 17:41:36 -070028 {
29 }
Alexander Afanasyevfdbfc6d2014-04-14 15:12:11 -070030
31 OID(const char* oid);
Alexander Afanasyev049f8f72013-12-26 19:07:15 -080032
Jeff Thompsonc0573432013-09-19 17:41:36 -070033 OID(const std::string& oid);
34
35 OID(const std::vector<int>& oid)
Alexander Afanasyevfdbfc6d2014-04-14 15:12:11 -070036 : m_oid(oid)
Jeff Thompsonc0573432013-09-19 17:41:36 -070037 {
38 }
39
Alexander Afanasyevfdbfc6d2014-04-14 15:12:11 -070040 const std::vector<int>&
Jeff Thompsonc0573432013-09-19 17:41:36 -070041 getIntegerList() const
42 {
Alexander Afanasyevfdbfc6d2014-04-14 15:12:11 -070043 return m_oid;
Jeff Thompsonc0573432013-09-19 17:41:36 -070044 }
45
46 void
47 setIntegerList(const std::vector<int>& value){
Alexander Afanasyevfdbfc6d2014-04-14 15:12:11 -070048 m_oid = value;
Jeff Thompsonc0573432013-09-19 17:41:36 -070049 }
50
Alexander Afanasyevfdbfc6d2014-04-14 15:12:11 -070051 std::string
Jeff Thompson6c729a22013-12-20 10:37:59 -080052 toString() const;
Jeff Thompsonc0573432013-09-19 17:41:36 -070053
Jeff Thompson6c729a22013-12-20 10:37:59 -080054 bool operator == (const OID& oid) const
Jeff Thompsonc0573432013-09-19 17:41:36 -070055 {
56 return equal(oid);
57 }
58
Jeff Thompson6c729a22013-12-20 10:37:59 -080059 bool operator != (const OID& oid) const
Jeff Thompsonc0573432013-09-19 17:41:36 -070060 {
61 return !equal(oid);
62 }
Alexander Afanasyev0ea6e082013-12-26 15:16:37 -080063
64 void
Alexander Afanasyevfdbfc6d2014-04-14 15:12:11 -070065 encode(CryptoPP::BufferedTransformation& out) const;
Alexander Afanasyev0ea6e082013-12-26 15:16:37 -080066
67 void
Alexander Afanasyevfdbfc6d2014-04-14 15:12:11 -070068 decode(CryptoPP::BufferedTransformation& in);
Jeff Thompsonc0573432013-09-19 17:41:36 -070069
Alexander Afanasyev049f8f72013-12-26 19:07:15 -080070
71private:
72 void
Alexander Afanasyevfdbfc6d2014-04-14 15:12:11 -070073 construct(const std::string& value);
74
Alexander Afanasyev049f8f72013-12-26 19:07:15 -080075 bool
76 equal(const OID& oid) const;
77
78private:
Alexander Afanasyevfdbfc6d2014-04-14 15:12:11 -070079 std::vector<int> m_oid;
Jeff Thompsonc0573432013-09-19 17:41:36 -070080};
81
82}
83
84#endif