158 lines
2.6 KiB
Plaintext
158 lines
2.6 KiB
Plaintext
# Oraset 标准库 - std.oinc
|
|
# 使用方法: oraset -i https://oraset.parlz.com/inc/std.oinc
|
|
|
|
# ==================== 数学函数 ====================
|
|
|
|
sin(x:double) -> double {
|
|
return std::sin(x);
|
|
}
|
|
|
|
cos(x:double) -> double {
|
|
return std::cos(x);
|
|
}
|
|
|
|
tan(x:double) -> double {
|
|
return std::tan(x);
|
|
}
|
|
|
|
asin(x:double) -> double {
|
|
return std::asin(x);
|
|
}
|
|
|
|
acos(x:double) -> double {
|
|
return std::acos(x);
|
|
}
|
|
|
|
atan(x:double) -> double {
|
|
return std::atan(x);
|
|
}
|
|
|
|
sinh(x:double) -> double {
|
|
return std::sinh(x);
|
|
}
|
|
|
|
cosh(x:double) -> double {
|
|
return std::cosh(x);
|
|
}
|
|
|
|
tanh(x:double) -> double {
|
|
return std::tanh(x);
|
|
}
|
|
|
|
exp(x:double) -> double {
|
|
return std::exp(x);
|
|
}
|
|
|
|
log(x:double) -> double {
|
|
return std::log(x);
|
|
}
|
|
|
|
log10(x:double) -> double {
|
|
return std::log10(x);
|
|
}
|
|
|
|
sqrt(x:double) -> double {
|
|
return std::sqrt(x);
|
|
}
|
|
|
|
pow(base:double, exp:double) -> double {
|
|
return std::pow(base, exp);
|
|
}
|
|
|
|
abs(x:double) -> double {
|
|
return std::abs(x);
|
|
}
|
|
|
|
floor(x:double) -> double {
|
|
return std::floor(x);
|
|
}
|
|
|
|
ceil(x:double) -> double {
|
|
return std::ceil(x);
|
|
}
|
|
|
|
round(x:double) -> double {
|
|
return std::round(x);
|
|
}
|
|
|
|
pi() -> double {
|
|
return M_PI;
|
|
}
|
|
|
|
e() -> double {
|
|
return M_E;
|
|
}
|
|
|
|
# ==================== 字符串函数 ====================
|
|
|
|
strlen(s:string) -> int {
|
|
return std::strlen(s);
|
|
}
|
|
|
|
strcmp(s1:string, s2:string) -> int {
|
|
return std::strcmp(s1, s2);
|
|
}
|
|
|
|
strstr(haystack:string, needle:string) -> string {
|
|
return (char*)std::strstr(haystack, needle);
|
|
}
|
|
|
|
strtolower(s:string) -> string {
|
|
char* p = s;
|
|
while (*p) {
|
|
*p = std::tolower(*p);
|
|
p++;
|
|
}
|
|
return s;
|
|
}
|
|
|
|
strtoupper(s:string) -> string {
|
|
char* p = s;
|
|
while (*p) {
|
|
*p = std::toupper(*p);
|
|
p++;
|
|
}
|
|
return s;
|
|
}
|
|
|
|
# ==================== 系统函数 ====================
|
|
|
|
system(cmd:string) -> int {
|
|
return std::system(cmd);
|
|
}
|
|
|
|
exit(code:int) {
|
|
std::exit(code);
|
|
}
|
|
|
|
getenv(name:string, default_val:string) -> string {
|
|
char* val = std::getenv(name);
|
|
return val ? val : default_val;
|
|
}
|
|
|
|
# ==================== 文件操作 ====================
|
|
|
|
file_exists(filename:string) -> int {
|
|
std::ifstream f(filename);
|
|
return f.good() ? 1 : 0;
|
|
}
|
|
|
|
file_read(filename:string) -> string {
|
|
std::ifstream f(filename);
|
|
std::stringstream buffer;
|
|
buffer << f.rdbuf();
|
|
return buffer.str();
|
|
}
|
|
|
|
file_write(filename:string, content:string) -> int {
|
|
std::ofstream f(filename);
|
|
f << content;
|
|
return f.good() ? 1 : 0;
|
|
}
|
|
|
|
file_append(filename:string, content:string) -> int {
|
|
std::ofstream f(filename, std::ios::app);
|
|
f << content;
|
|
return f.good() ? 1 : 0;
|
|
}
|