NCBI C++ ToolKit
ncbi_url.hpp
Go to the documentation of this file.

Go to the SVN repository for this file.

1 #ifndef CORELIB___NCBI_URL__HPP
2 #define CORELIB___NCBI_URL__HPP
3 
4 /* $Id: ncbi_url.hpp 76576 2017-02-16 21:51:04Z grichenk $
5  * ===========================================================================
6  *
7  * PUBLIC DOMAIN NOTICE
8  * National Center for Biotechnology Information
9  *
10  * This software/database is a "United States Government Work" under the
11  * terms of the United States Copyright Act. It was written as part of
12  * the author's official duties as a United States Government employee and
13  * thus cannot be copyrighted. This software/database is freely available
14  * to the public for use. The National Library of Medicine and the U.S.
15  * Government have not placed any restriction on its use or reproduction.
16  *
17  * Although all reasonable efforts have been taken to ensure the accuracy
18  * and reliability of the software and data, the NLM and the U.S.
19  * Government do not and cannot warrant the performance or results that
20  * may be obtained by using this software or data. The NLM and the U.S.
21  * Government disclaim all warranties, express or implied, including
22  * warranties of performance, merchantability or fitness for any particular
23  * purpose.
24  *
25  * Please cite the author in any work or product based on this material.
26  *
27  * ===========================================================================
28  *
29  * Authors: Alexey Grichenko, Vladimir Ivanov
30  *
31  * File Description: URL parsing classes
32  *
33  */
34 
35 /// @file ncbi_url.hpp
36 ///
37 /// URL parsing classes.
38 ///
39 
40 #include <corelib/ncbi_param.hpp>
41 #include <corelib/version.hpp>
42 #include <corelib/ncbistr.hpp>
43 #include <map>
44 #include <memory>
45 
46 /** @addtogroup UTIL
47  *
48  * @{
49  */
50 
52 
53 /////////////////////////////////////////////////////////////////////////////
54 ///
55 /// IUrlEncoder::
56 ///
57 /// URL parts encoder/decoder interface. Used by CUrl.
58 ///
59 
61 {
62 public:
63  virtual ~IUrlEncoder(void) {}
64 
65  /// Encode user name
66  virtual string EncodeUser(const string& user) const = 0;
67  /// Decode user name
68  virtual string DecodeUser(const string& user) const = 0;
69  /// Encode password
70  virtual string EncodePassword(const string& password) const = 0;
71  /// Decode password
72  virtual string DecodePassword(const string& password) const = 0;
73  /// Encode path on server
74  virtual string EncodePath(const string& path) const = 0;
75  /// Decode path on server
76  virtual string DecodePath(const string& path) const = 0;
77  /// Encode URL argument name
78  virtual string EncodeArgName(const string& name) const = 0;
79  /// Decode URL argument name
80  virtual string DecodeArgName(const string& name) const = 0;
81  /// Encode URL argument value
82  virtual string EncodeArgValue(const string& value) const = 0;
83  /// Decode URL argument value
84  virtual string DecodeArgValue(const string& value) const = 0;
85  /// Encode fragment
86  virtual string EncodeFragment(const string& value) const = 0;
87  /// Decode fragment
88  virtual string DecodeFragment(const string& value) const = 0;
89 };
90 
91 
92 /// Primitive encoder - all methods return the argument value.
93 /// Used as base class for other encoders.
95 {
96 public:
97  virtual string EncodeUser(const string& user) const
98  { return user; }
99  virtual string DecodeUser(const string& user) const
100  { return user; }
101  virtual string EncodePassword(const string& password) const
102  { return password; }
103  virtual string DecodePassword(const string& password) const
104  { return password; }
105  virtual string EncodePath(const string& path) const
106  { return path; }
107  virtual string DecodePath(const string& path) const
108  { return path; }
109  virtual string EncodeArgName(const string& name) const
110  { return name; }
111  virtual string DecodeArgName(const string& name) const
112  { return name; }
113  virtual string EncodeArgValue(const string& value) const
114  { return value; }
115  virtual string DecodeArgValue(const string& value) const
116  { return value; }
117  virtual string EncodeFragment(const string& value) const
118  { return value; }
119  virtual string DecodeFragment(const string& value) const
120  { return value; }
121 };
122 
123 
124 /// Default encoder, uses the selected encoding for argument names/values
125 /// and eUrlEncode_Path for document path. Other parts of the URL are
126 /// not encoded.
128 {
129 public:
131  : m_Encode(NStr::EUrlEncode(encode)) { return; }
132  virtual string EncodeUser(const string& user) const
133  { return NStr::URLEncode(user, NStr::eUrlEnc_URIUserinfo); }
134  virtual string DecodeUser(const string& user) const
135  { return NStr::URLDecode(user); }
136  virtual string EncodePassword(const string& password) const
137  { return NStr::URLEncode(password, NStr::eUrlEnc_URIUserinfo); }
138  virtual string DecodePassword(const string& password) const
139  { return NStr::URLDecode(password); }
140  virtual string EncodePath(const string& path) const
141  { return NStr::URLEncode(path, NStr::eUrlEnc_URIPath); }
142  virtual string DecodePath(const string& path) const
143  { return NStr::URLDecode(path); }
144  virtual string EncodeArgName(const string& name) const
145  { return NStr::URLEncode(name, m_Encode); }
146  virtual string DecodeArgName(const string& name) const
147  { return NStr::URLDecode(name,
148  m_Encode == NStr::eUrlEnc_PercentOnly ?
150  virtual string EncodeArgValue(const string& value) const
151  { return NStr::URLEncode(value, m_Encode); }
152  virtual string DecodeArgValue(const string& value) const
153  { return NStr::URLDecode(value,
154  m_Encode == NStr::eUrlEnc_PercentOnly ?
156  virtual string EncodeFragment(const string& value) const
157  { return NStr::URLEncode(value, NStr::eUrlEnc_URIFragment); }
158  virtual string DecodeFragment(const string& value) const
159  { return NStr::URLDecode(value, NStr::eUrlDec_All); }
160 private:
162 };
163 
164 
165 
166 /////////////////////////////////////////////////////////////////////////////
167 ///
168 /// CUrlArgs_Parser::
169 ///
170 /// Base class for arguments parsers.
171 ///
172 
174 {
175 public:
176  CUrlArgs_Parser(void) : m_SemicolonIsNotArgDelimiter(false) {}
177  virtual ~CUrlArgs_Parser(void) {}
178 
179  /// Parse query string, call AddArgument() to store each value.
180  void SetQueryString(const string& query, NStr::EUrlEncode encode);
181  /// Parse query string, call AddArgument() to store each value.
182  void SetQueryString(const string& query,
183  const IUrlEncoder* encoder = 0);
184 
185  /// Treat semicolon as query string argument separator
186  void SetSemicolonIsNotArgDelimiter(bool enable = true)
187  {
188  m_SemicolonIsNotArgDelimiter = enable;
189  }
190 
191 protected:
192  /// Query type flag
193  enum EArgType {
194  eArg_Value, ///< Query contains name=value pairs
195  eArg_Index ///< Query contains a list of names: name1+name2+name3
196  };
197 
198  /// Process next query argument. Must be overriden to process and store
199  /// the arguments.
200  /// @param position
201  /// 1-based index of the argument in the query.
202  /// @param name
203  /// Name of the argument.
204  /// @param value
205  /// Contains argument value if query type is eArg_Value or
206  /// empty string for eArg_Index.
207  /// @param arg_type
208  /// Query type flag.
209  virtual void AddArgument(unsigned int position,
210  const string& name,
211  const string& value,
212  EArgType arg_type = eArg_Index) = 0;
213 private:
214  void x_SetIndexString(const string& query,
215  const IUrlEncoder& encoder);
216 
218 };
219 
220 
221 /////////////////////////////////////////////////////////////////////////////
222 ///
223 /// CUrlArgs::
224 ///
225 /// URL arguments list.
226 ///
227 
229 {
230 public:
231  /// Create an empty arguments set.
232  CUrlArgs(void);
233  /// Parse the query string, store the arguments.
234  CUrlArgs(const string& query, NStr::EUrlEncode decode);
235  /// Parse the query string, store the arguments.
236  CUrlArgs(const string& query, const IUrlEncoder* encoder = 0);
237 
238  /// Ampersand encoding for composed URLs
240  eAmp_Char, ///< Use & to separate arguments
241  eAmp_Entity ///< Encode '&' as "&amp;"
242  };
243 
244  /// Construct and return complete query string. Use selected amp
245  /// and name/value encodings.
246  string GetQueryString(EAmpEncoding amp_enc,
247  NStr::EUrlEncode encode) const;
248  /// Construct and return complete query string. Use selected amp
249  /// and name/value encodings.
250  string GetQueryString(EAmpEncoding amp_enc,
251  const IUrlEncoder* encoder = 0) const;
252 
253  /// Name-value pair.
254  struct SUrlArg
255  {
256  SUrlArg(const string& aname, const string& avalue)
257  : name(aname), value(avalue) { }
258  string name;
259  string value;
260  };
261  typedef SUrlArg TArg;
262  typedef list<TArg> TArgs;
263  typedef TArgs::iterator iterator;
264  typedef TArgs::const_iterator const_iterator;
265 
266  /// Check if an argument with the given name exists.
267  bool IsSetValue(const string& name) const
268  { return FindFirst(name) != m_Args.end(); }
269 
270  /// Get value for the given name. finds first of the arguments with the
271  /// given name. If the name does not exist, is_found is set to false.
272  /// If is_found is null, CUrlArgsException is thrown.
273  const string& GetValue(const string& name, bool* is_found = 0) const;
274 
275  /// Set new value for the first argument with the given name or
276  /// add a new argument.
277  void SetValue(const string& name, const string& value);
278 
279  /// Add new value even if an argument with the same name already exists.
280  void AddValue(const string& name, const string& value);
281 
282  /// Set value, remove any other values for the name.
283  void SetUniqueValue(const string& name, const string& value);
284 
285  /// Get the const list of arguments.
286  const TArgs& GetArgs(void) const
287  { return m_Args; }
288 
289  /// Get the list of arguments.
290  TArgs& GetArgs(void)
291  { return m_Args; }
292 
293  /// Find the first argument with the given name. If not found, return
294  /// GetArgs().end().
295  iterator FindFirst(const string& name);
296 
297  /// Take argument name from the iterator, find next argument with the same
298  /// name, return GetArgs().end() if not found.
299  iterator FindNext(const iterator& iter);
300 
301  /// Find the first argument with the given name. If not found, return
302  /// GetArgs().end().
303  const_iterator FindFirst(const string& name) const;
304 
305  /// Take argument name from the iterator, find next argument with the same
306  /// name, return GetArgs().end() if not found.
307  const_iterator FindNext(const const_iterator& iter) const;
308 
309  /// Select case sensitivity of arguments' names.
310  void SetCase(NStr::ECase name_case)
311  { m_Case = name_case; }
312 
313 protected:
314  virtual void AddArgument(unsigned int position,
315  const string& name,
316  const string& value,
317  EArgType arg_type);
318 private:
319  iterator x_Find(const string& name, const iterator& start);
320  const_iterator x_Find(const string& name,
321  const const_iterator& start) const;
322 
324  bool m_IsIndex;
325  TArgs m_Args;
326 };
327 
328 
329 /////////////////////////////////////////////////////////////////////////////
330 ///
331 /// CUrl::
332 ///
333 /// URL parser. Uses CUrlArgs to parse arguments.
334 ///
335 
336 #define NCBI_SCHEME_SERVICE "ncbilb"
337 
339 {
340 public:
341  /// Default constructor
342  CUrl(void);
343 
344  /// Parse the URL.
345  ///
346  /// @param url
347  /// String to parse as URL:
348  /// Generic: [scheme://[[user]:[password]@]]host[:port][/path][?args]
349  /// Special: scheme:[path]
350  /// The leading '/', if any, is included in path value.
351  /// @param encoder
352  /// URL encoder object. If not set, the default encoder will be used.
353  /// @sa CDefaultUrlEncoder
354  CUrl(const string& url, const IUrlEncoder* encoder = 0);
355 
356  /// Parse the URL.
357  ///
358  /// @param url
359  /// String to parse as URL
360  /// @param encoder
361  /// URL encoder object. If not set, the default encoder will be used.
362  /// @sa CDefaultUrlEncoder
363  void SetUrl(const string& url, const IUrlEncoder* encoder = 0);
364 
365  /// Compose the URL.
366  ///
367  /// @param amp_enc
368  /// Method of encoding ampersand.
369  /// @sa CUrlArgs::EAmpEncoding
370  /// @param encoder
371  /// URL encoder object. If not set, the default encoder will be used.
372  /// @sa CDefaultUrlEncoder
373  string ComposeUrl(CUrlArgs::EAmpEncoding amp_enc,
374  const IUrlEncoder* encoder = 0) const;
375 
376  // Access parts of the URL
377 
378  string GetScheme(void) const { return m_Scheme; }
379  void SetScheme(const string& value) { m_Scheme = value; }
380 
381  /// Generic schemes use '//' prefix (after optional scheme).
382  bool GetIsGeneric(void) const { return m_IsGeneric; }
383  void SetIsGeneric(bool value) { m_IsGeneric = value; }
384 
385  string GetUser(void) const { return m_User; }
386  void SetUser(const string& value) { m_User = value; }
387 
388  string GetPassword(void) const { return m_Password; }
389  void SetPassword(const string& value) { m_Password = value; }
390 
391  string GetHost(void) const { return m_Host; }
392  void SetHost(const string& value);
393 
394  bool IsService(void) const { return !m_Service.empty(); }
395  string GetService(void) const { return m_Service; }
396  void SetService(const string& value);
397 
398  string GetPort(void) const { return m_Port; }
399  void SetPort(const string& value) { m_Port = value; }
400 
401  string GetPath(void) const { return m_Path; }
402  void SetPath(const string& value) { m_Path = value; }
403 
404  string GetFragment(void) const { return m_Fragment; }
405  void SetFragment(const string& value) { m_Fragment = value; }
406 
407  /// Get the original (unparsed and undecoded) query string
408  string GetOriginalArgsString(void) const
409  { return m_OrigArgs; }
410 
411  /// Check if the URL contains any arguments
412  bool HaveArgs(void) const
413  { return m_ArgsList.get() != 0 && !m_ArgsList->GetArgs().empty(); }
414 
415  /// Get const list of arguments
416  const CUrlArgs& GetArgs(void) const;
417 
418  /// Get list of arguments
419  CUrlArgs& GetArgs(void);
420 
421  CUrl(const CUrl& url);
422  CUrl& operator=(const CUrl& url);
423 
424  /// Return default URL encoder.
425  ///
426  /// @sa CDefaultUrlEncoder
427  static IUrlEncoder* GetDefaultEncoder(void);
428 
429  bool IsEmpty(void) const;
430 
431  /// Flags controlling URL adjustment.
432  /// @sa CUrl::Adjust
434  fUser_Replace = 0x0001, ///< Replace user if set in 'other'
435  fUser_ReplaceIfEmpty = 0x0002, ///< Replace user only if not yet set
436  fPassword_Replace = 0x0004, ///< Replace password if set in 'other'
437  fPassword_ReplaceIfEmpty = 0x0008, ///< Replace password only if not yet set
438  fPath_Replace = 0x0010, ///< Replace path
439  fPath_Append = 0x0020, ///< Append new path to the existing one
440  fFragment_Replace = 0x0040, ///< Replace fragment if set in 'other'
441  fFragment_ReplaceIfEmpty = 0x0080, ///< Replace fragment only if not yet set
442  fArgs_Replace = 0x0100, ///< Discard all args, replace with args from 'other'
443  fArgs_Append = 0x0200, ///< Append args, allow duplicate names and values
444  fArgs_Merge = 0x0400 ///< Append new args; replace values of existing args,
445  ///< do not allow to set multiple values with the same name
446  };
447  typedef int TAdjustFlags;
448 
449  /// Adjust this URL using information from 'other' URL.
450  /// Scheme, host and port are never changed. Other parts can be replaced or merged
451  /// depending on the flags.
452  /// Throw CUrlException if the flags are inconsistent (e.g. both fPath_Replace and fPath_Append are set).
453  void Adjust(const CUrl& other, TAdjustFlags flags);
454 
455 private:
456  // Set values with verification
457  void x_SetScheme(const string& scheme, const IUrlEncoder& encoder);
458  void x_SetUser(const string& user, const IUrlEncoder& encoder);
459  void x_SetPassword(const string& password, const IUrlEncoder& encoder);
460  void x_SetHost(const string& host, const IUrlEncoder& encoder);
461  void x_SetService(const string& service);
462  void x_SetPort(const string& port, const IUrlEncoder& encoder);
463  void x_SetPath(const string& path, const IUrlEncoder& encoder);
464  void x_SetArgs(const string& args, const IUrlEncoder& encoder);
465  void x_SetFragment(const string& fragment, const IUrlEncoder& encoder);
466 
467  string m_Scheme;
468  bool m_IsGeneric; // generic schemes include '//' delimiter
469  string m_User;
470  string m_Password;
471  string m_Host;
472  string m_Service;
473  string m_Port;
474  string m_Path;
475  string m_Fragment;
476  string m_OrigArgs;
478 };
479 
480 
481 /////////////////////////////////////////////////////////////////////////////
482 ///
483 /// CUrlException --
484 ///
485 /// Exceptions to be used by CUrl.
486 ///
487 
488 class CUrlException : public CException
489 {
490 public:
491  enum EErrCode {
492  eName, //< Argument does not exist
493  eNoArgs, //< CUrl contains no arguments
494  eFlags //< Inconsistent flags passed to Adjust()
495  };
496  virtual const char* GetErrCodeString(void) const
497  {
498  switch ( GetErrCode() ) {
499  case eName: return "Unknown argument name";
500  case eNoArgs: return "Arguments list is empty";
501  case eFlags: return "Inconsistent flags set";
502  default: return CException::GetErrCodeString();
503  }
504  }
505 
507 };
508 
509 
510 /////////////////////////////////////////////////////////////////////////////
511 ///
512 /// CUrlParserException --
513 ///
514 /// Exceptions used by the URL parser
515 
516 class CUrlParserException : public CParseTemplException<CUrlException>
517 {
518 public:
519  enum EErrCode {
520  eFormat //< Invalid URL format
521  };
522 
523  virtual const char* GetErrCodeString(void) const
524  {
525  switch (GetErrCode()) {
526  case eFormat: return "Url format error";
527  default: return CException::GetErrCodeString();
528  }
529  }
530 
533  std::string::size_type);
534 };
535 
536 
537 //////////////////////////////////////////////////////////////////////////////
538 //
539 // Inline functions
540 //
541 //////////////////////////////////////////////////////////////////////////////
542 
543 
544 // CUrl
545 
546 inline
547 void CUrl::SetHost(const string& host)
548 {
549  m_Service.clear();
550  m_Host = host;
551 }
552 
553 inline
554 void CUrl::SetService(const string& service)
555 {
556  m_Host.clear();
557  m_Service = service;
558 }
559 
560 inline
561 void CUrl::x_SetScheme(const string& scheme,
562  const IUrlEncoder& /*encoder*/)
563 {
564  m_Scheme = scheme;
565 }
566 
567 inline
568 void CUrl::x_SetUser(const string& user,
569  const IUrlEncoder& encoder)
570 {
571  m_User = encoder.DecodeUser(user);
572 }
573 
574 inline
575 void CUrl::x_SetPassword(const string& password,
576  const IUrlEncoder& encoder)
577 {
578  m_Password = encoder.DecodePassword(password);
579 }
580 
581 inline
582 void CUrl::x_SetHost(const string& host,
583  const IUrlEncoder& /*encoder*/)
584 {
585  m_Host = host;
586  m_Service.clear();
587 }
588 
589 inline
590 void CUrl::x_SetService(const string& service)
591 {
592  m_Service = NStr::URLDecode(service);
593 }
594 
595 inline
596 void CUrl::x_SetPort(const string& port,
597  const IUrlEncoder& /*encoder*/)
598 {
599  NStr::StringToInt(port);
600  m_Port = port;
601 }
602 
603 inline
604 void CUrl::x_SetPath(const string& path,
605  const IUrlEncoder& encoder)
606 {
607  m_Path = encoder.DecodePath(path);
608 }
609 
610 inline
611 void CUrl::x_SetFragment(const string& fragment,
612  const IUrlEncoder& encoder)
613 {
614  m_Fragment = encoder.DecodeFragment(fragment);
615 }
616 
617 inline
618 void CUrl::x_SetArgs(const string& args,
619  const IUrlEncoder& encoder)
620 {
621  m_OrigArgs = args;
622  m_ArgsList.reset(new CUrlArgs(m_OrigArgs, &encoder));
623 }
624 
625 
626 inline
628 {
629  if ( !m_ArgsList.get() ) {
631  }
632  return *m_ArgsList;
633 }
634 
635 
636 inline
638 {
639  return x_Find(name, m_Args.begin());
640 }
641 
642 
643 inline
645 {
646  return x_Find(name, m_Args.begin());
647 }
648 
649 
650 inline
652 {
653  const_iterator next = iter;
654  ++next;
655  return x_Find(iter->name, next);
656 }
657 
658 
659 inline
661 {
662  iterator next = iter;
663  ++next;
664  return x_Find(iter->name, next);
665 }
666 
667 /* @} */
668 
670 
671 #endif /* CORELIB___NCBI_URL__HPP */
EUrlEncode
Definition: cgi_util.hpp:56
EAdjustFlags
Flags controlling URL adjustment.
Definition: ncbi_url.hpp:433
void SetQueryString(const string &query, const IUrlEncoder *encoder=0)
Definition: cgi_util.hpp:99
virtual string DecodeFragment(const string &value) const
Decode fragment.
Definition: ncbi_url.hpp:119
TArgs m_Args
Definition: ncbi_url.hpp:325
TArgs & GetArgs(void)
Get the list of arguments.
Definition: ncbi_url.hpp:290
Definition: dbpivot.c:60
void x_SetUser(const string &user, const IUrlEncoder &encoder)
Definition: ncbi_url.hpp:568
void SetPort(const string &value)
Definition: ncbi_url.hpp:399
void x_SetService(const string &service)
Definition: ncbi_url.hpp:590
virtual string EncodeArgName(const string &name) const
Encode URL argument name.
Definition: ncbi_url.hpp:144
string GetPassword(void) const
Definition: ncbi_url.hpp:388
string m_Port
Definition: ncbi_url.hpp:473
virtual void AddArgument(unsigned int position, const string &name, const string &value, EArgType arg_type=eArg_Index)=0
Process next query argument.
string m_Path
Definition: ncbi_url.hpp:474
iterator FindNext(const iterator &iter)
Take argument name from the iterator, find next argument with the same name, return GetArgs()...
Definition: ncbi_url.hpp:660
virtual string DecodeArgValue(const string &value) const
Decode URL argument value.
Definition: ncbi_url.hpp:152
Default encoder, uses the selected encoding for argument names/values and eUrlEncode_Path for documen...
Definition: ncbi_url.hpp:127
string GetPort(void) const
Definition: ncbi_url.hpp:398
bool HaveArgs(void) const
Check if the URL contains any arguments.
Definition: ncbi_url.hpp:412
Query contains name=value pairs.
Definition: ncbi_url.hpp:194
void SetHost(const string &value)
Definition: ncbi_url.hpp:547
bool IsSetValue(const string &name) const
Check if an argument with the given name exists.
Definition: ncbi_url.hpp:267
virtual ~IUrlEncoder(void)
Definition: ncbi_url.hpp:63
list< TArg > TArgs
Definition: ncbi_url.hpp:262
virtual string EncodePassword(const string &password) const
Encode password.
Definition: ncbi_url.hpp:101
virtual string EncodeUser(const string &user) const
Encode user name.
Definition: ncbi_url.hpp:132
string GetUser(void) const
Definition: ncbi_url.hpp:385
NCBI_DEPRECATED_CLASS NCBI_XCGI_EXPORT EUrlEncode decode
Definition: cgi_util.hpp:102
static string URLDecode(const CTempString str, EUrlDecode flag=eUrlDec_All)
URL-decode string.
Definition: ncbistr.cpp:5958
auto_ptr< CUrlArgs > m_ArgsList
Definition: ncbi_url.hpp:477
SUrlArg TArg
Definition: ncbi_url.hpp:261
virtual string EncodeArgName(const string &name) const
Encode URL argument name.
Definition: ncbi_url.hpp:109
NStr::EUrlEncode m_Encode
Definition: ncbi_url.hpp:161
NCBI_EXCEPTION_DEFAULT2(CUrlParserException, CParseTemplException< CUrlException >, std::string::size_type)
static const unsigned char password[6][32]
Definition: pkcs5.c:305
virtual string EncodeArgName(const string &name) const =0
Encode URL argument name.
X * get(void) const
Get pointer value.
Definition: ncbimisc.hpp:397
void SetFragment(const string &value)
Definition: ncbi_url.hpp:405
CParseTemplException –.
Definition: ncbistr.hpp:3752
const TArgs & GetArgs(void) const
Get the const list of arguments.
Definition: ncbi_url.hpp:286
Encode userinfo part of an URI.
Definition: ncbistr.hpp:2997
virtual string EncodeFragment(const string &value) const =0
Encode fragment.
#define NCBI_XNCBI_EXPORT
Definition: ncbi_export.h:1266
int TAdjustFlags
Definition: ncbi_url.hpp:447
string m_Host
Definition: ncbi_url.hpp:471
#define kEmptyStr
Definition: ncbistr.hpp:120
virtual string EncodeArgValue(const string &value) const =0
Encode URL argument value.
Encode path part of an URI.
Definition: ncbistr.hpp:2999
string m_Service
Definition: ncbi_url.hpp:472
virtual const char * GetErrCodeString(void) const
Get error code interpreted as text.
Definition: ncbi_url.hpp:496
void SetCase(NStr::ECase name_case)
Select case sensitivity of arguments' names.
Definition: ncbi_url.hpp:310
Name-value pair.
Definition: ncbi_url.hpp:254
TErrCode GetErrCode(void) const
Get error code.
Definition: ncbistr.hpp:3810
void SetSemicolonIsNotArgDelimiter(bool enable=true)
Treat semicolon as query string argument separator.
Definition: ncbi_url.hpp:186
string m_Scheme
Definition: ncbi_url.hpp:467
string GetHost(void) const
Definition: ncbi_url.hpp:391
void x_SetPort(const string &port, const IUrlEncoder &encoder)
Definition: ncbi_url.hpp:596
ECase
Which type of string comparison.
Definition: ncbistr.hpp:1175
iterator x_Find(const string &name, const iterator &start)
Definition: ncbi_url.cpp:297
virtual string EncodeArgValue(const string &value) const
Encode URL argument value.
Definition: ncbi_url.hpp:150
void x_SetPassword(const string &password, const IUrlEncoder &encoder)
Definition: ncbi_url.hpp:575
#define END_NCBI_SCOPE
End previously defined NCBI scope.
Definition: ncbistl.hpp:101
void SetIsGeneric(bool value)
Definition: ncbi_url.hpp:383
bool m_IsIndex
Definition: ncbi_url.hpp:324
Decode only XX.
Definition: ncbistr.hpp:3011
virtual string DecodeFragment(const string &value) const
Decode fragment.
Definition: ncbi_url.hpp:158
Do not convert chars like '!', '(' etc.
Definition: ncbistr.hpp:2988
bool GetIsGeneric(void) const
Generic schemes use '//' prefix (after optional scheme).
Definition: ncbi_url.hpp:382
virtual string DecodeArgValue(const string &value) const
Decode URL argument value.
Definition: ncbi_url.hpp:115
virtual string EncodePath(const string &path) const =0
Encode path on server.
string GetService(void) const
Definition: ncbi_url.hpp:395
NStr::ECase m_Case
Definition: ncbi_url.hpp:323
void x_SetArgs(const string &args, const IUrlEncoder &encoder)
Definition: ncbi_url.hpp:618
static string query
virtual string EncodePassword(const string &password) const =0
Encode password.
TArgs::const_iterator const_iterator
Definition: ncbi_url.hpp:264
virtual string DecodePassword(const string &password) const =0
Decode password.
void reset(X *p=0)
Reset pointer.
Definition: ncbimisc.hpp:405
CUrlParserException –.
Definition: ncbi_url.hpp:516
bool m_IsGeneric
Definition: ncbi_url.hpp:468
string GetPath(void) const
Definition: ncbi_url.hpp:401
void x_SetPath(const string &path, const IUrlEncoder &encoder)
Definition: ncbi_url.hpp:604
void SetPassword(const string &value)
Definition: ncbi_url.hpp:389
virtual string DecodeArgValue(const string &value) const =0
Decode URL argument value.
EArgType
Query type flag.
Definition: ncbi_url.hpp:193
CUrl –.
Definition: ncbi_url.hpp:338
Encode fragment part of an URI.
Definition: ncbistr.hpp:3002
CDefaultUrlEncoder(NStr::EUrlEncode encode=NStr::eUrlEnc_SkipMarkChars)
Definition: ncbi_url.hpp:130
string GetOriginalArgsString(void) const
Get the original (unparsed and undecoded) query string.
Definition: ncbi_url.hpp:408
bool IsService(void) const
Definition: ncbi_url.hpp:394
string m_OrigArgs
Definition: ncbi_url.hpp:476
TArgs::iterator iterator
Definition: ncbi_url.hpp:263
CUrlArgs::
Definition: ncbi_url.hpp:228
virtual string DecodeArgName(const string &name) const
Decode URL argument name.
Definition: ncbi_url.hpp:146
string m_User
Definition: ncbi_url.hpp:469
virtual string EncodePassword(const string &password) const
Encode password.
Definition: ncbi_url.hpp:136
NCBI_EXCEPTION_DEFAULT(CUrlException, CException)
#define GetArgs
Avoid preprocessor name clash with the NCBI C Toolkit.
Definition: ncbiapp.hpp:59
virtual string DecodePassword(const string &password) const
Decode password.
Definition: ncbi_url.hpp:103
void x_SetFragment(const string &fragment, const IUrlEncoder &encoder)
Definition: ncbi_url.hpp:611
char value[7]
Definition: config.c:428
Primitive encoder - all methods return the argument value.
Definition: ncbi_url.hpp:94
string GetScheme(void) const
Definition: ncbi_url.hpp:378
virtual string DecodePath(const string &path) const
Decode path on server.
Definition: ncbi_url.hpp:142
virtual const char * GetErrCodeString(void) const
Translate from the error code value to its string representation.
Definition: ncbi_url.hpp:523
virtual string EncodePath(const string &path) const
Encode path on server.
Definition: ncbi_url.hpp:140
CException –.
Definition: ncbiexpt.hpp:709
void SetPath(const string &value)
Definition: ncbi_url.hpp:402
virtual string EncodePath(const string &path) const
Encode path on server.
Definition: ncbi_url.hpp:105
EAmpEncoding
Ampersand encoding for composed URLs.
Definition: ncbi_url.hpp:239
Convert all non-alphanum chars including space and '' to %## format.
Definition: ncbistr.hpp:2991
virtual string DecodeUser(const string &user) const =0
Decode user name.
string GetFragment(void) const
Definition: ncbi_url.hpp:404
SUrlArg(const string &aname, const string &avalue)
Definition: ncbi_url.hpp:256
virtual string EncodeArgValue(const string &value) const
Encode URL argument value.
Definition: ncbi_url.hpp:113
CUrlException –.
Definition: ncbi_url.hpp:488
virtual string EncodeUser(const string &user) const
Encode user name.
Definition: ncbi_url.hpp:97
TErrCode GetErrCode(void) const
Get error code.
Definition: ncbiexpt.cpp:435
unsigned short m_Port
TCP port to listen on.
IUrlEncoder::
Definition: ncbi_url.hpp:60
virtual string DecodePath(const string &path) const =0
Decode path on server.
void SetUser(const string &value)
Definition: ncbi_url.hpp:386
virtual string DecodePassword(const string &password) const
Decode password.
Definition: ncbi_url.hpp:138
string m_Fragment
Definition: ncbi_url.hpp:475
virtual string DecodeUser(const string &user) const
Decode user name.
Definition: ncbi_url.hpp:99
virtual string DecodeUser(const string &user) const
Decode user name.
Definition: ncbi_url.hpp:134
virtual string EncodeFragment(const string &value) const
Encode fragment.
Definition: ncbi_url.hpp:156
void SetScheme(const string &value)
Definition: ncbi_url.hpp:379
void x_SetHost(const string &host, const IUrlEncoder &encoder)
Definition: ncbi_url.hpp:582
virtual string DecodeFragment(const string &value) const =0
Decode fragment.
void SetService(const string &value)
Definition: ncbi_url.hpp:554
virtual string DecodePath(const string &path) const
Decode path on server.
Definition: ncbi_url.hpp:107
Decode '+' to space.
Definition: ncbistr.hpp:3010
Use & to separate arguments.
Definition: ncbi_url.hpp:240
string GetQueryString(EAmpEncoding amp_enc, EUrlEncode encode) const
Definition: cgi_util.hpp:112
CUrlArgs_Parser::
Definition: ncbi_url.hpp:173
static string URLEncode(const CTempString str, EUrlEncode flag=eUrlEnc_SkipMarkChars)
URL-encode string.
Definition: ncbistr.cpp:5814
bool m_SemicolonIsNotArgDelimiter
Definition: ncbi_url.hpp:217
void x_SetScheme(const string &scheme, const IUrlEncoder &encoder)
Definition: ncbi_url.hpp:561
virtual string DecodeArgName(const string &name) const
Decode URL argument name.
Definition: ncbi_url.hpp:111
CUrlArgs_Parser(void)
Definition: ncbi_url.hpp:176
iterator FindFirst(const string &name)
Find the first argument with the given name.
Definition: ncbi_url.hpp:644
virtual ~CUrlArgs_Parser(void)
Definition: ncbi_url.hpp:177
const CUrlArgs & GetArgs(void) const
Get const list of arguments.
Definition: ncbi_url.cpp:562
#define BEGIN_NCBI_SCOPE
Define ncbi namespace.
Definition: ncbistl.hpp:98
virtual string EncodeFragment(const string &value) const
Encode fragment.
Definition: ncbi_url.hpp:117
NCBI_DEPRECATED_CLASS NCBI_XCGI_EXPORT EUrlEncode encode
Definition: cgi_util.hpp:98
virtual string EncodeUser(const string &user) const =0
Encode user name.
static IUrlEncoder * GetDefaultEncoder(void)
Return default URL encoder.
Definition: ncbi_url.cpp:687
string m_Password
Definition: ncbi_url.hpp:470
static int StringToInt(const CTempString str, TStringToNumFlags flags=0, int base=10)
Convert string to int.
Definition: ncbistr.cpp:531
EUrlEncode
URL-encode flags.
Definition: ncbistr.hpp:2987
virtual const char * GetErrCodeString(void) const
Get error code interpreted as text.
Definition: ncbiexpt.cpp:426
NStr –.
Definition: ncbistr.hpp:232
virtual string DecodeArgName(const string &name) const =0
Decode URL argument name.
Modified on Mon Mar 27 16:05:00 2017 by modify_doxy.py rev. 506947