Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
23 changes: 23 additions & 0 deletions StaticResourceAssert/Common.cpp
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@

#include "include/Common.h"

#include <cctype>

#ifdef _WIN32
#include "Windows.h"
#endif
Expand Down Expand Up @@ -59,6 +61,27 @@ std::size_t replace_all(std::string& inout, std::string_view what, std::string_v
return count;
}

void TrimStartWhitespace(std::string& inout) {
if(inout.empty()) {
return;
}
auto beginIter = inout.begin();
while(inout.end() != beginIter && std::isspace(*beginIter)) {
beginIter = inout.erase(beginIter);
}
}

void TrimEndWhitespace(std::string& inout) {
if(inout.empty()) {
return;
}
auto endIter = inout.end()-1;
while(inout.end() != endIter && std::isspace(*endIter)) {
inout.pop_back();
endIter--;
}
}

bool HasArg( const char* argStr, int argc, char** argv )
{
for( int c = 0; c < argc; c++ )
Expand Down
10 changes: 10 additions & 0 deletions StaticResourceAssert/Main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,16 @@ int main( int argc, char** argv )

std::string directoryStr = GetArgData( "-d", argc, argv );
replace_all( directoryStr, "\\", "/" );
replace_all( directoryStr, "\\", "" );
replace_all( directoryStr, "<", "" );
replace_all( directoryStr, ">", "" );
replace_all( directoryStr, "\"", "" );
replace_all( directoryStr, "|", "" );
replace_all( directoryStr, "?", "" );
replace_all( directoryStr, "*", "" );

TrimStartWhitespace(directoryStr);
TrimEndWhitespace(directoryStr);

std::string outputHeaderStr = "static_resource_assert_api.h";
if( HasArg( "-o", argc, argv ) )
Expand Down
3 changes: 3 additions & 0 deletions StaticResourceAssert/include/Common.h
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,9 @@ void __pstream(const std::ostream &t, bool bNewline = true );

std::size_t replace_all(std::string& inout, std::string_view what, std::string_view with);

void TrimStartWhitespace(std::string& inout);

void TrimEndWhitespace(std::string& inout);

// Program arguments

Expand Down