Index: trunk/ChameleonPrefPane/ChameleonPrefPane.xcodeproj/project.pbxproj =================================================================== --- trunk/ChameleonPrefPane/ChameleonPrefPane.xcodeproj/project.pbxproj (revision 38) +++ trunk/ChameleonPrefPane/ChameleonPrefPane.xcodeproj/project.pbxproj (revision 39) @@ -20,6 +20,7 @@ 019930FF110A0E6F003B056E /* PeripheralsController.mm in Sources */ = {isa = PBXBuildFile; fileRef = 019930FD110A0E6F003B056E /* PeripheralsController.mm */; }; 01993115110A0EB9003B056E /* AdvancedSetupController.h in Headers */ = {isa = PBXBuildFile; fileRef = 01993113110A0EB9003B056E /* AdvancedSetupController.h */; }; 01993116110A0EB9003B056E /* AdvancedSetupController.mm in Sources */ = {isa = PBXBuildFile; fileRef = 01993114110A0EB9003B056E /* AdvancedSetupController.mm */; }; + 01993197110A2B71003B056E /* string_util.h in Headers */ = {isa = PBXBuildFile; fileRef = 01993196110A2B71003B056E /* string_util.h */; }; 01A40F75110550F4002A74CD /* CHANGES in Resources */ = {isa = PBXBuildFile; fileRef = 01A40F74110550F4002A74CD /* CHANGES */; }; 01B0E8141108B85A00ACF21B /* ChameleonPrefPane.h in Headers */ = {isa = PBXBuildFile; fileRef = 01B0E80E1108B85A00ACF21B /* ChameleonPrefPane.h */; }; 01B0E8151108B85A00ACF21B /* ChameleonPrefPane.mm in Sources */ = {isa = PBXBuildFile; fileRef = 01B0E80F1108B85A00ACF21B /* ChameleonPrefPane.mm */; }; @@ -57,6 +58,7 @@ 019930FD110A0E6F003B056E /* PeripheralsController.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; name = PeripheralsController.mm; path = Sources/PeripheralsController.mm; sourceTree = ""; }; 01993113110A0EB9003B056E /* AdvancedSetupController.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = AdvancedSetupController.h; path = Sources/AdvancedSetupController.h; sourceTree = ""; }; 01993114110A0EB9003B056E /* AdvancedSetupController.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; name = AdvancedSetupController.mm; path = Sources/AdvancedSetupController.mm; sourceTree = ""; }; + 01993196110A2B71003B056E /* string_util.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = string_util.h; sourceTree = ""; }; 01A40F74110550F4002A74CD /* CHANGES */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text; path = CHANGES; sourceTree = ""; }; 01B0E80E1108B85A00ACF21B /* ChameleonPrefPane.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = ChameleonPrefPane.h; path = Sources/ChameleonPrefPane.h; sourceTree = ""; }; 01B0E80F1108B85A00ACF21B /* ChameleonPrefPane.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; name = ChameleonPrefPane.mm; path = Sources/ChameleonPrefPane.mm; sourceTree = ""; }; @@ -155,6 +157,7 @@ 01B0E8101108B85A00ACF21B /* process.cpp */, 01B0E8131108B85A00ACF21B /* property_list.h */, 01B0E8121108B85A00ACF21B /* property_list.cpp */, + 01993196110A2B71003B056E /* string_util.h */, ); name = Classes; sourceTree = ""; @@ -216,6 +219,7 @@ 019930E8110A0D80003B056E /* BootFlagsController.h in Headers */, 019930FE110A0E6F003B056E /* PeripheralsController.h in Headers */, 01993115110A0EB9003B056E /* AdvancedSetupController.h in Headers */, + 01993197110A2B71003B056E /* string_util.h in Headers */, ); runOnlyForDeploymentPostprocessing = 0; }; Index: trunk/ChameleonPrefPane/string_util.h =================================================================== --- trunk/ChameleonPrefPane/string_util.h (revision 0) +++ trunk/ChameleonPrefPane/string_util.h (revision 39) @@ -0,0 +1,34 @@ +/* + * string_util.h + * ChameleonPrefPane + * + * Created by Rekursor on 1/22/10. + * + */ + +/** + * trim the space chars on the right of a sring + */ +inline std::string trim_right(const std::string &source , const std::string& t = " ") +{ + std::string str = source; + return str.erase( str.find_last_not_of(t) + 1); +} + +/** + * trim the space chars on the left of a sring + */ +inline std::string trim_left( const std::string& source, const std::string& t = " ") +{ + std::string str = source; + return str.erase(0 , source.find_first_not_of(t) ); +} + +/** + * trim the space chars on the left and the right of a string + */ +inline std::string trim(const std::string& source, const std::string& t = " ") +{ + std::string str = source; + return trim_left( trim_right( str , t) , t ); +}