forked from gfwilliams/tiny-js
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathutils.h
executable file
·64 lines (45 loc) · 1.82 KB
/
utils.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
/*
* TinyJS
*
* Miscellaneous functions.
*/
#pragma once
#include <string>
#include <sstream>
#include <stdarg.h>
#include "jsLexer.h"
typedef std::vector<std::string> StringVector;
struct ScriptPosition;
bool isWhitespace(char ch);
bool isNumeric(char ch);
bool isNumber(const std::string &str);
bool isHexadecimal(char ch);
bool isOctal(char ch);
bool isOctal(const std::string& str);
bool isAlpha(char ch);
bool isAlphaNum(const std::string &str);
bool isIDString(const char *s);
void replace(std::string &str, char textFrom, const char *textTo);
bool startsWith (const std::string& str, const std::string& prefix);
StringVector split (const std::string& str, const std::string& separator);
std::string join (const StringVector& strings, const std::string& separator);
int copyWhile(char* dest, const char* src, bool (*conditionFN)(char), int maxLen);
const char* skipWhitespace(const char* input);
const char* skipNumeric(const char* input);
const char* skipHexadecimal(const char* input);
/// convert the given string into a quoted string suitable for javascript
std::string escapeString(const std::string &str, bool quote = true);
std::string indentText(int indent);
std::string double_to_string(double x);
double getNaN();
std::string readTextFile (const std::string& szPath);
bool writeTextFile (const std::string& szPath, const std::string& szContent);
bool createDirIfNotExist (const std::string& szPath);
std::string dirFromPath (const std::string& szPath);
std::string parentPath (const std::string& szPath);
std::string removeExt (const std::string& szPath);
std::string fileFromPath (const std::string& szPath);
std::string normalizePath (const std::string& path);
std::string joinPaths (const std::string& base, const std::string& relative);
bool isPathRelative (const std::string& path);
std::string getCurrentDirectory();