blob: 9dc846f5036fb6728df779a42dfc4afbfafdcc2e [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
Alexander Afanasyev258ec2b2014-05-14 16:15:37 -070013#ifndef NDN_ENCODING_OID_HPP
14#define NDN_ENCODING_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 Afanasyev258ec2b2014-05-14 16:15:37 -070018#include <vector>
19
Alexander Afanasyev2a7f7202014-04-23 14:25:29 -070020namespace CryptoPP {
21class BufferedTransformation;
22}
Alexander Afanasyev0ea6e082013-12-26 15:16:37 -080023
Jeff Thompsonc0573432013-09-19 17:41:36 -070024namespace ndn {
25
Alexander Afanasyev2a7f7202014-04-23 14:25:29 -070026class OID
27{
Jeff Thompsonc0573432013-09-19 17:41:36 -070028public:
Alexander Afanasyevfdbfc6d2014-04-14 15:12:11 -070029 OID ()
Jeff Thompsonc0573432013-09-19 17:41:36 -070030 {
31 }
Alexander Afanasyevfdbfc6d2014-04-14 15:12:11 -070032
33 OID(const char* oid);
Alexander Afanasyev049f8f72013-12-26 19:07:15 -080034
Jeff Thompsonc0573432013-09-19 17:41:36 -070035 OID(const std::string& oid);
36
37 OID(const std::vector<int>& oid)
Alexander Afanasyevfdbfc6d2014-04-14 15:12:11 -070038 : m_oid(oid)
Jeff Thompsonc0573432013-09-19 17:41:36 -070039 {
40 }
41
Alexander Afanasyevfdbfc6d2014-04-14 15:12:11 -070042 const std::vector<int>&
Jeff Thompsonc0573432013-09-19 17:41:36 -070043 getIntegerList() const
44 {
Alexander Afanasyevfdbfc6d2014-04-14 15:12:11 -070045 return m_oid;
Jeff Thompsonc0573432013-09-19 17:41:36 -070046 }
47
48 void
49 setIntegerList(const std::vector<int>& value){
Alexander Afanasyevfdbfc6d2014-04-14 15:12:11 -070050 m_oid = value;
Jeff Thompsonc0573432013-09-19 17:41:36 -070051 }
52
Alexander Afanasyevfdbfc6d2014-04-14 15:12:11 -070053 std::string
Jeff Thompson6c729a22013-12-20 10:37:59 -080054 toString() const;
Jeff Thompsonc0573432013-09-19 17:41:36 -070055
Jeff Thompson6c729a22013-12-20 10:37:59 -080056 bool operator == (const OID& oid) const
Jeff Thompsonc0573432013-09-19 17:41:36 -070057 {
58 return equal(oid);
59 }
60
Jeff Thompson6c729a22013-12-20 10:37:59 -080061 bool operator != (const OID& oid) const
Jeff Thompsonc0573432013-09-19 17:41:36 -070062 {
63 return !equal(oid);
64 }
Alexander Afanasyev0ea6e082013-12-26 15:16:37 -080065
66 void
Alexander Afanasyevfdbfc6d2014-04-14 15:12:11 -070067 encode(CryptoPP::BufferedTransformation& out) const;
Alexander Afanasyev0ea6e082013-12-26 15:16:37 -080068
69 void
Alexander Afanasyevfdbfc6d2014-04-14 15:12:11 -070070 decode(CryptoPP::BufferedTransformation& in);
Jeff Thompsonc0573432013-09-19 17:41:36 -070071
Alexander Afanasyev049f8f72013-12-26 19:07:15 -080072
73private:
74 void
Alexander Afanasyevfdbfc6d2014-04-14 15:12:11 -070075 construct(const std::string& value);
76
Alexander Afanasyev049f8f72013-12-26 19:07:15 -080077 bool
78 equal(const OID& oid) const;
79
80private:
Alexander Afanasyevfdbfc6d2014-04-14 15:12:11 -070081 std::vector<int> m_oid;
Jeff Thompsonc0573432013-09-19 17:41:36 -070082};
83
84}
85
Alexander Afanasyev258ec2b2014-05-14 16:15:37 -070086#endif // NDN_ENCODING_OID_HPP