Software and Services, Portable Libraries  2019.Mar.01
A library for managing digital certificates
Uri.hpp
1 //
2 // BEGIN_DOUGLAS_MARK_ROYER_COPYRIGHT
3 //
4 // Copyright (C) 1993-2015 Douglas Mark Royer, All Rights Reserved.
5 //
6 // NOTICE:
7 //
8 // THIS SOURCE CODE BELONGS TO DOUGLAS MARK ROYER
9 // CORPORATION, A NEVADA CORPORATION. THIS CODE IS PROPERTY
10 // OF THE COPYRIGHT HOLDER AND IS NOT TO BE DIVULGED OR USED BY
11 // PARTIES WHO HAVE NOT RECEIVED WRITTEN AUTHORIZATION FROM THE OWNER.
12 //
13 // THIS SOFTWARE AND MANUAL ARE BOTH PROTECTED BY UNITED STATES
14 // COPYRIGHT LAW (TITLE 17 UNITED STATES CODE). UNAUTHORIZED REPRODUCTION
15 // AND/OR SALE MAY RESULT IN IMPRISONMENT OF UP TO ONE YEAR AND FINES
16 // OF UP TO $100,000 (17 USC 506). COPYRIGHT INFRINGERS MAY ALSO
17 // BE SUBJECT TO CIVIL LIABILITY.
18 //
19 // THIS NOTICE AND THE ABOVE COPYRIGHT NOTICE MUST REMAIN IN ALL
20 // COPIES AND ANY DERIVED WORK.
21 //
22 // ALL OF THIS CODE IS ORIGINAL WORK BY THE COPYRIGHT HOLDER.
23 //
24 // THIS DOCUMENT AND THE INFORMATION CONTAINED HEREIN IS
25 // PROVIDED ON AN "AS IS" BASIS AND INET-CONSULTING.COM, INC.
26 // DISCLAIM ALL WARRANTIES, EXPRESS OR IMPLIED, INCLUDING BUT
27 // NOT LIMITED TO ANY WARRANTY THAT THE USE OF THE INFORMATION
28 // HEREIN WILL NOT INFRINGE ANY RIGHTS OR ANY IMPLIED
29 // WARRANTIES OF MERCHANTABILITY OR FITNESS FOR A PARTICULAR
30 // PURPOSE. ANY SERVICE CONTRACT WILL BE UNDER A SEPARATE
31 // LICENSE.
32 //
33 // END_DOUGLAS_MARK_ROYER_COPYRIGHT
34 //
35 
36 #ifndef PROJECT_CONTRACTING_LIBRARY_RFCBASIC_URI_HPP
37 #define PROJECT_CONTRACTING_LIBRARY_RFCBASIC_URI_HPP
38 
39 #ifndef EXPORT_RFC
40 #ifdef BUILDING_LIBRARY_RFC
41 #define EXPORT_RFC EXPORT_OUT
42 #else
43 #define EXPORT_RFC EXPORT_IN
44 #endif
45 #endif
46 
47 #ifdef WIN32
48 #pragma warning (disable : 4251)
49 #endif
50 
51 #ifdef BUILDING_LIBRARY_RFC
52 #include "rfcTokens.h"
53 #else
54 #include <SaS/RfcBasic/rfcTokens.h>
55 #endif
56 
57 #include <SaS/Common/Base.hpp>
58 #include <SaS/Common/String.hpp>
59 #include <SaS/Common/StringCache.hpp>
60 
61 #include <sys/types.h>
62 #include <string>
63 #include <map>
64 
65 using namespace std;
67 
68 namespace SoftwareAndServices
69 {
70  namespace Library
71  {
72  namespace RfcBasic
73  {
74 
81  class EXPORT_RFC Uri
82  : public instance<Uri>
83  {
84 
85  public:
86 
87  static const char * URICap_s;
88  static const char * URICid_s;
89  static const char * URIFile_s;
90  static const char * URIFtp_s;
91  static const char * URIGopher_s;
92  static const char * URIHttp_s;
93  static const char * URIHttps_s;
94  static const char * URILdap_s;
95  static const char * URIMailTo_s;
96  static const char * URIMid_s;
97  static const char * URINews_s;
98  static const char * URINntp_s;
99  static const char * URIProsperp_s;
100  static const char * URITelnet_s;
101  static const char * URIWais_s;
102  static const char * URIWebCal_s;
103  static const char * URIWebDav_s;
104  static const char * URICalDav_s;
105  static const char * URISql_s;
106  static const char * URILotusCal_s;
107  static const char * URIMicrosoftCal_s;
108  static const char * URIOracleCal_s;
109  static const char * URISip_s;
110  static const char * URISips_s;
111 
116  class EXPORT_RFC NameValuePair
117  {
118 
119  public:
120 
124  NameValuePair();
125 
133  NameValuePair(const char * TheName, const char * TheValue);
134 
138  virtual ~NameValuePair();
139 
143  const char * Name() const;
144 
148  const char * Value() const;
149 
150  private:
151 
155  const char * _Name;
156 
160  const char * _Value;
161  };
162 
167  class EXPORT_RFC Parameter
168  : public NameValuePair
169  {
170  public:
171 
179  Parameter(const char * TheName, const char * TheValue);
180  };
181 
186  class EXPORT_RFC Header
187  : public NameValuePair
188  {
189  public:
190 
198  Header(const char * TheName, const char * TheValue);
199  };
200 
205  enum Uri_t {
206  Other_t,
207 
212 
217 
222 
225 
228 
231 
234 
237 
240 
246 
249 
252 
255 
258 
261 
264 
267 
270 
276 
281 
287 
293 
296 
299 
300  URI_LAST
301  };
302 
306  Uri();
307 
311  virtual ~Uri();
312 
316  Uri_t GetSchemeType() const;
317 
321  const char * GetScheme() const;
322 
326  const char * GetSchemeSpecific() const;
327 
331  const char * GetServer() const;
332 
340  short GetPort() const;
341 
345  const char * GetUser() const;
346 
350  const char * GetPassword() const;
351 
359  void SetSchemeType(const Uri_t type,
360  const char * otherType = NULL);
361 
369  void SetScheme(const char * type);
370 
376  void SetSchemeSpecific(const char * value);
377 
383  void SetServer(const char * server);
384 
391  void SetPort(const int port);
392 
398  void SetUser(const char * user);
399 
405  void SetPassword(const char * pw);
406 
413  bool IsUri(const char * IsSuppotedUri) const;
414 
422  bool Parse(const char * aString);
423 
431  virtual bool Sprint(string * Results) const;
432 
440  virtual bool Sprint(String & Results) const;
441 
452  bool Sprint(char * resultString,
453  const size_t resultStringMaxSize) const;
454 
458  const char * GetUri() const;
459 
467  bool operator==(const Uri * Other) const;
468 
476  bool operator!=(const Uri * Other) const;
477 
485  bool operator==(const Uri & Other) const;
486 
494  bool operator!=(const Uri & Other) const;
495 
503  bool operator==(const char * Other) const;
504 
512  bool operator!=(const char * Other) const;
513 
521  void AddParameter(const char * TheName,
522  const char * TheValue);
523 
531  void AddHeader(const char * TheName,
532  const char * TheValue);
533 
537  size_t ParameterCount() const;
538 
542  size_t HeaderCount() const;
543 
550  const Parameter * GetParameter(unsigned long nTh) const;
551 
558  const Header * GetHeader(unsigned long nTh) const;
559 
568  const Parameter * GetParameter(const char * TheName) const;
569 
578  const Header * GetHeader(const char * TheName) const;
579 
583  static const char * UriTokenTable[40];
584 
585  private:
586  Uri_t _uriType;
587 
588  mutable const char * _scheme;
589  mutable const char * _schemeSpecific;
590 
591  const char * _server;
592  int _port;
593  const char * _user;
594  const char * _password;
595 
596  std::map<const char*,Parameter*> _Parameters;
597  std::map<const char*,Header*> _Headers;
598 
599  // Cached - hence mutable
600  //
601  mutable const char * _fullUri;
602  };
603 
604  }
605  }
606 }
607 
608 #endif //PROJECT_CONTRACTING_LIBRARY_RFCBASIC_URI_HPP
FILE uri (direct file I/O - no network needed)
Definition: Uri.hpp:221
Content ID (Used to identify an attachment in a MIME message)
Definition: Uri.hpp:216
STL namespace.
A basic implementation an a generic URI.
Definition: Uri.hpp:81
Generic text parsing routines.
Definition: Parse.hpp:102
Uri_t
The currently known URI types.
Definition: Uri.hpp:205
LDAP uri (Directory Services)
Definition: Uri.hpp:236
Each one holds one header Value.
Definition: Uri.hpp:186
Message ID uri (Used in MIME message and some IMAP and POP server to identify a unique message) ...
Definition: Uri.hpp:245
An SQL based Calendar - for calendars - Unique to Project-Contracting.com.
Definition: Uri.hpp:275
Each one holds one name and value.
Definition: Uri.hpp:116
Lotus URI - for calendars - Unique to Project-Contracting.com.
Definition: Uri.hpp:280
Instance counting and tracking.
Definition: instance.hpp:90
Microsoft URI - for calendars - Unique to Project-Contracting.com.
Definition: Uri.hpp:286
Each one holds one Parameter value.
Definition: Uri.hpp:167
Web Based Calendars (not WebDav)
Definition: Uri.hpp:263
HTTP uri (HyperText Transfer Protocol)
Definition: Uri.hpp:230
HTTPS uri (HyperText Transfer Protocol - Secure)
Definition: Uri.hpp:233
This is a class that allows:
Definition: String.hpp:114
Copyright Douglas Mark Royer DouglasRoyer@gmail.com.
Definition: Base.hpp:98
SIP URI - for Session initiation protocol.
Definition: Uri.hpp:295
Gopher uri - no long used on the internet?
Definition: Uri.hpp:227
SIPs URI - for secure (TLS) Session initiation protocol.
Definition: Uri.hpp:298
FTP uri (File Transfer Protocol)
Definition: Uri.hpp:224
Net News (Net News Transfer Protocol)
Definition: Uri.hpp:251
Oracle URI - for calendars - Unique to Project-Contracting.com.
Definition: Uri.hpp:292
EMail uri (Represents an EMAIL address)
Definition: Uri.hpp:239