From ba8541cad3a4069886444abbd1848b6ef3fff72c Mon Sep 17 00:00:00 2001 From: Mauro Sardara Date: Wed, 22 Feb 2017 14:37:37 +0100 Subject: Initial Commit: libicnet Change-Id: I10a72cb0d84b76553a85c168416b847f6a4ff5f6 Signed-off-by: Mauro Sardara --- icnet/ccnx/icnet_ccnx_name.h | 120 +++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 120 insertions(+) create mode 100644 icnet/ccnx/icnet_ccnx_name.h (limited to 'icnet/ccnx/icnet_ccnx_name.h') diff --git a/icnet/ccnx/icnet_ccnx_name.h b/icnet/ccnx/icnet_ccnx_name.h new file mode 100644 index 00000000..68c4d19e --- /dev/null +++ b/icnet/ccnx/icnet_ccnx_name.h @@ -0,0 +1,120 @@ +/* + * Copyright (c) 2017 Cisco and/or its affiliates. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at: + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#ifndef ICNET_CCNX_NAME_H_ +#define ICNET_CCNX_NAME_H_ + +#include "icnet_ccnx_common.h" + +#include +#include +#include + +extern "C" { +#include +}; + +//#include "name.hpp" +#include "icnet_ccnx_segment.h" +#include + +typedef CCNxName CCNxNameStructure; + +namespace icnet { + +namespace ccnx { + +class Name : public std::enable_shared_from_this // : public api::Name +{ + public: + Name(); + + /** + * @brief Create name + * @param uri The null-terminated URI string + */ + Name(const char *uri); + + /** + * @brief Create name from @p uri (ICN URI scheme) + * @param uri The URI string + */ + Name(std::string uri); + + Name(const Name &name); + + Name(Name &&otherName); + + Name(const CCNxNameStructure *name); + + Name &operator=(const Name &name); + + Name &operator=(Name &&name); + + bool operator==(const Name &name) const; + + bool isValid(); + + const std::string &toString(); + + void appendComponent(const Segment &component); + + void append(const Name &suffix); + + Name getPrefix(ssize_t number_of_components) const; + + Name &appendSegment(const uint64_t chunk_number); + + bool isPrefixOf(const Name &name); + + bool equals(const Name &name); + + Segment get(ssize_t index) const; + + Name getSubName(ssize_t start_component, ssize_t number_of_components = -1) const; + + bool empty() const; + + void clear(); + + std::size_t getSegmentCount(); + + std::size_t size(); + + ~Name(); + + CCNxNameStructure *getWrappedStructure() const; + + private: + + CCNxNameStructure *name_; + std::string name_string_; +}; + +std::ostream &operator<<(std::ostream &os, const Name &name); + +} // end namespace ccnx + +} // end namespace icnet + +namespace std { +template<> +struct hash { + size_t operator()(const icnet::ccnx::Name &name) const; +}; + +} // end namespace std + +#endif // ICNET_CCNX_NAME_H_ -- cgit 1.2.3-korg