@@ -30,12 +30,8 @@ template <typename T> class SmallVectorImpl;
30
30
31
31
namespace details {
32
32
class CharSetConverterImplBase {
33
- public:
34
- virtual ~CharSetConverterImplBase () = default ;
35
-
36
- // / Resets the converter to the initial state.
37
- virtual void reset () = 0;
38
33
34
+ private:
39
35
// / Converts a string.
40
36
// / \param[in] Source source string
41
37
// / \param[out] Result container for converted string
@@ -55,12 +51,21 @@ class CharSetConverterImplBase {
55
51
// / In case of an error, the result string contains the successfully converted
56
52
// / part of the input string.
57
53
// /
58
-
59
- std::error_code convert (StringRef Source,
60
- SmallVectorImpl<char > &Result) const ;
61
-
62
54
virtual std::error_code convertString (StringRef Source,
63
55
SmallVectorImpl<char > &Result) = 0;
56
+
57
+ // / Resets the converter to the initial state.
58
+ virtual void reset () = 0;
59
+
60
+ public:
61
+ virtual ~CharSetConverterImplBase () = default ;
62
+
63
+ // / Converts a string and resets the converter to the initial state.
64
+ std::error_code convert (StringRef Source, SmallVectorImpl<char > &Result) {
65
+ auto EC = convertString (Source, Result);
66
+ reset ();
67
+ return EC;
68
+ }
64
69
};
65
70
} // namespace details
66
71
@@ -118,15 +123,12 @@ class CharSetConverter {
118
123
// / \return error code in case something went wrong
119
124
std::error_code convert (StringRef Source,
120
125
SmallVectorImpl<char > &Result) const {
121
- auto EC = Converter->convertString (Source, Result);
122
- Converter->reset ();
123
- return EC;
126
+ return Converter->convert (Source, Result);
124
127
}
125
128
126
129
ErrorOr<std::string> convert (StringRef Source) const {
127
130
SmallString<100 > Result;
128
- auto EC = Converter->convertString (Source, Result);
129
- Converter->reset ();
131
+ auto EC = Converter->convert (Source, Result);
130
132
if (!EC)
131
133
return std::string (Result);
132
134
return EC;
0 commit comments