Skip to content

Commit

Permalink
Add "String input" documentation
Browse files Browse the repository at this point in the history
  • Loading branch information
rmisev committed Oct 17, 2024
1 parent 4ca5098 commit 9d200ba
Show file tree
Hide file tree
Showing 5 changed files with 34 additions and 2 deletions.
3 changes: 2 additions & 1 deletion Doxyfile
Original file line number Diff line number Diff line change
Expand Up @@ -970,7 +970,8 @@ INPUT = include/upa/url.h \
include/upa/url_result.h \
include/upa/url_search_params.h \
include/upa/url_percent_encode.h \
README.md
README.md \
doc/string_input.md

# This tag can be used to specify the character encoding of the source files
# that Doxygen parses. Internally Doxygen uses the UTF-8 encoding. Doxygen uses
Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ Upa URL contains features not specified in the standard:
4. Experimental URLHost class (see proposal: https://github.com/whatwg/url/pull/288): `upa::url_host`
5. The `upa::url_search_params` class has a few additional functions: `remove`, `remove_if`

For string input, the library supports UTF-8, UTF-16, UTF-32 encodings and several string types, including `std::basic_string`, `std::basic_string_view`, null-terminated strings of any char type: `char`, `char8_t`, `char16_t`, `char32_t`, or `wchar_t`.
For string input, the library supports UTF-8, UTF-16, UTF-32 encodings and several string types, including `std::basic_string`, `std::basic_string_view`, null-terminated strings of any char type: `char`, `char8_t`, `char16_t`, `char32_t`, or `wchar_t`. See ["String input"](doc/string_input.md) for more information.

## Installation

Expand Down
23 changes: 23 additions & 0 deletions doc/string_input.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
## String input

For string input, the library supports UTF-8, UTF-16, UTF-32 encodings and several string types, including `std::basic_string`, `std::basic_string_view`, null-terminated strings of any char type: `char`, `char8_t`, `char16_t`, `char32_t`, or `wchar_t`.

The ATL/MFC and Qt library string types are also supported. To use them you need to include the header files listed in the table below instead of `url.h`:

| Library | Supported string types | Include instead of `url.h` |
|-|-|-|
| ATL/MFC | `CSimpleStringT`, `CStringT`, `CFixedStringT` | `url_for_atl.h` |
| Qt | `QString`, `QStringView`, `QUtf8StringView` | `url_for_qt.h` |

Qt example:
```cpp
#include "upa/url_for_qt.h"
#include <QString>

int main() {
QString str{"http://example.com/"};
upa::url url{str};
std::cout << url.href() << '\n';
return 0;
}
```
4 changes: 4 additions & 0 deletions include/upa/url_for_atl.h
Original file line number Diff line number Diff line change
@@ -1,6 +1,10 @@
// Copyright 2024 Rimas Misevičius
// Distributed under the BSD-style license that can be
// found in the LICENSE file.

// This file can be included instead of url.h to allow strings of the
// ATL/MFC classes CSimpleStringT, CStringT, CFixedStringT to be used
// as string input in the functions of this library.
//
#ifndef UPA_URL_FOR_ATL_H
#define UPA_URL_FOR_ATL_H
Expand Down
4 changes: 4 additions & 0 deletions include/upa/url_for_qt.h
Original file line number Diff line number Diff line change
@@ -1,6 +1,10 @@
// Copyright 2024 Rimas Misevičius
// Distributed under the BSD-style license that can be
// found in the LICENSE file.

// This file can be included instead of url.h to allow strings of the
// Qt classes QString, QStringView, QUtf8StringView to be used as string
// input in the functions of this library.
//
#ifndef UPA_URL_FOR_QT_H
#define UPA_URL_FOR_QT_H
Expand Down

0 comments on commit 9d200ba

Please sign in to comment.