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;
|
||||
|
||||
// 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;
|
||||
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;
|
||||
}
|
||||
|
||||
|
||||
@@ -102,4 +98,22 @@ static inline std::string trim_copy(std::string 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
|
||||
|
@@ -84,17 +84,6 @@ void setGlobalRouterIsRunning(bool running)
|
||||
@implementation ExtractMetaInfo : NSObject
|
||||
@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
|
||||
|
||||
@@ -109,6 +98,7 @@ bool replace(std::string& str, const std::string& from, const std::string& to) {
|
||||
#include <assert.h>
|
||||
|
||||
#include "include/subprocess.hpp"
|
||||
#include "include/strutil.hpp"
|
||||
|
||||
using namespace subprocess;
|
||||
|
||||
|
Reference in New Issue
Block a user