I2P Address: [http://git.idk.i2p]

Skip to content
Snippets Groups Projects
Commit 9b958e44 authored by meeh's avatar meeh
Browse files

Moving replace function to strutil.hpp

parent 281c5f57
No related branches found
No related tags found
No related merge requests found
...@@ -53,16 +53,12 @@ inline std::string extractString(CFStringRef value) ...@@ -53,16 +53,12 @@ inline std::string extractString(CFStringRef value)
} }
} }
using std::experimental::optional; bool replace(std::string& str, const std::string& from, const std::string& to) {
size_t start_pos = str.find(from);
// Use CFStringRef instead of NSString*, otherwise disable ARC if(start_pos == std::string::npos)
inline optional<CFStringRef> optionalString(bool val) { return false;
optional<CFStringRef> myOptString; str.replace(start_pos, from.length(), to);
if(val) { return true;
// Cast to corresponding CoreFoundation object
myOptString = (CFStringRef)@"String";
}
return myOptString;
} }
...@@ -102,4 +98,22 @@ static inline std::string trim_copy(std::string s) { ...@@ -102,4 +98,22 @@ static inline std::string trim_copy(std::string s) {
return s; return s;
} }
#ifdef CPP17
using std::experimental::optional;
// Use CFStringRef instead of NSString*, otherwise disable ARC
inline optional<CFStringRef> optionalString(bool val) {
optional<CFStringRef> myOptString;
if(val) {
// Cast to corresponding CoreFoundation object
myOptString = (CFStringRef)@"String";
}
return myOptString;
}
#endif
#endif #endif
...@@ -84,17 +84,6 @@ void setGlobalRouterIsRunning(bool running) ...@@ -84,17 +84,6 @@ void setGlobalRouterIsRunning(bool running)
@implementation ExtractMetaInfo : NSObject @implementation ExtractMetaInfo : NSObject
@end @end
#ifdef __cplusplus
bool replace(std::string& str, const std::string& from, const std::string& to) {
size_t start_pos = str.find(from);
if(start_pos == std::string::npos)
return false;
str.replace(start_pos, from.length(), to);
return true;
}
#endif
@implementation AppDelegate @implementation AppDelegate
...@@ -109,6 +98,7 @@ bool replace(std::string& str, const std::string& from, const std::string& to) { ...@@ -109,6 +98,7 @@ bool replace(std::string& str, const std::string& from, const std::string& to) {
#include <assert.h> #include <assert.h>
#include "include/subprocess.hpp" #include "include/subprocess.hpp"
#include "include/strutil.hpp"
using namespace subprocess; using namespace subprocess;
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment