OpFlex Framework  1.3.0
URI.h
Go to the documentation of this file.
1 /* -*- C++ -*-; c-basic-offset: 4; indent-tabs-mode: nil */
6 /*
7  * Copyright (c) 2014 Cisco Systems, Inc. and others. All rights reserved.
8  *
9  * This program and the accompanying materials are made available under the
10  * terms of the Eclipse Public License v1.0 which accompanies this distribution,
11  * and is available at http://www.eclipse.org/legal/epl-v10.html
12  */
13 
14 #ifndef MODB_URI_H
15 #define MODB_URI_H
16 
17 #include <boost/shared_ptr.hpp>
18 #include <boost/any.hpp>
19 #include <boost/functional/hash.hpp>
20 #include <string>
21 #include <vector>
22 
23 namespace opflex {
24 namespace modb {
25 
41 class URI {
42 public:
46  explicit URI(const boost::shared_ptr<const std::string>& uri);
47 
51  explicit URI(const std::string& uri);
52 
56  URI(const URI& uri);
57 
61  ~URI();
62 
66  const std::string& toString() const;
67 
72  void getElements(/* out */ std::vector<std::string>& elements) const;
73 
77  URI& operator=( const URI& rhs );
78 
82  static const URI ROOT;
83 
84 private:
85  boost::shared_ptr<const std::string> uri;
86  size_t hashv;
87 
88  friend bool operator==(const URI& lhs, const URI& rhs);
89  friend bool operator!=(const URI& lhs, const URI& rhs);
90  friend bool operator<(const URI& lhs, const URI& rhs);
91  friend size_t hash_value(URI const& uri);
92 };
93 
97 std::ostream & operator<<(std::ostream &os, const URI& uri);
98 
102 bool operator==(const URI& lhs, const URI& rhs);
106 bool operator!=(const URI& lhs, const URI& rhs);
110 bool operator<(const URI& lhs, const URI& rhs);
115 size_t hash_value(URI const& uri);
116 
117 /* @} modb */
118 /* @} cpp */
119 
120 } /* namespace modb */
121 } /* namespace opflex */
122 
123 #endif /* MODB_URI_H */
~URI()
Destroy the URI.
std::ostream & operator<<(std::ostream &os, const URI &uri)
URI stream insertion.
bool operator==(const URI &lhs, const URI &rhs)
Check for URI equality.
URI(const boost::shared_ptr< const std::string > &uri)
Construct a URI using the given string representation.
URI & operator=(const URI &rhs)
Assignment operator.
bool operator<(const URI &lhs, const URI &rhs)
Comparison operator for sorting.
friend size_t hash_value(URI const &uri)
Compute a hash value for the URI, making URI suitable as a key in an unordered_map.
static const URI ROOT
Static root URI.
Definition: URI.h:82
bool operator!=(const URI &lhs, const URI &rhs)
Check for URI inequality.
size_t hash_value(URI const &uri)
Compute a hash value for the URI, making URI suitable as a key in an unordered_map.
const std::string & toString() const
Get the URI represented as a string.
friend bool operator<(const URI &lhs, const URI &rhs)
Comparison operator for sorting.
A URI is used to identify managed objects in the MODB.
Definition: URI.h:41
friend bool operator!=(const URI &lhs, const URI &rhs)
Check for URI inequality.
void getElements(std::vector< std::string > &elements) const
Parse the URI and get the unescaped path elements from the URI.
friend bool operator==(const URI &lhs, const URI &rhs)
Check for URI equality.