blob: 7da47a6b2fc4d76db177d843caa1b70f063d20b9 [file] [log] [blame]
Alexander Afanasyevc169a812014-05-20 20:37:29 -04001/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
Jeff Thompsonc0573432013-09-19 17:41:36 -07002/**
Alexander Afanasyevc169a812014-05-20 20:37:29 -04003 * Copyright (c) 2013-2014 Regents of the University of California.
Alexander Afanasyevdfa52c42014-04-24 21:10:11 -07004 *
5 * This file is part of ndn-cxx library (NDN C++ library with eXperimental eXtensions).
Alexander Afanasyevdfa52c42014-04-24 21:10:11 -07006 *
Alexander Afanasyevc169a812014-05-20 20:37:29 -04007 * ndn-cxx library is free software: you can redistribute it and/or modify it under the
8 * terms of the GNU Lesser General Public License as published by the Free Software
9 * Foundation, either version 3 of the License, or (at your option) any later version.
10 *
11 * ndn-cxx library is distributed in the hope that it will be useful, but WITHOUT ANY
12 * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A
13 * PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details.
14 *
15 * You should have received copies of the GNU General Public License and GNU Lesser
16 * General Public License along with ndn-cxx, e.g., in COPYING.md file. If not, see
17 * <http://www.gnu.org/licenses/>.
18 *
19 * See AUTHORS.md for complete list of ndn-cxx authors and contributors.
Jeff Thompsonc0573432013-09-19 17:41:36 -070020 */
21
Alexander Afanasyev258ec2b2014-05-14 16:15:37 -070022#ifndef NDN_ENCODING_OID_HPP
23#define NDN_ENCODING_OID_HPP
Jeff Thompsonc0573432013-09-19 17:41:36 -070024
Alexander Afanasyeve2dcdfd2014-02-07 15:53:28 -080025#include "../common.hpp"
Jeff Thompsonc0573432013-09-19 17:41:36 -070026
Alexander Afanasyev258ec2b2014-05-14 16:15:37 -070027#include <vector>
28
Alexander Afanasyev2a7f7202014-04-23 14:25:29 -070029namespace CryptoPP {
30class BufferedTransformation;
31}
Alexander Afanasyev0ea6e082013-12-26 15:16:37 -080032
Jeff Thompsonc0573432013-09-19 17:41:36 -070033namespace ndn {
34
Alexander Afanasyev2a7f7202014-04-23 14:25:29 -070035class OID
36{
Jeff Thompsonc0573432013-09-19 17:41:36 -070037public:
Alexander Afanasyevfdbfc6d2014-04-14 15:12:11 -070038 OID ()
Jeff Thompsonc0573432013-09-19 17:41:36 -070039 {
40 }
Alexander Afanasyevfdbfc6d2014-04-14 15:12:11 -070041
42 OID(const char* oid);
Alexander Afanasyev049f8f72013-12-26 19:07:15 -080043
Jeff Thompsonc0573432013-09-19 17:41:36 -070044 OID(const std::string& oid);
45
46 OID(const std::vector<int>& oid)
Alexander Afanasyevfdbfc6d2014-04-14 15:12:11 -070047 : m_oid(oid)
Jeff Thompsonc0573432013-09-19 17:41:36 -070048 {
49 }
50
Alexander Afanasyevfdbfc6d2014-04-14 15:12:11 -070051 const std::vector<int>&
Jeff Thompsonc0573432013-09-19 17:41:36 -070052 getIntegerList() const
53 {
Alexander Afanasyevfdbfc6d2014-04-14 15:12:11 -070054 return m_oid;
Jeff Thompsonc0573432013-09-19 17:41:36 -070055 }
56
57 void
58 setIntegerList(const std::vector<int>& value){
Alexander Afanasyevfdbfc6d2014-04-14 15:12:11 -070059 m_oid = value;
Jeff Thompsonc0573432013-09-19 17:41:36 -070060 }
61
Alexander Afanasyevfdbfc6d2014-04-14 15:12:11 -070062 std::string
Jeff Thompson6c729a22013-12-20 10:37:59 -080063 toString() const;
Jeff Thompsonc0573432013-09-19 17:41:36 -070064
Jeff Thompson6c729a22013-12-20 10:37:59 -080065 bool operator == (const OID& oid) const
Jeff Thompsonc0573432013-09-19 17:41:36 -070066 {
67 return equal(oid);
68 }
69
Jeff Thompson6c729a22013-12-20 10:37:59 -080070 bool operator != (const OID& oid) const
Jeff Thompsonc0573432013-09-19 17:41:36 -070071 {
72 return !equal(oid);
73 }
Alexander Afanasyev0ea6e082013-12-26 15:16:37 -080074
75 void
Alexander Afanasyevfdbfc6d2014-04-14 15:12:11 -070076 encode(CryptoPP::BufferedTransformation& out) const;
Alexander Afanasyev0ea6e082013-12-26 15:16:37 -080077
78 void
Alexander Afanasyevfdbfc6d2014-04-14 15:12:11 -070079 decode(CryptoPP::BufferedTransformation& in);
Jeff Thompsonc0573432013-09-19 17:41:36 -070080
Alexander Afanasyev049f8f72013-12-26 19:07:15 -080081
82private:
83 void
Alexander Afanasyevfdbfc6d2014-04-14 15:12:11 -070084 construct(const std::string& value);
85
Alexander Afanasyev049f8f72013-12-26 19:07:15 -080086 bool
87 equal(const OID& oid) const;
88
89private:
Alexander Afanasyevfdbfc6d2014-04-14 15:12:11 -070090 std::vector<int> m_oid;
Jeff Thompsonc0573432013-09-19 17:41:36 -070091};
92
93}
94
Alexander Afanasyev258ec2b2014-05-14 16:15:37 -070095#endif // NDN_ENCODING_OID_HPP