Changeset 9b958e4 for launchers


Ignore:
Timestamp:
Sep 19, 2018 4:03:39 PM (19 months ago)
Author:
meeh <meeh@…>
Branches:
master
Children:
802115e
Parents:
281c5f57
Message:

Moving replace function to strutil.hpp

Location:
launchers/macosx
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • launchers/macosx/include/strutil.hpp

    r281c5f57 r9b958e4  
    5454}
    5555
    56 using std::experimental::optional;
    57 
    58 // Use CFStringRef instead of NSString*, otherwise disable ARC
    59 inline optional<CFStringRef> optionalString(bool val) {
    60     optional<CFStringRef> myOptString;
    61     if(val) {
    62         // Cast to corresponding CoreFoundation object
    63         myOptString = (CFStringRef)@"String";
    64     }
    65     return myOptString;
     56bool replace(std::string& str, const std::string& from, const std::string& to) {
     57  size_t start_pos = str.find(from);
     58  if(start_pos == std::string::npos)
     59    return false;
     60  str.replace(start_pos, from.length(), to);
     61  return true;
    6662}
    6763
     
    10399}
    104100
     101#ifdef CPP17
     102
     103
     104using std::experimental::optional;
     105
     106// Use CFStringRef instead of NSString*, otherwise disable ARC
     107inline optional<CFStringRef> optionalString(bool val) {
     108  optional<CFStringRef> myOptString;
     109  if(val) {
     110    // Cast to corresponding CoreFoundation object
     111    myOptString = (CFStringRef)@"String";
     112  }
     113  return myOptString;
     114}
     115
    105116#endif
     117
     118
     119#endif
  • launchers/macosx/main.mm

    r281c5f57 r9b958e4  
    8585@end
    8686
    87 #ifdef __cplusplus
    88 
    89 bool replace(std::string& str, const std::string& from, const std::string& to) {
    90   size_t start_pos = str.find(from);
    91   if(start_pos == std::string::npos)
    92     return false;
    93   str.replace(start_pos, from.length(), to);
    94   return true;
    95 }
    96 
    97 #endif
    9887
    9988@implementation AppDelegate
     
    11099
    111100#include "include/subprocess.hpp"
     101#include "include/strutil.hpp"
    112102
    113103using namespace subprocess;
Note: See TracChangeset for help on using the changeset viewer.