Cogs.Foundation
Loading...
Searching...
No Matches
Macros
StringViewFormat.h File Reference

Go to the source code of this file.

Macros

#define StringViewFormat(sv)   static_cast<int>(sv.size()), sv.data()
 Provide a consistent way to pass a std::string_view or StringView to functions that std::printf style formatting.
 

Macro Definition Documentation

◆ StringViewFormat

#define StringViewFormat (   sv)    static_cast<int>(sv.size()), sv.data()

Provide a consistent way to pass a std::string_view or StringView to functions that std::printf style formatting.

a variable argument function that uses %.*s to format the StringView contents. (UNICODE wstring_view uses format: '%.*ls' DO NOT print std::string_view using: std::printf("%s", sv.data()) - Will print until '\0' char found. ALWAYS print std::string using c_str(): std::printf("%s", std::string("Hello).c_str()) Check suspicious code In Cogs Logging using RegExp matches: LOG_.*\.data() E.g. probably passing string_view without StringViewFormat. @param sw std::string_view or StringView to print. Example usage: printf("%.*s", StringViewFormat(sv));