Jetson Inference
DNN Vision Library
URI.h
Go to the documentation of this file.
1 /*
2  * Copyright (c) 2020, NVIDIA CORPORATION. All rights reserved.
3  *
4  * Permission is hereby granted, free of charge, to any person obtaining a
5  * copy of this software and associated documentation files (the "Software"),
6  * to deal in the Software without restriction, including without limitation
7  * the rights to use, copy, modify, merge, publish, distribute, sublicense,
8  * and/or sell copies of the Software, and to permit persons to whom the
9  * Software is furnished to do so, subject to the following conditions:
10  *
11  * The above copyright notice and this permission notice shall be included in
12  * all copies or substantial portions of the Software.
13  *
14  * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
15  * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
16  * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
17  * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
18  * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
19  * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
20  * DEALINGS IN THE SOFTWARE.
21  */
22 
23 #ifndef __URI_RESOURCE_H_
24 #define __URI_RESOURCE_H_
25 
26 
27 #include <string>
28 
29 
101 struct URI
102 {
103 public:
107  URI();
108 
113  URI( const char* uri );
114 
119  bool Parse( const char* uri );
120 
124  void Print( const char* prefix="" ) const;
125 
129  inline const char* c_str() const { return string.c_str(); }
130 
134  operator const char* () const { return string.c_str(); }
135 
139  operator std::string () const { return string; }
140 
144  inline void operator = (const char* uri ) { Parse(uri); }
145 
149  inline void operator = (const std::string& uri ) { Parse(uri.c_str()); }
150 
154  std::string string;
155 
159  std::string protocol;
160 
164  std::string path;
165 
169  std::string extension;
170 
174  std::string location;
175 
179  int port;
180 };
181 
182 #endif
183 
URI::protocol
std::string protocol
Protocol string (e.g.
Definition: URI.h:159
URI::c_str
const char * c_str() const
Cast to C-style string (const char*)
Definition: URI.h:129
URI::path
std::string path
Path (for a network URI this comes after the port)
Definition: URI.h:164
URI::string
std::string string
Full resource URI (what was originally parsed)
Definition: URI.h:154
URI::location
std::string location
Path, IP address, or device name.
Definition: URI.h:174
URI::operator=
void operator=(const char *uri)
Assignment operator (parse URI string)
Definition: URI.h:144
URI::port
int port
IP port, camera port, ect.
Definition: URI.h:179
URI::URI
URI()
Default constructor.
URI
Resource URI of a video device, IP stream, or file/directory.
Definition: URI.h:101
URI::Parse
bool Parse(const char *uri)
Parse the URI from the given resource string.
URI::string
operator std::string() const
Cast to std::string
Definition: URI.h:139
URI::Print
void Print(const char *prefix="") const
Log the URI, with an optional prefix label.
URI::extension
std::string extension
File extension (for files only, otherwise empty)
Definition: URI.h:169