From 9faa724c576ac12ead76b291bf42b898bf768824 Mon Sep 17 00:00:00 2001 From: Cristian Adam Date: Sat, 10 Oct 2026 22:31:43 +0200 Subject: [PATCH 1/2] Qch: Hand the help viewers the site stylesheet, and a dark one The Qt Help output is read in Qt Assistant and in Qt Creator, and the pass that built it was written when Assistant rendered with QTextBrowser, which follows no stylesheet and knows a small corner of CSS. So the pass flattened cppreference's stylesheet into `style` attributes, threw the classes away and rewrote the layout as nested tables, and the pages read like it. Both viewers render with litehtml now -- Assistant since Qt 6.2, Qt Creator since 4.11 -- which does follow a stylesheet, so give them the site's own and let them lay the pages out the way a browser does. The stylesheet. The pages keep their markup and their classes and link one file, which `commands/qch_css.py` builds out of `ext.css`, `site_modules.css`, the seven distinct ` - - - - - -
-
- - -

-std::basic_string

- - -
- - - - - -
-
-
 
- -
 
- -
 
-
std::basic_string
-
 
-
- - - - - - - - - - - - - - - - - - - - - - - - -
Defined in header <string> -
-
template<
-

    class CharT,
-    class Traits = std::char_traits<CharT>,
-    class Allocator = std::allocator<CharT>
-

-> class basic_string;
-
(1)
namespace pmr {
-

    template <class CharT, class Traits = std::char_traits<CharT>>
-    using basic_string = std::basic_string< CharT, Traits,
-                                            std::polymorphic_allocator<CharT>>
-

-}
-
(2) (since C++17)
-

The class template basic_string stores and manipulates sequences of char-like objects, which are non-array objects of trivial type. The class is dependent neither on the character type nor on the nature of operations on that type. The definitions of the operations are supplied via the Traits template parameter - a specialization of std::char_traits or a compatible traits class. Traits::char_type and CharT must name the same type; otherwise the behavior is undefined. -

- - - - - -
-

The elements of a basic_string are stored contiguously, that is, for a basic_string s, &*(s.begin() + n) == &*s.begin() + n for any n in [0, s.size()), or, equivalently, a pointer to s[0] can be passed to functions that expect a pointer to the first element of a CharT[] array. -

-
(since C++11)
-

std::basic_string satisfies the requirements of AllocatorAwareContainer, SequenceContainer and ContiguousContainer (since C++17) -

-

Several typedefs for common character types are provided: -

- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
Defined in header <string>
-
Type - Definition -
std::string - std::basic_string<char> -
std::wstring - std::basic_string<wchar_t> -
std::u16string (C++11) - std::basic_string<char16_t> -
std::u32string (C++11) - std::basic_string<char32_t> -
std::pmr::string (C++17) - std::pmr::basic_string<char> -
std::pmr::wstring (C++17) - std::pmr::basic_string<wchar_t> -
std::pmr::u16string (C++17) - std::pmr::basic_string<char16_t> -
std::pmr::u32string (C++17) - std::pmr::basic_string<char32_t> -
-

Template parameters

- - - - - - - - - - - - - - - - - - -
CharT - - - character type -
Traits - - - traits class specifying the operations on the character type -
Allocator - - - Allocator type used to allocate internal storage -
-

Member types

- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
Member type - Definition -
traits_type - Traits -
value_type - CharT -
allocator_type - Allocator
size_type - - - - - - - - - -
Allocator::size_type(until C++11)
std::allocator_traits<Allocator>::size_type(since C++11)
difference_type - - - - - - - - - -
Allocator::difference_type(until C++11)
std::allocator_traits<Allocator>::difference_type(since C++11)
reference - - - - - - - - - -
Allocator::reference(until C++11)
value_type&(since C++11)
const_reference - - - - - - - - - -
Allocator::const_reference(until C++11)
const value_type&(since C++11)
pointer - - - - - - - - - -
Allocator::pointer(until C++11)
std::allocator_traits<Allocator>::pointer(since C++11)
const_pointer - - - - - - - - - -
Allocator::const_pointer(until C++11)
std::allocator_traits<Allocator>::const_pointer(since C++11)
iterator - RandomAccessIterator
const_iterator - Constant RandomAccessIterator
reverse_iterator - std::reverse_iterator<iterator>
const_reverse_iterator - std::reverse_iterator<const_iterator>
-

Member functions

- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
- constructs a basic_string
(public member function)
(destructor)
-
destroys the string, deallocating internal storage if used
(public member function) -
- assigns values to the string
(public member function)
- assign characters to a string
(public member function)
- returns the associated allocator
(public member function)
Element access -
-
- accesses the specified character with bounds checking
(public member function)
- accesses the specified character
(public member function)
- - -
(C++11)
-
accesses the first character
(public member function)
- - -
(C++11)
-
accesses the last character
(public member function)
- returns a pointer to the first character of a string
(public member function)
- returns a non-modifiable standard C character array version of the string
(public member function)
- returns a non-modifiable string_view into the entire string
(public member function)
Iterators -
-
- - -
- - -
(C++11)
-
returns an iterator to the beginning
(public member function)
- - -
- - -
(C++11)
-
returns an iterator to the end
(public member function)
- - -
- - -
(C++11)
-
returns a reverse iterator to the beginning
(public member function)
- - -
- - -
(C++11)
-
returns a reverse iterator to the end
(public member function)
Capacity -
-
- checks whether the string is empty
(public member function)
- returns the number of characters
(public member function)
- returns the maximum number of characters
(public member function)
- reserves storage
(public member function)
- returns the number of characters that can be held in currently allocated storage
(public member function)
- - -
(C++11)
-
reduces memory usage by freeing unused memory
(public member function)
Operations -
-
- clears the contents
(public member function)
- inserts characters
(public member function)
- removes characters
(public member function)
- appends a character to the end
(public member function)
- - -
(C++11)
-
removes the last character
(public member function)
- appends characters to the end
(public member function)
- appends characters to the end
(public member function)
- compares two strings
(public member function)
- - -
(C++20)
-
checks if the string starts with the given prefix
(public member function)
- - -
(C++20)
-
checks if the string ends with the given suffix
(public member function)
- replaces specified portion of a string
(public member function)
- returns a substring
(public member function)
- copies characters
(public member function)
- changes the number of characters stored
(public member function)
- swaps the contents
(public member function)
Search -
-
- find characters in the string
(public member function)
- find the last occurrence of a substring
(public member function)
- find first occurrence of characters
(public member function)
- find first absence of characters
(public member function)
- find last occurrence of characters
(public member function)
- find last absence of characters
(public member function)

Constants -

-
- - -
[static]
-
special value. The exact meaning depends on the context
(public static member constant)
-

Non-member functions

- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
- concatenates two strings or a string and a char
(function template)
- lexicographically compares two strings
(function template)
- specializes the std::swap algorithm
(function template)
Input/output -
-
- performs stream input and output on strings
(function template)
- read data from an I/O stream into a string
(function template)
Numeric conversions -
-
- - -
- - - -
(C++11)
(C++11)
(C++11)
-
converts a string to a signed integer
(function)
- - -
- - -
(C++11)
(C++11)
-
converts a string to an unsigned integer
(function)
- - -
- - - -
(C++11)
(C++11)
(C++11)
-
converts a string to a floating point value
(function)
- - -
(C++11)
-
converts an integral or floating point value to string
(function)
- - -
(C++11)
-
converts an integral or floating point value to wstring
(function)
-

Literals

- - - - - - - - - - - -
Defined in inline namespace std::literals::string_literals
-
- - -
(C++14)
-
Converts a character array literal to basic_string
(function)
-

Helper classes

- - - - - - - -
- hash support for strings
(class template specialization)
-

Deduction guides(since C++17)

- - - - -
- -
- Retrieved from "http://en.cppreference.com/mwiki/index.php?title=cpp/string/basic_string&oldid=97050"
- - - -
- - -
- -
-
- - - - - - - - - - - diff --git a/tests/preprocess_cssless_data/multiset_expected.html b/tests/preprocess_cssless_data/multiset_expected.html deleted file mode 100644 index b030a93b2..000000000 --- a/tests/preprocess_cssless_data/multiset_expected.html +++ /dev/null @@ -1,608 +0,0 @@ - - - -std::multiset - cppreference.com - - - - - - - - - - - - - -
-
- - -

-std::multiset

- - -
- - - - - -
-
-
 
- -
 
- -
 
-
std::multiset
-
 
-
- - - - - - - - - - - - - - - - - - - - - - - - -
Defined in header <set> -
-
template<
-

    class Key,
-    class Compare = std::less<Key>,
-    class Allocator = std::allocator<Key>
-

-> class multiset;
-
(1)
namespace pmr {
-

    template <class Key, class Compare = std::less<Key>>
-    using multiset = std::multiset<Key, Compare,
-                                   std::pmr::polymorphic_allocator<Key>>;
-

-}
-
(2) (since C++17)
-

std::multiset is an associative container that contains a sorted set of objects of type Key. Unlike set, multiple keys with equivalent values are allowed. Sorting is done using the key comparison function Compare. Search, insertion, and removal operations have logarithmic complexity. -

-

Everywhere the standard library uses the Compare concept, equivalence is determined by using the equivalence relation as described on Compare. In imprecise terms, two objects a and b are considered equivalent if neither compares less than the other: !comp(a, b) && !comp(b, a). -

-

The order of the elements that compare equivalent is the order of insertion and does not change. (since C++11) -

-

std::multiset meets the requirements of Container, AllocatorAwareContainer, AssociativeContainer and ReversibleContainer. -

-

Member types

- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
Member type - Definition -
key_type - Key
value_type - Key
size_type - Unsigned integer type (usually std::size_t)
difference_type - Signed integer type (usually std::ptrdiff_t)
key_compare - Compare
value_compare - Compare
allocator_type - Allocator
reference - - - - - - - - - -
Allocator::reference(until C++11)
value_type&(since C++11)
const_reference - - - - - - - - - -
Allocator::const_reference(until C++11)
const value_type&(since C++11)
pointer - - - - - - - - - -
Allocator::pointer(until C++11)
std::allocator_traits<Allocator>::pointer(since C++11)
const_pointer - - - - - - - - - -
Allocator::const_pointer(until C++11)
std::allocator_traits<Allocator>::const_pointer(since C++11)
iterator - - - - - - - - - -
BidirectionalIterator(until C++11)
Constant BidirectionalIterator -(since C++11)
const_iterator - Constant BidirectionalIterator
reverse_iterator - std::reverse_iterator<iterator>
const_reverse_iterator - std::reverse_iterator<const_iterator>
node_type(since C++17) - a specialization of node handle representing a container node
-

Member functions

- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
- constructs the multiset
(public member function)
- destructs the multiset
(public member function)
- assigns values to the container
(public member function)
- returns the associated allocator
(public member function)
Iterators -
-
- - -
- - -
-
returns an iterator to the beginning
(public member function)
- - -
- - -
-
returns an iterator to the end
(public member function)
- returns a reverse iterator to the beginning
(public member function)
- - -
- - -
-
returns a reverse iterator to the end
(public member function)
Capacity -
-
- checks whether the container is empty
(public member function)
- returns the number of elements
(public member function)
- returns the maximum possible number of elements
(public member function)
Modifiers -
-
- clears the contents
(public member function)
- inserts elements or nodes (since C++17)
(public member function)
- - -
(C++11)
-
constructs element in-place
(public member function)
- - -
(C++11)
-
constructs elements in-place using a hint
(public member function)
- erases elements
(public member function)
- swaps the contents
(public member function)
- - -
(C++17)
-
extracts nodes from the container
(public member function)
- - -
(C++17)
-
splices nodes from another container
(public member function)
Lookup -
-
- returns the number of elements matching specific key
(public member function)
- finds element with specific key
(public member function)
- returns range of elements matching a specific key
(public member function)
- returns an iterator to the first element not less than the given key
(public member function)
- returns an iterator to the first element greater than the given key
(public member function)
Observers -
-
- returns the function that compares keys
(public member function)
- returns the function that compares keys in objects of type value_type
(public member function)
-

Non-member functions

- - - - - - - - - - - - - -
- lexicographically compares the values in the multiset
(function template)
- specializes the std::swap algorithm
(function template)
-

Deduction guides(since C++17)

-

Notes

-

The member types iterator and const_iterator may be aliases to the same type. Since iterator is convertible to const_iterator, const_iterator should be used in function parameter lists to avoid violations of the One Definition Rule. -

- - - -
- -
- Retrieved from "http://en.cppreference.com/mwiki/index.php?title=cpp/container/multiset&oldid=98454"
- - - -
- - -
- -
-
- - - - - - - - - - - diff --git a/tests/preprocess_cssless_data/basic_string.html b/tests/preprocess_qch_data/basic_string.html similarity index 100% rename from tests/preprocess_cssless_data/basic_string.html rename to tests/preprocess_qch_data/basic_string.html diff --git a/tests/preprocess_qch_data/basic_string_expected.html b/tests/preprocess_qch_data/basic_string_expected.html new file mode 100644 index 000000000..a4bfcf14f --- /dev/null +++ b/tests/preprocess_qch_data/basic_string_expected.html @@ -0,0 +1,854 @@ + + + +std::basic_string - cppreference.com + + + + + + + + + + +
+
+ + + +

+std::basic_string

+ + +
+ +
From cppreference.com
+ + +
< cpp‎ | string
+ + +
+
+
 
+ +
 
+ +
 
+
std::basic_string
+
 
+
+ + + + + + + + + + + + + + + + + + + + + +
Defined in header <string> +
+
template<
+

    class CharT,
+    class Traits = std::char_traits<CharT>,
+    class Allocator = std::allocator<CharT>
+

+> class basic_string;
+
(1)
namespace pmr {
+

    template <class CharT, class Traits = std::char_traits<CharT>>
+    using basic_string = std::basic_string< CharT, Traits,
+                                            std::polymorphic_allocator<CharT>>
+

+}
+
(2) (since C++17)
+

The class template basic_string stores and manipulates sequences of char-like objects, which are non-array objects of trivial type. The class is dependent neither on the character type nor on the nature of operations on that type. The definitions of the operations are supplied via the Traits template parameter - a specialization of std::char_traits or a compatible traits class. Traits::char_type and CharT must name the same type; otherwise the behavior is undefined. +

+ + + + + +
+

The elements of a basic_string are stored contiguously, that is, for a basic_string s, &*(s.begin() + n) == &*s.begin() + n for any n in [0, s.size()), or, equivalently, a pointer to s[0] can be passed to functions that expect a pointer to the first element of a CharT[] array. +

+
(since C++11)
+

std::basic_string satisfies the requirements of AllocatorAwareContainer, SequenceContainer and ContiguousContainer (since C++17) +

+

Several typedefs for common character types are provided: +

+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
Defined in header <string>
+
Type + Definition +
std::string + std::basic_string<char> +
std::wstring + std::basic_string<wchar_t> +
std::u16string (C++11) + std::basic_string<char16_t> +
std::u32string (C++11) + std::basic_string<char32_t> +
std::pmr::string (C++17) + std::pmr::basic_string<char> +
std::pmr::wstring (C++17) + std::pmr::basic_string<wchar_t> +
std::pmr::u16string (C++17) + std::pmr::basic_string<char16_t> +
std::pmr::u32string (C++17) + std::pmr::basic_string<char32_t> +
+

Template parameters

+ + + + + + + + + + + + + + + + + + +
CharT + - + character type +
Traits + - + traits class specifying the operations on the character type +
Allocator + - + Allocator type used to allocate internal storage +
+

Member types

+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
Member type + Definition +
traits_type + Traits +
value_type + CharT +
allocator_type + Allocator
size_type + + + + + + + + + +
Allocator::size_type(until C++11)
std::allocator_traits<Allocator>::size_type(since C++11)
difference_type + + + + + + + + + +
Allocator::difference_type(until C++11)
std::allocator_traits<Allocator>::difference_type(since C++11)
reference + + + + + + + + + +
Allocator::reference(until C++11)
value_type&(since C++11)
const_reference + + + + + + + + + +
Allocator::const_reference(until C++11)
const value_type&(since C++11)
pointer + + + + + + + + + +
Allocator::pointer(until C++11)
std::allocator_traits<Allocator>::pointer(since C++11)
const_pointer + + + + + + + + + +
Allocator::const_pointer(until C++11)
std::allocator_traits<Allocator>::const_pointer(since C++11)
iterator + RandomAccessIterator
const_iterator + Constant RandomAccessIterator
reverse_iterator + std::reverse_iterator<iterator>
const_reverse_iterator + std::reverse_iterator<const_iterator>
+

Member functions

+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
+ constructs a basic_string
(public member function)
(destructor)
+
destroys the string, deallocating internal storage if used
(public member function) +
+ assigns values to the string
(public member function)
+ assign characters to a string
(public member function)
+ returns the associated allocator
(public member function)
Element access +
+
+ accesses the specified character with bounds checking
(public member function)
+ accesses the specified character
(public member function)
+ +
(C++11)
+
+
accesses the first character
(public member function)
+ +
(C++11)
+
+
accesses the last character
(public member function)
+ returns a pointer to the first character of a string
(public member function)
+ returns a non-modifiable standard C character array version of the string
(public member function)
+ returns a non-modifiable string_view into the entire string
(public member function)
Iterators +
+
+ +
(C++11)
+
+
returns an iterator to the beginning
(public member function)
+ +
(C++11)
+
+
returns an iterator to the end
(public member function)
+ +
(C++11)
+
+
returns a reverse iterator to the beginning
(public member function)
+ +
(C++11)
+
+
returns a reverse iterator to the end
(public member function)
Capacity +
+
+ checks whether the string is empty
(public member function)
+ returns the number of characters
(public member function)
+ returns the maximum number of characters
(public member function)
+ reserves storage
(public member function)
+ returns the number of characters that can be held in currently allocated storage
(public member function)
+ +
(C++11)
+
+
reduces memory usage by freeing unused memory
(public member function)
Operations +
+
+ clears the contents
(public member function)
+ inserts characters
(public member function)
+ removes characters
(public member function)
+ appends a character to the end
(public member function)
+ +
(C++11)
+
+
removes the last character
(public member function)
+ appends characters to the end
(public member function)
+ appends characters to the end
(public member function)
+ compares two strings
(public member function)
+ +
(C++20)
+
+
checks if the string starts with the given prefix
(public member function)
+ +
(C++20)
+
+
checks if the string ends with the given suffix
(public member function)
+ replaces specified portion of a string
(public member function)
+ returns a substring
(public member function)
+ copies characters
(public member function)
+ changes the number of characters stored
(public member function)
+ swaps the contents
(public member function)
Search +
+
+ find characters in the string
(public member function)
+ find the last occurrence of a substring
(public member function)
+ find first occurrence of characters
(public member function)
+ find first absence of characters
(public member function)
+ find last occurrence of characters
(public member function)
+ find last absence of characters
(public member function)

Constants +

+
+ +
[static]
+
+
special value. The exact meaning depends on the context
(public static member constant)
+

Non-member functions

+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
+ concatenates two strings or a string and a char
(function template)
+ lexicographically compares two strings
(function template)
+ specializes the std::swap algorithm
(function template)
Input/output +
+
+ performs stream input and output on strings
(function template)
+ read data from an I/O stream into a string
(function template)
Numeric conversions +
+
+ +
(C++11)(C++11)(C++11)
+
+
converts a string to a signed integer
(function)
+ +
(C++11)(C++11)
+
+
converts a string to an unsigned integer
(function)
+ +
(C++11)(C++11)(C++11)
+
+
converts a string to a floating point value
(function)
+ +
(C++11)
+
+
converts an integral or floating point value to string
(function)
+ +
(C++11)
+
+
converts an integral or floating point value to wstring
(function)
+

Literals

+ + + + + + + + + + +
Defined in inline namespace std::literals::string_literals
+
+ +
(C++14)
+
+
Converts a character array literal to basic_string
(function)
+

Helper classes

+ + + + + + +
+ hash support for strings
(class template specialization)
+

Deduction guides(since C++17)

+ + + + +
+ + + + + +
+ + +
+ +
+
+ + + + + + + + + + + diff --git a/tests/preprocess_cssless_data/ext.css b/tests/preprocess_qch_data/ext.css similarity index 100% rename from tests/preprocess_cssless_data/ext.css rename to tests/preprocess_qch_data/ext.css diff --git a/tests/preprocess_cssless_data/multiset.html b/tests/preprocess_qch_data/multiset.html similarity index 100% rename from tests/preprocess_cssless_data/multiset.html rename to tests/preprocess_qch_data/multiset.html diff --git a/tests/preprocess_qch_data/multiset_expected.html b/tests/preprocess_qch_data/multiset_expected.html new file mode 100644 index 000000000..c64e70de3 --- /dev/null +++ b/tests/preprocess_qch_data/multiset_expected.html @@ -0,0 +1,512 @@ + + + +std::multiset - cppreference.com + + + + + + + + + + +
+
+ + + +

+std::multiset

+ + +
+ +
From cppreference.com
+ + +
< cpp‎ | container
+ + +
+
+
 
+ +
 
+ +
 
+
std::multiset
+
 
+
+ + + + + + + + + + + + + + + + + + + + + +
Defined in header <set> +
+
template<
+

    class Key,
+    class Compare = std::less<Key>,
+    class Allocator = std::allocator<Key>
+

+> class multiset;
+
(1)
namespace pmr {
+

    template <class Key, class Compare = std::less<Key>>
+    using multiset = std::multiset<Key, Compare,
+                                   std::pmr::polymorphic_allocator<Key>>;
+

+}
+
(2) (since C++17)
+

std::multiset is an associative container that contains a sorted set of objects of type Key. Unlike set, multiple keys with equivalent values are allowed. Sorting is done using the key comparison function Compare. Search, insertion, and removal operations have logarithmic complexity. +

+

Everywhere the standard library uses the Compare concept, equivalence is determined by using the equivalence relation as described on Compare. In imprecise terms, two objects a and b are considered equivalent if neither compares less than the other: !comp(a, b) && !comp(b, a). +

+

The order of the elements that compare equivalent is the order of insertion and does not change. (since C++11) +

+

std::multiset meets the requirements of Container, AllocatorAwareContainer, AssociativeContainer and ReversibleContainer. +

+

Member types

+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
Member type + Definition +
key_type + Key
value_type + Key
size_type + Unsigned integer type (usually std::size_t)
difference_type + Signed integer type (usually std::ptrdiff_t)
key_compare + Compare
value_compare + Compare
allocator_type + Allocator
reference + + + + + + + + + +
Allocator::reference(until C++11)
value_type&(since C++11)
const_reference + + + + + + + + + +
Allocator::const_reference(until C++11)
const value_type&(since C++11)
pointer + + + + + + + + + +
Allocator::pointer(until C++11)
std::allocator_traits<Allocator>::pointer(since C++11)
const_pointer + + + + + + + + + +
Allocator::const_pointer(until C++11)
std::allocator_traits<Allocator>::const_pointer(since C++11)
iterator + + + + + + + + + +
BidirectionalIterator(until C++11)
Constant BidirectionalIterator +(since C++11)
const_iterator + Constant BidirectionalIterator
reverse_iterator + std::reverse_iterator<iterator>
const_reverse_iterator + std::reverse_iterator<const_iterator>
node_type(since C++17) + a specialization of node handle representing a container node
+

Member functions

+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
+ constructs the multiset
(public member function)
+ destructs the multiset
(public member function)
+ assigns values to the container
(public member function)
+ returns the associated allocator
(public member function)
Iterators +
+
+ returns an iterator to the beginning
(public member function)
+ +
+
+
returns an iterator to the end
(public member function)
+ returns a reverse iterator to the beginning
(public member function)
+ returns a reverse iterator to the end
(public member function)
Capacity +
+
+ checks whether the container is empty
(public member function)
+ returns the number of elements
(public member function)
+ returns the maximum possible number of elements
(public member function)
Modifiers +
+
+ clears the contents
(public member function)
+ inserts elements or nodes (since C++17)
(public member function)
+ +
(C++11)
+
+
constructs element in-place
(public member function)
+ +
(C++11)
+
+
constructs elements in-place using a hint
(public member function)
+ erases elements
(public member function)
+ swaps the contents
(public member function)
+ +
(C++17)
+
+
extracts nodes from the container
(public member function)
+ +
(C++17)
+
+
splices nodes from another container
(public member function)
Lookup +
+
+ returns the number of elements matching specific key
(public member function)
+ finds element with specific key
(public member function)
+ returns range of elements matching a specific key
(public member function)
+ returns an iterator to the first element not less than the given key
(public member function)
+ returns an iterator to the first element greater than the given key
(public member function)
Observers +
+
+ returns the function that compares keys
(public member function)
+ returns the function that compares keys in objects of type value_type
(public member function)
+

Non-member functions

+ + + + + + + + + + + +
+ lexicographically compares the values in the multiset
(function template)
+ specializes the std::swap algorithm
(function template)
+

Deduction guides(since C++17)

+

Notes

+

The member types iterator and const_iterator may be aliases to the same type. Since iterator is convertible to const_iterator, const_iterator should be used in function parameter lists to avoid violations of the One Definition Rule. +

+ + + +
+ + + + + +
+ + +
+ +
+
+ + + + + + + + + + + diff --git a/tests/preprocess_cssless_data/site_modules.css b/tests/preprocess_qch_data/site_modules.css similarity index 100% rename from tests/preprocess_cssless_data/site_modules.css rename to tests/preprocess_qch_data/site_modules.css diff --git a/tests/test_preprocess_cssless.py b/tests/test_preprocess_cssless.py deleted file mode 100644 index 64864ccf2..000000000 --- a/tests/test_preprocess_cssless.py +++ /dev/null @@ -1,657 +0,0 @@ -# Copyright (C) 2018 Monika Kairaityte -# -# This file is part of cppreference-doc -# -# This program is free software: you can redistribute it and/or modify -# it under the terms of the GNU General Public License as published by -# the Free Software Foundation, either version 3 of the License, or -# (at your option) any later version. -# -# This program is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -# GNU General Public License for more details. -# -# You should have received a copy of the GNU General Public License -# along with this program. If not, see http://www.gnu.org/licenses/. - -import os -import unittest - -from lxml import etree - -from commands.preprocess_cssless import apply_font_size -from commands.preprocess_cssless import convert_font_size_property_to_pt -from commands.preprocess_cssless import convert_inline_block_elements_to_table -from commands.preprocess_cssless import convert_span_tables_to_tr_td -from commands.preprocess_cssless import \ - convert_table_border_top_to_tr_background -from commands.preprocess_cssless import convert_zero_td_width_to_nonzero -from commands.preprocess_cssless import preprocess_html_merge_cssless -from commands.preprocess_cssless import silence_cssutils_warnings - - -class TestPreprocessHtmlMergeCss(unittest.TestCase): - def test_preprocess_html_merge_cssless(self): - dir_path = os.path.dirname(__file__) - src_path = os.path.join( - dir_path, 'preprocess_cssless_data/multiset.html') - dst_path = os.path.join( - dir_path, 'preprocess_cssless_data/multiset_out.html') - expected_path = os.path.join( - dir_path, 'preprocess_cssless_data/multiset_expected.html') - - preprocess_html_merge_cssless(src_path, dst_path) - - with open(dst_path, 'r') as a_file: - test = a_file.read() - - with open(expected_path, 'r') as a_file: - expected = a_file.read() - - self.assertEqual(test, expected) - os.remove(dst_path) - - def test_preprocess_html_merge_cssless2(self): - dir_path = os.path.dirname(__file__) - src_path = os.path.join( - dir_path, 'preprocess_cssless_data/basic_string.html') - dst_path = os.path.join( - dir_path, 'preprocess_cssless_data/basic_string_out.html') - expected_path = os.path.join( - dir_path, 'preprocess_cssless_data/basic_string_expected.html') - - preprocess_html_merge_cssless(src_path, dst_path) - - with open(dst_path, 'r') as a_file: - test = a_file.read() - - with open(expected_path, 'r') as a_file: - expected = a_file.read() - - self.assertEqual(test, expected) - os.remove(dst_path) - - -class HTMLTestBase(unittest.TestCase): - def setUp(self): - self.maxDiff = None - silence_cssutils_warnings() - - def assert_converts_html(self, input, expected_output, function): - input = '{0}'.format(input) - expected_output = \ - '{0}'.format(expected_output) - - parser = etree.HTMLParser() - root = etree.fromstring(input, parser) - - root = function(root) - - output = etree.tostring(root, encoding=str, method='xml') - - self.assertEqual(expected_output, output) - - -class TestConvertSpanTablesToTrTd(HTMLTestBase): - def assert_processes_table(self, input, expected_output): - def test_fun(root): - convert_span_tables_to_tr_td(root) - return root - - self.assert_converts_html(input, expected_output, test_fun) - - def test_normal_table(self): - input = '''\ -
- - - - 1 - 2 - - - -
-''' # noqa - - expected = '''\ -
- - - - - - -
12
-
-
-''' - self.assert_processes_table(input, expected) - - def test_wraps_table_row_text(self): - input = '''\ -
- - - little text - - -
-''' - expected = '''\ -
- - - -
little text
-
-
-''' - self.assert_processes_table(input, expected) - - def test_wraps_into_td_table_row_children(self): - input = '''\ -
- - - - blabla - blabla2 - - - -
-''' - expected = '''\ -
- - - -
- blabla - blabla2 -
-
-
-''' - self.assert_processes_table(input, expected) - - def test_wraps_into_td_table_row_children_with_style(self): - input = '''\ -
- - - - (C++11) - - - -
-''' - expected = '''\ -
- - - -
- (C++11) -
-
-
-''' - self.assert_processes_table(input, expected) - - def test_wraps_into_td_table_row_children_with_tags(self): - input = '''\ -
- - - - -
bla
-
- blabla2 -
-
-
-
-''' - expected = '''\ -
- - - -
- -
bla
-
- blabla2 -
-
-
-''' - self.assert_processes_table(input, expected) - - def test_does_not_wrap_into_td_children_when_not_in_table_row(self): - input = '''\ -
- - - - 2 - - - -
-''' - expected = '''\ -
- - - - 2 - -
-
-
-''' - self.assert_processes_table(input, expected) - - def test_does_not_wrap_children_when_sibling_is_td(self): - input = '''\ -
- - - - 1 - 2 - - - -
-''' - expected = '''\ -
- - - - 1 - - -
2
-
-
-''' - self.assert_processes_table(input, expected) - - def test_does_not_convert_tr_when_parent_is_not_table(self): - input = '''\ -
- - - - - blabla - - - - -
-''' - expected = '''\ -
- - - - - blabla - - -
-
-
-''' - self.assert_processes_table(input, expected) - - def test_does_not_convert_td_when_parent_is_not_tr(self): - input = '''\ -
- - - - - blabla - - - - -
-''' - expected = '''\ -
- - - - - blabla - - -
-
-
-''' - self.assert_processes_table(input, expected) - - -class TestConvertInlineBlockElementsToTable(HTMLTestBase): - def perform_test(self, input, expected_output): - def test_fun(root): - convert_inline_block_elements_to_table(root) - return root - - self.assert_converts_html(input, expected_output, test_fun) - - def test_does_not_convert_single(self): - input = '''\ -
-
-
-''' - self.perform_test(input, input) - - def test_converts_multiple(self): - input = '''\ -
-
-
-
-''' - expected = '''\ -
-
-
-
-''' # noqa - self.perform_test(input, expected) - - -class TestConvertZeroTdWidthToNonzero(HTMLTestBase): - def test_css_property(self): - def test_fun(root): - convert_zero_td_width_to_nonzero(root) - return root - - input = '''\ - - - - -''' - expected = '''\ - - - - -''' - self.assert_converts_html(input, expected, test_fun) - - def test_attribute(self): - def test_fun(root): - convert_zero_td_width_to_nonzero(root) - return root - - input = '''\ - - - - -''' - expected = '''\ - - - - -''' - self.assert_converts_html(input, expected, test_fun) - - -class TestApplyFontSize(unittest.TestCase): - def test_em(self): - self.assertEqual(10, apply_font_size('1em', 10)) - self.assertEqual(8, apply_font_size('0.8em', 10)) - self.assertEqual(10, apply_font_size('1.0em', 10)) - self.assertEqual(15, apply_font_size('1.5em', 10)) - - self.assertEqual(15, apply_font_size('1.5 em', 10)) - self.assertEqual(15, apply_font_size(' 1.5em ', 10)) - self.assertEqual(15, apply_font_size('1.5em ', 10)) - - def test_px(self): - self.assertEqual(8, apply_font_size('8px', 10)) - self.assertEqual(10, apply_font_size('10px', 10)) - self.assertEqual(15, apply_font_size('15px', 10)) - - self.assertEqual(15, apply_font_size('15 px', 10)) - self.assertEqual(15, apply_font_size(' 15px ', 10)) - self.assertEqual(15, apply_font_size('15px ', 10)) - - def test_ptc(self): - self.assertEqual(8, apply_font_size('80%', 10)) - self.assertEqual(10, apply_font_size('100%', 10)) - self.assertEqual(15, apply_font_size('150%', 10)) - - self.assertEqual(15, apply_font_size('150 %', 10)) - self.assertEqual(15, apply_font_size(' 150% ', 10)) - self.assertEqual(15, apply_font_size('150% ', 10)) - - -class TestConvertFontSizePropertyToPt(HTMLTestBase): - def test_simple(self): - def test_fun(root): - convert_font_size_property_to_pt(root, 10) - return root - - input = '''\ -
-text -
-''' - expected = '''\ -
-text -
-''' - self.assert_converts_html(input, expected, test_fun) - - def test_font_size_value_is_unsupported(self): - def test_fun(root): - convert_font_size_property_to_pt(root, 10) - return root - - input = '''\ -
-
- text -
-
''' - expected = '''\ -
-
- text -
-
''' - self.assert_converts_html(input, expected, test_fun) - - def test_simple_px(self): - def test_fun(root): - convert_font_size_property_to_pt(root, 10) - return root - - input = '''\ -
-text -
-''' - expected = '''\ -
-text -
-''' - self.assert_converts_html(input, expected, test_fun) - - def test_simple_pt(self): - def test_fun(root): - convert_font_size_property_to_pt(root, 10) - return root - - input = '''\ -
-text -
-''' - expected = '''\ -
-text -
-''' - self.assert_converts_html(input, expected, test_fun) - - def test_inherits(self): - def test_fun(root): - convert_font_size_property_to_pt(root, 10) - return root - - input = '''\ -
-
- text -
-
''' - expected = '''\ -
-
- text -
-
''' - self.assert_converts_html(input, expected, test_fun) - - def test_inherits_1em(self): - def test_fun(root): - convert_font_size_property_to_pt(root, 10) - return root - - input = '''\ -
-
- text -
- text -
-
-
''' - expected = '''\ -
-
- text -
- text -
-
-
''' - self.assert_converts_html(input, expected, test_fun) - - -class TestConvertTableBorderTopToTrBackground(HTMLTestBase): - def test_no_border(self): - def test_fun(root): - convert_table_border_top_to_tr_background(root) - return root - - input = '''\ - - - -
-
-''' - self.assert_converts_html(input, input, test_fun) - - def test_single_td(self): - def test_fun(root): - convert_table_border_top_to_tr_background(root) - return root - - input = '''\ - - - -
-
-''' - expected = '''\ - - - -
-
-''' # noqa - self.assert_converts_html(input, expected, test_fun) - - def test_multiple_td(self): - def test_fun(root): - convert_table_border_top_to_tr_background(root) - return root - - input = '''\ - - - -
- - -
-''' - expected = '''\ - - - -
- - -
-''' # noqa - self.assert_converts_html(input, expected, test_fun) - - def test_subtable_does_not_affect_parent_table(self): - def test_fun(root): - convert_table_border_top_to_tr_background(root) - return root - - input = '''\ - - - - -
- - - -
-
-
-''' - expected = '''\ - - - - -
- - - -
-
-
-''' # noqa - self.assert_converts_html(input, expected, test_fun) diff --git a/tests/test_preprocess_qch_html.py b/tests/test_preprocess_qch_html.py new file mode 100644 index 000000000..7b30d9433 --- /dev/null +++ b/tests/test_preprocess_qch_html.py @@ -0,0 +1,270 @@ +# Copyright (C) 2018 Monika Kairaityte +# Copyright (C) 2026 Cristian Adam +# +# This file is part of cppreference-doc +# +# This program is free software: you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation, either version 3 of the License, or +# (at your option) any later version. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program. If not, see http://www.gnu.org/licenses/. + +import os +import tempfile +import unittest + +from lxml import etree + +from commands.preprocess_qch_html import add_color_classes +from commands.preprocess_qch_html import clamp_rowspans +from commands.preprocess_qch_html import drop_navbar_menus +from commands.preprocess_qch_html import lift_style_blocks +from commands.preprocess_qch_html import link_stylesheet +from commands.preprocess_qch_html import preprocess_html_file +from commands.preprocess_qch_html import referenced_images +from commands.preprocess_qch_html import strip_scripts +from commands.preprocess_qch_html import unstack_vertical_headers + +DATA_DIR = os.path.join(os.path.dirname(__file__), 'preprocess_qch_data') + + +class HTMLTestBase(unittest.TestCase): + def setUp(self): + self.maxDiff = None + + def parse(self, body): + return etree.fromstring( + '{0}'.format(body), etree.HTMLParser()) + + def assert_converts_html(self, input, expected_output, function): + root = self.parse(input) + function(root) + + self.assertEqual( + '{0}'.format(expected_output), + etree.tostring(root, encoding=str, method='xml')) + + +class TestLiftStyleBlocks(HTMLTestBase): + def test_takes_the_blocks_out_of_the_page(self): + root = etree.fromstring( + '' + '' + '

text

', etree.HTMLParser()) + + self.assertEqual(('.a { color: red }', '.b { color: blue }'), + lift_style_blocks(root)) + self.assertNotIn(b'.a { color: red }' + '') + + self.assertEqual(('.a { color: red }',), lift_style_blocks(root)) + + def test_ignores_an_empty_block(self): + self.assertEqual((), lift_style_blocks(self.parse(''))) + + +class TestStripScripts(HTMLTestBase): + def test_removes_them(self): + self.assert_converts_html( + '

a

', + '

a

', strip_scripts) + + +class TestDropNavbarMenus(HTMLTestBase): + def test_removes_them(self): + self.assert_converts_html( + '
C++

a

', + '

a

', drop_navbar_menus) + + def test_keeps_the_text_after_one(self): + # it belongs to the page, as it does for the