Stroika Library 3.0d23x
 
Loading...
Searching...
No Matches
Charset.cpp
1/*
2 * Copyright(c) Sophist Solutions, Inc. 1990-2026. All rights reserved
3 */
4#include "Stroika/Foundation/StroikaPreComp.h"
5
8
9#include "Charset.h"
10
11using namespace Stroika::Foundation;
13using namespace Stroika::Foundation::Memory;
14
15// Comment this in to turn on aggressive noisy DbgTrace in this module
16//#define USE_NOISY_TRACE_IN_THIS_MODULE_ 1
17
18struct Charset::Rep_ : Memory::UseBlockAllocationIfAppropriate<Charset::Rep_> {
19 Rep_ (const String& v)
20 : fValue{v}
21 {
22 }
23 String fValue;
24};
25
26/*
27 ********************************************************************************
28 ****************************** Characters::Charset *****************************
29 ********************************************************************************
30 */
31Charset::Charset (const std::string& charsetName)
32 : fRep_{MakeSharedPtr<Rep_> (String{charsetName})} // conversion throws if not valid ascii
33{
34}
35Charset::Charset (const std::string_view& charsetName)
36 : fRep_{MakeSharedPtr<Rep_> (String{charsetName})} // conversion asserts valid ASCII
37{
38}
39Charset::Charset (const String& charsetName)
40 : fRep_{MakeSharedPtr<Rep_> (charsetName)}
41{
42}
43
44Charset::operator String () const
45{
46 return fRep_->fValue;
47}
48
49string Charset::AsNarrowSDKString () const
50{
51 return fRep_->fValue.AsNarrowSDKString ();
52}
53
54strong_ordering Charset::operator<=> (const Charset& rhs) const
55{
56 return String ::ThreeWayComparer{eCaseInsensitive}(fRep_->fValue, rhs.fRep_->fValue);
57}
58
59bool Charset::operator== (const Charset& rhs) const
60{
61 return String::EqualsComparer{eCaseInsensitive}(fRep_->fValue, rhs.fRep_->fValue);
62}
auto MakeSharedPtr(ARGS_TYPE &&... args) -> shared_ptr< T >
same as make_shared, but if type T has block allocation, then use block allocation for the 'shared pa...
conditional_t< qStroika_Foundation_Memory_PreferBlockAllocation and andTrueCheck, BlockAllocationUseHelper< T >, Common::Empty > UseBlockAllocationIfAppropriate
Use this to enable block allocation for a particular class. Beware of subclassing.
String is like std::u32string, except it is much easier to use, often much more space efficient,...
Definition String.h:201