2 * Lightweight URL & URI parser (RFC 1738, RFC 3986)
3 * https://github.com/corporateshark/LUrlParser
5 * The MIT License (MIT)
7 * Copyright (C) 2015 Sergey Kosarevsky (sk@linderdaum.com)
9 * Permission is hereby granted, free of charge, to any person obtaining a copy
10 * of this software and associated documentation files (the "Software"), to deal
11 * in the Software without restriction, including without limitation the rights
12 * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
13 * copies of the Software, and to permit persons to whom the Software is
14 * furnished to do so, subject to the following conditions:
16 * The above copyright notice and this permission notice shall be included in all
17 * copies or substantial portions of the Software.
19 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
20 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
21 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
22 * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
23 * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
24 * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
36 LUrlParserError_Ok
= 0,
37 LUrlParserError_Uninitialized
= 1,
38 LUrlParserError_NoUrlCharacter
= 2,
39 LUrlParserError_InvalidSchemeName
= 3,
40 LUrlParserError_NoDoubleSlash
= 4,
41 LUrlParserError_NoAtSign
= 5,
42 LUrlParserError_UnexpectedEndOfLine
= 6,
43 LUrlParserError_NoSlash
= 7,
49 LUrlParserError m_ErrorCode
;
55 std::string m_Fragment
;
56 std::string m_UserName
;
57 std::string m_Password
;
60 : m_ErrorCode( LUrlParserError_Uninitialized
)
63 /// return 'true' if the parsing was successful
64 bool IsValid() const { return m_ErrorCode
== LUrlParserError_Ok
; }
66 /// helper to convert the port number to int, return 'true' if the port is valid (within the 0..65535 range)
67 bool GetPort( int* OutPort
) const;
70 static clParseURL
ParseURL( const std::string
& URL
);
73 explicit clParseURL( LUrlParserError ErrorCode
)
74 : m_ErrorCode( ErrorCode
)
78 } // namespace LUrlParser