forked from I2P_Developers/i2p.i2p
Moving replace function to strutil.hpp
This commit is contained in:
@@ -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) {
|
|||||||
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)
|
|||||||
@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) {
|
|||||||
#include <assert.h>
|
#include <assert.h>
|
||||||
|
|
||||||
#include "include/subprocess.hpp"
|
#include "include/subprocess.hpp"
|
||||||
|
#include "include/strutil.hpp"
|
||||||
|
|
||||||
using namespace subprocess;
|
using namespace subprocess;
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user