-
Notifications
You must be signed in to change notification settings - Fork 387
Replace custom BaseString with std::string and std::basic_string #5682
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Conversation
Co-authored-by: max-charlamb <44248479+max-charlamb@users.noreply.github.com>
Co-authored-by: max-charlamb <44248479+max-charlamb@users.noreply.github.com>
Co-authored-by: max-charlamb <44248479+max-charlamb@users.noreply.github.com>
Co-authored-by: max-charlamb <44248479+max-charlamb@users.noreply.github.com>
…erloads Co-authored-by: max-charlamb <44248479+max-charlamb@users.noreply.github.com>
Co-authored-by: max-charlamb <44248479+max-charlamb@users.noreply.github.com>
Co-authored-by: max-charlamb <44248479+max-charlamb@users.noreply.github.com>
…ions Co-authored-by: max-charlamb <44248479+max-charlamb@users.noreply.github.com>
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pull request overview
This PR removes the custom BaseString template class (~150 lines) from util.h and replaces it with standard library string types (std::string and std::basic_string<WCHAR>). The change modernizes the codebase by leveraging STL instead of maintaining custom string implementations.
Changes:
- Removed custom
BaseStringtemplate class and replaced type definitions withstd::stringandstd::basic_string<WCHAR> - Updated method calls from
GetLength()to standardlength()and added explicitc_str()calls where implicit conversions previously occurred - Added explicit
WString()constructor wrapping for Format objects in string concatenation expressions to work withstd::basic_string's operator+
Reviewed changes
Copilot reviewed 3 out of 3 changed files in this pull request and generated 1 comment.
| File | Description |
|---|---|
| src/SOS/Strike/util.h | Removed BaseString template class, updated typedefs to use STL types, and added .c_str() calls in Format conversion operator and TableOutput methods |
| src/SOS/Strike/util.cpp | Updated string concatenations with Format objects to use explicit WString() wrapping, changed GetLength() to length(), and added intermediate pointer variable for ArrayHolder |
| src/SOS/Strike/strike.cpp | Added explicit WString() wrapping for Format object concatenations and updated all ExtOut calls to use .c_str() on String objects across all platform-specific sections |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
| const WCHAR* fileNamePtr = wszFileName; | ||
| methodOutput += WString(W(" [")) + fileNamePtr + W(" @ ") + WString(Decimal(linenum)) + W("]"); |
Copilot
AI
Jan 15, 2026
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The intermediate variable fileNamePtr is unnecessary. ArrayHolder<WCHAR> already has an implicit conversion operator to const WCHAR* (defined at line 42-45 of arrayholder.h), so wszFileName can be used directly in the concatenation expression. This would be more consistent with line 5375 in the same file where wszFileName is used directly with the += operator without creating an intermediate pointer.
| const WCHAR* fileNamePtr = wszFileName; | |
| methodOutput += WString(W(" [")) + fileNamePtr + W(" @ ") + WString(Decimal(linenum)) + W("]"); | |
| methodOutput += WString(W(" [")) + wszFileName + W(" @ ") + WString(Decimal(linenum)) + W("]"); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The intermediate variable is actually required. While ArrayHolder<WCHAR> has an implicit conversion to const WCHAR*, this conversion doesn't work with std::basic_string::operator+ in the expression on line 5515.
When I removed the intermediate variable, the build failed with:
error: invalid operands to binary expression ('WString' (aka 'basic_string<char16_t>') and 'ArrayHolder<WCHAR>')
Line 5375 works differently because it uses the += operator (which has overloads accepting const WCHAR*) on an already-dereferenced pointer (pJustName + 1), not the binary + operator with an ArrayHolder directly.
The intermediate const WCHAR* variable forces the implicit conversion to happen before the binary + operator is invoked, similar to how explicit WString() wrapping is needed for Format objects.
…uirements Co-authored-by: max-charlamb <44248479+max-charlamb@users.noreply.github.com>
Replace BaseString in util.h with std::string and std::basic_string
This PR replaces the custom
BaseStringtemplate class with standard STL string types as suggested in the PR review comment from PR #5594.Plan:
Changes made:
BaseStringtemplate class from util.h (150+ lines of code)Stringtypedef fromBaseString<char, strlen, strcpy_s>tostd::stringWStringtypedef fromBaseString<WCHAR, _wcslen, wcscpy_s>tostd::basic_string<WCHAR>GetLength()calls tolength()(std::string standard method).c_str()calls where neededWString()constructor wrappingoperator WString(), but it's not invoked when used with std::string's operator+. Therefore, explicit wrapping withWString()is necessary..c_str()on string parametersExtOut,DMLOut, etc.), explicitly call.c_str()to convert toPCSTRTesting:
Original prompt
💡 You can make Copilot smarter by setting up custom instructions, customizing its development environment and configuring Model Context Protocol (MCP) servers. Learn more Copilot coding agent tips in the docs.