From 0751720d95dd59848e8bb4327d8a9d8713ae8518 Mon Sep 17 00:00:00 2001 From: Matt Hill Date: Sun, 18 May 2014 12:49:56 -0500 Subject: [PATCH] Added startsWith function --- src/openalpr/support/filesystem.cpp | 9 +++++++++ src/openalpr/support/filesystem.h | 1 + 2 files changed, 10 insertions(+) diff --git a/src/openalpr/support/filesystem.cpp b/src/openalpr/support/filesystem.cpp index 4757d5f..957750b 100644 --- a/src/openalpr/support/filesystem.cpp +++ b/src/openalpr/support/filesystem.cpp @@ -1,5 +1,14 @@ #include "filesystem.h" +bool startsWith(std::string const &fullString, std::string const &prefix) +{ + if(fullString.substr(0, prefix.size()) == prefix) { + return true; + } + + return false; +} + bool hasEnding (std::string const &fullString, std::string const &ending) { if (fullString.length() >= ending.length()) diff --git a/src/openalpr/support/filesystem.h b/src/openalpr/support/filesystem.h index e519956..e0d1372 100644 --- a/src/openalpr/support/filesystem.h +++ b/src/openalpr/support/filesystem.h @@ -17,6 +17,7 @@ #include #include +bool startsWith(std::string const &fullString, std::string const &prefix); bool hasEnding (std::string const &fullString, std::string const &ending); bool DirectoryExists( const char* pzPath ); bool fileExists( const char* pzPath );