@@ -135,46 +135,6 @@ class BasicString
135
135
*/
136
136
static void remove_all (StringType &target, const StringType &search);
137
137
138
- /* *
139
- * Check if a string begins with a character.
140
- *
141
- * @param source The string to check.
142
- * @param search The beginning to search for.
143
- *
144
- * @return True if the string begins with the search character.
145
- */
146
- static bool starts_with (const StringType &source, const char_type &search);
147
-
148
- /* *
149
- * Check if a string begins with another string.
150
- *
151
- * @param source The string to check.
152
- * @param search The beginning to search for.
153
- *
154
- * @return True if the string begins with the search string.
155
- */
156
- static bool starts_with (const StringType &source, const StringType &search);
157
-
158
- /* *
159
- * Check if a string ends with a character.
160
- *
161
- * @param source The string to check.
162
- * @param search The ending to search for.
163
- *
164
- * @return True if the string ends with the search character.
165
- */
166
- static bool ends_with (const StringType &source, const char_type &search);
167
-
168
- /* *
169
- * Check if a string ends with another string.
170
- *
171
- * @param source The string to check.
172
- * @param search The ending to search for.
173
- *
174
- * @return True if the string ends with the search string.
175
- */
176
- static bool ends_with (const StringType &source, const StringType &search);
177
-
178
138
/* *
179
139
* Check if a string matches another string with wildcard expansion.
180
140
*
@@ -566,70 +526,6 @@ void BasicString<StringType>::remove_all(StringType &target, const StringType &s
566
526
replace_all (target, search, StringType ());
567
527
}
568
528
569
- // ==================================================================================================
570
- template <typename StringType>
571
- bool BasicString<StringType>::starts_with(const StringType &source, const char_type &search)
572
- {
573
- bool result = false ;
574
-
575
- if (!source.empty ())
576
- {
577
- result = source[0 ] == search;
578
- }
579
-
580
- return result;
581
- }
582
-
583
- // ==================================================================================================
584
- template <typename StringType>
585
- bool BasicString<StringType>::starts_with(const StringType &source, const StringType &search)
586
- {
587
- bool result = false ;
588
-
589
- const size_type source_sz = source.size ();
590
- const size_type search_sz = search.size ();
591
-
592
- if (source_sz >= search_sz)
593
- {
594
- result = source.compare (0 , search_sz, search) == 0 ;
595
- }
596
-
597
- return result;
598
- }
599
-
600
- // ==================================================================================================
601
- template <typename StringType>
602
- bool BasicString<StringType>::ends_with(const StringType &source, const char_type &search)
603
- {
604
- bool result = false ;
605
-
606
- const size_type source_sz = source.size ();
607
-
608
- if (source_sz > 0 )
609
- {
610
- result = source[source_sz - 1 ] == search;
611
- }
612
-
613
- return result;
614
- }
615
-
616
- // ==================================================================================================
617
- template <typename StringType>
618
- bool BasicString<StringType>::ends_with(const StringType &source, const StringType &search)
619
- {
620
- bool result = false ;
621
-
622
- const size_type source_sz = source.size ();
623
- const size_type search_sz = search.size ();
624
-
625
- if (source_sz >= search_sz)
626
- {
627
- result = source.compare (source_sz - search_sz, search_sz, search) == 0 ;
628
- }
629
-
630
- return result;
631
- }
632
-
633
529
// ==================================================================================================
634
530
template <typename StringType>
635
531
bool BasicString<StringType>::wildcard_match(const StringType &source, const StringType &search)
@@ -644,11 +540,11 @@ bool BasicString<StringType>::wildcard_match(const StringType &source, const Str
644
540
{
645
541
if (result && (search.front () != s_wildcard))
646
542
{
647
- result = starts_with (source, segments.front ());
543
+ result = source. starts_with (segments.front ());
648
544
}
649
545
if (result && (search.back () != s_wildcard))
650
546
{
651
- result = ends_with (source, segments.back ());
547
+ result = source. ends_with (segments.back ());
652
548
}
653
549
654
550
for (auto it = segments.begin (); result && (it != segments.end ()); ++it)
@@ -795,18 +691,18 @@ StringType BasicString<StringType>::generate_random_string(size_type length)
795
691
constexpr auto limit = static_cast <short_distribution::result_type>(s_alpha_num_length - 1 );
796
692
static_assert (limit > 0 );
797
693
798
- static thread_local const auto now = std::chrono::system_clock::now ().time_since_epoch ();
799
- static thread_local const auto seed = static_cast <std::mt19937::result_type>(now .count ());
694
+ static thread_local const auto s_now = std::chrono::system_clock::now ().time_since_epoch ();
695
+ static thread_local const auto s_seed = static_cast <std::mt19937::result_type>(s_now .count ());
800
696
801
- static thread_local std::mt19937 engine (seed );
697
+ static thread_local std::mt19937 s_engine (s_seed );
802
698
short_distribution distribution (0 , limit);
803
699
804
700
StringType result;
805
701
result.reserve (length);
806
702
807
703
while (length-- != 0 )
808
704
{
809
- result.push_back (s_alpha_num[distribution (engine )]);
705
+ result.push_back (s_alpha_num[distribution (s_engine )]);
810
706
}
811
707
812
708
return result;
0 commit comments