add class SingleQuoted

This commit is contained in:
Garux
2025-10-07 00:16:53 +05:00
parent c5ced679f4
commit 7ea9546cdf
17 changed files with 46 additions and 30 deletions
+3 -3
View File
@@ -100,16 +100,16 @@ public:
}
void capture() override {
if ( ++m_refcount == 1 ) {
globalOutputStream() << "Module Initialising: '" << Type::Name << "' '" << APIConstructor::getName() << "'\n";
globalOutputStream() << "Module Initialising: " << SingleQuoted( Type::Name ) << ' ' << SingleQuoted( APIConstructor::getName() ) << '\n';
m_dependencies = new Dependencies();
m_dependencyCheck = !globalModuleServer().getError();
if ( m_dependencyCheck ) {
m_api = APIConstructor::constructAPI( *m_dependencies );
globalOutputStream() << "Module Ready: '" << Type::Name << "' '" << APIConstructor::getName() << "'\n";
globalOutputStream() << "Module Ready: " << SingleQuoted( Type::Name ) << ' ' << SingleQuoted( APIConstructor::getName() ) << '\n';
}
else
{
globalErrorStream() << "Module Dependencies Failed: '" << Type::Name << "' '" << APIConstructor::getName() << "'\n";
globalErrorStream() << "Module Dependencies Failed: " << SingleQuoted( Type::Name ) << ' ' << SingleQuoted( APIConstructor::getName() ) << '\n';
}
m_cycleCheck = true;
}
+16
View File
@@ -304,6 +304,22 @@ inline TextOutputStreamType& ostream_write( TextOutputStreamType& ostream, const
return ostream << '"' << quoted.m_type << '"';
}
template<typename Type>
class SingleQuoted
{
public:
const Type& m_type;
SingleQuoted( const Type& type )
: m_type( type ){
}
};
/// \brief Writes any type to \p ostream with a quotation mark character before and after it.
template<typename TextOutputStreamType, typename Type>
inline TextOutputStreamType& ostream_write( TextOutputStreamType& ostream, const SingleQuoted<Type>& quoted ){
return ostream << '\'' << quoted.m_type << '\'';
}
class LowerCase
{
+2 -2
View File
@@ -222,7 +222,7 @@ inline bool string_parse_size( const char* string, std::size_t& i ){
#define RETURN_FALSE_IF_FAIL( expression ) do{ if ( !expression ) { return false; } }while( false )
inline void Tokeniser_unexpectedError( Tokeniser& tokeniser, const char* token, const char* expected ){
globalErrorStream() << tokeniser.getLine() << ':' << tokeniser.getColumn() << ": parse error at '" << ( token != 0 ? token : "#EOF" ) << "': expected '" << expected << "'\n";
globalErrorStream() << tokeniser.getLine() << ':' << tokeniser.getColumn() << ": parse error at " << SingleQuoted( token != 0 ? token : "#EOF" ) << ": expected " << SingleQuoted( expected ) << '\n';
}
@@ -233,7 +233,7 @@ inline bool Tokeniser_getFloat( Tokeniser& tokeniser, float& f ){
}
//fallback for 1.#IND 1.#INF 1.#QNAN cases, happening sometimes after texture locking algorithms
else if ( token != 0 && strstr( token, ".#" ) ) {
globalWarningStream() << "Warning: " << tokeniser.getLine() << ':' << tokeniser.getColumn() << ": expected parse problem at '" << token << "': wanted '#number'\nProcessing anyway\n";
globalWarningStream() << "Warning: " << tokeniser.getLine() << ':' << tokeniser.getColumn() << ": expected parse problem at " << SingleQuoted( token ) << ": wanted '#number'\nProcessing anyway\n";
// *strstr( token, ".#" ) = '\0';
return true;
}
+1 -1
View File
@@ -187,7 +187,7 @@ public:
for ( const auto& [ postfix, index ] : postfixes.m_postfixes )
{
postfix.write( buf );
globalErrorStream() << " '" << buf << "'";
globalErrorStream() << ' ' << SingleQuoted( buf );
}
globalErrorStream() << '\n';
}
+1 -1
View File
@@ -181,7 +181,7 @@ Image* LoadBMPBuff( PointerInputStream& inputStream, std::size_t length ){
ReadBMP( inputStream, image->getRGBAPixels(), rows, columns, ReadPixel32() );
break;
default:
globalErrorStream() << "LoadBMP: illegal pixel_size '" << bmpHeader.bitsPerPixel << "'\n";
globalErrorStream() << "LoadBMP: illegal pixel_size " << SingleQuoted( bmpHeader.bitsPerPixel ) << '\n';
image->release();
return 0;
}
+4 -4
View File
@@ -298,7 +298,7 @@ Image* Targa_decodeImageData( const TargaHeader& targa_header, PointerInputStrea
image_fix_fully_transparent_alpha( *image );
break;
default:
globalErrorStream() << "LoadTGA: illegal pixel_size '" << targa_header.pixel_size << "'\n";
globalErrorStream() << "LoadTGA: illegal pixel_size " << SingleQuoted( targa_header.pixel_size ) << '\n';
image->release();
return 0;
}
@@ -317,7 +317,7 @@ Image* Targa_decodeImageData( const TargaHeader& targa_header, PointerInputStrea
image_fix_fully_transparent_alpha( *image );
break;
default:
globalErrorStream() << "LoadTGA: illegal pixel_size '" << targa_header.pixel_size << "'\n";
globalErrorStream() << "LoadTGA: illegal pixel_size " << SingleQuoted( targa_header.pixel_size ) << '\n';
image->release();
return 0;
}
@@ -333,7 +333,7 @@ Image* Targa_decodeImageData( const TargaHeader& targa_header, PointerInputStrea
image_fix_fully_transparent_alpha( *image );
break;
default:
globalErrorStream() << "LoadTGA: illegal colormap_size '" << targa_header.colormap_size << "'\n";
globalErrorStream() << "LoadTGA: illegal colormap_size " << SingleQuoted( targa_header.colormap_size ) << '\n';
image->release();
return 0;
}
@@ -349,7 +349,7 @@ Image* Targa_decodeImageData( const TargaHeader& targa_header, PointerInputStrea
image_fix_fully_transparent_alpha( *image );
break;
default:
globalErrorStream() << "LoadTGA: illegal colormap_size '" << targa_header.colormap_size << "'\n";
globalErrorStream() << "LoadTGA: illegal colormap_size " << SingleQuoted( targa_header.colormap_size ) << '\n';
image->release();
return 0;
}
+1 -1
View File
@@ -254,7 +254,7 @@ inline bool check_plane_is_integer( const PlanePoints& planePoints ){
inline void brush_check_shader( const char* name ){
if ( !texdef_name_valid( name ) ) {
globalErrorStream() << "brush face has invalid texture name: '" << name << "'\n";
globalErrorStream() << "brush face has invalid texture name: " << SingleQuoted( name ) << '\n';
}
}
+2 -2
View File
@@ -142,14 +142,14 @@ public:
if ( filterMode.filter_mp_sp ) {
if ( string_empty( GlobalRadiant().getGameMode() ) || string_equal( GlobalRadiant().getGameMode(), "sp" ) ) {
if ( string_equal_n( name, filterMode.sp_ignore_prefix, strlen( filterMode.sp_ignore_prefix ) ) ) {
globalOutputStream() << "Ignoring '" << name << "'\n";
globalOutputStream() << "Ignoring " << SingleQuoted( name ) << '\n';
return;
}
}
else
{
if ( string_equal_n( name, filterMode.mp_ignore_prefix, strlen( filterMode.mp_ignore_prefix ) ) ) {
globalOutputStream() << "Ignoring '" << name << "'\n";
globalOutputStream() << "Ignoring " << SingleQuoted( name ) << '\n';
return;
}
}
+1 -1
View File
@@ -2475,7 +2475,7 @@ void DoShaderView( const char *shaderFileName, const char *shaderName, bool exte
#ifdef WIN32
ShellExecute( (HWND)MainFrame_getWindow()->effectiveWinId(), 0, pathFull.c_str(), 0, 0, SW_SHOWNORMAL );
#else
globalWarningStream() << "Failed to open '" << pathFull << "'\nSet Shader Editor Command in preferences\n";
globalWarningStream() << "Failed to open " << SingleQuoted( pathFull ) << "\nSet Shader Editor Command in preferences\n";
#endif
}
else{
+3 -3
View File
@@ -54,7 +54,7 @@ void process_xlink( const char* filename, const char *menu_name, const char *bas
if ( file_exists( filename ) ) {
xmlDocPtr pDoc = xmlParseFile( filename );
if ( pDoc ) {
globalOutputStream() << "Processing .xlink file '" << filename << "'\n";
globalOutputStream() << "Processing .xlink file " << SingleQuoted( filename ) << '\n';
// create sub menu
menu = menu->addMenu( menu_name );
@@ -100,12 +100,12 @@ void process_xlink( const char* filename, const char *menu_name, const char *bas
}
else
{
globalWarningStream() << "'" << filename << "' parse failed\n";
globalWarningStream() << SingleQuoted( filename ) << " parse failed\n";
}
}
else
{
globalWarningStream() << "'" << filename << "' not found\n";
globalWarningStream() << SingleQuoted( filename ) << " not found\n";
}
}
+1 -1
View File
@@ -544,7 +544,7 @@ void Radiant_loadModules( const char* path ){
ASSERT_MESSAGE( strlen( path ) + strlen( name ) < 1024, "" );
strcpy( fullname, path );
strcat( fullname, name );
globalOutputStream() << "Found '" << fullname << "'\n";
globalOutputStream() << "Found " << SingleQuoted( fullname ) << '\n';
GlobalModuleServer_loadModule( fullname );
}));
}
+1 -1
View File
@@ -983,7 +983,7 @@ private:
void check_shader(){
if ( !texdef_name_valid( GetShader() ) ) {
globalErrorStream() << "patch has invalid texture name: '" << GetShader() << "'\n";
globalErrorStream() << "patch has invalid texture name: " << SingleQuoted( GetShader() ) << '\n';
}
}
+2 -2
View File
@@ -104,7 +104,7 @@ CGameDescription::CGameDescription( xmlDocPtr pDoc, const CopiedString& gameFile
{
GameDescription::iterator i = m_gameDescription.find( "type" );
if ( i == m_gameDescription.end() ) {
globalWarningStream() << "Warning, 'type' attribute not found in '" << reinterpret_cast<const char*>( pDoc->URL ) << "'\n";
globalWarningStream() << "Warning, 'type' attribute not found in " << SingleQuoted( reinterpret_cast<const char*>( pDoc->URL ) ) << '\n';
// default
mGameType = "q3";
}
@@ -318,7 +318,7 @@ void CGameDialog::ScanForGames(){
}
else
{
globalErrorStream() << "XML parser failed on '" << strPath << "'\n";
globalErrorStream() << "XML parser failed on " << SingleQuoted( strPath ) << '\n';
}
}));
}
+2 -2
View File
@@ -224,9 +224,9 @@ void RunBatch( const std::vector<CopiedString>& commands ){
#if defined ( POSIX )
chmod( batpath, 0744 );
#endif
globalOutputStream() << "Writing the compile script to '" << batpath << "'\n";
globalOutputStream() << "Writing the compile script to " << SingleQuoted( batpath ) << '\n';
if( g_WatchBSP0_DumpLog )
globalOutputStream() << "The build output will be saved in '" << junkpath << "'\n";
globalOutputStream() << "The build output will be saved in " << SingleQuoted( junkpath ) << '\n';
Q_Exec( batpath, nullptr, nullptr, true, false );
}
}
+2 -2
View File
@@ -678,11 +678,11 @@ void Select_RotateTexture( float amt ){
// expects shader names at input, comparison relies on shader names .. texture names no longer relevant
void FindReplaceTextures( const char* pFind, const char* pReplace, bool bSelected ){
if ( !texdef_name_valid( pFind ) ) {
globalErrorStream() << "FindReplaceTextures: invalid texture name: '" << pFind << "', aborted\n";
globalErrorStream() << "FindReplaceTextures: invalid texture name: " << SingleQuoted( pFind ) << ", aborted\n";
return;
}
if ( !texdef_name_valid( pReplace ) ) {
globalErrorStream() << "FindReplaceTextures: invalid texture name: '" << pReplace << "', aborted\n";
globalErrorStream() << "FindReplaceTextures: invalid texture name: " << SingleQuoted( pReplace ) << ", aborted\n";
return;
}
+3 -3
View File
@@ -127,7 +127,7 @@ public:
DynamicLibrary( const char* filename ){
m_library = LoadLibrary( filename );
if ( m_library == 0 ) {
globalErrorStream() << "LoadLibrary failed: '" << filename << "'\n";
globalErrorStream() << "LoadLibrary failed: " << SingleQuoted( filename ) << '\n';
globalErrorStream() << "GetLastError: " << FormatGetLastError();
}
}
@@ -142,7 +142,7 @@ public:
FunctionPointer findSymbol( const char* symbol ){
FunctionPointer address = (FunctionPointer) GetProcAddress( m_library, symbol );
if ( address == 0 ) {
globalErrorStream() << "GetProcAddress failed: '" << symbol << "'\n";
globalErrorStream() << "GetProcAddress failed: " << SingleQuoted( symbol ) << '\n';
globalErrorStream() << "GetLastError: " << FormatGetLastError();
}
return address;
@@ -162,7 +162,7 @@ public:
DynamicLibrary( const char* filename ){
m_library = dlopen( filename, RTLD_NOW );
if ( failed() ) {
globalErrorStream() << "LoadLibrary failed: '" << filename << "'\n";
globalErrorStream() << "LoadLibrary failed: " << SingleQuoted( filename ) << '\n';
globalErrorStream() << "Module dlopen(3) Error: " << dlerror() << '\n';
}
}
+1 -1
View File
@@ -1013,7 +1013,7 @@ void SurfaceInspector::ApplyShader(){
// TTimo: detect and refuse invalid texture names (at least the ones with spaces)
if ( !texdef_name_valid( name ) ) {
globalErrorStream() << "invalid texture name '" << name << "'\n";
globalErrorStream() << "invalid texture name " << SingleQuoted( name ) << '\n';
SurfaceInspector_queueDraw();
return;
}