-
Notifications
You must be signed in to change notification settings - Fork 0
/
text.h
66 lines (51 loc) · 1.77 KB
/
text.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
#ifndef _H_TEXT
#define _H_TEXT
#include <string>
#include <vector>
typedef std::vector<std::string> StringList;
typedef int64_t intp_t; // PHP on 64 bit integers
#ifdef __has_include
# if __has_include(<string_view>)
# include <string_view>
# if __cplusplus >= 201703L || defined(_LIBCPP_STRING_VIEW)
# define ABSL_HAVE_STD_STRING_VIEW 1
# endif
# endif
#endif
#ifndef ABSL_HAVE_STD_STRING_VIEW
# include <experimental/string_view>
namespace svx = std::experimental;
#else
namespace svx = std;
#endif
#include <phpcpp.h>
#ifndef _H_PUN_TYPE
#include "puntype.h"
#endif
namespace pun {
//! Tries to do thing as PHP version.
std::string uncamelize(const std::string& s, char sep);
//! Tries to do thing as PHP version.
StringList explode(const std::string& sep, const std::string& toSplit);
//! Tries to do thing as PHP version.
std::string str_replace(
const std::string& from,
const std::string& to,
const std::string& subject);
/*! Return the number of replacements.
If return zero, the result is unchanged
else result contains new string with replacements
Argument src can be view of original result, or any other string.
*/
unsigned int replaceAll(svx::string_view src,
const svx::string_view& out,
const svx::string_view& in,
std::string& result);
void replaceVar_object(Php::Value& obj, Php::Value& lookup);
bool replaceVar_str(const svx::string_view& src,
std::string& result,
Php::Value& lookup);
void replaceVar_ValueArray(ValueArray& items, Php::Value& lookup);
void replaceVar_ValueMap(ValueMap& items, Php::Value& lookup);
};
#endif