Migrated engine to using dlmalloc through eng::
This commit is contained in:
@@ -30,88 +30,88 @@ enum MessageType {
|
||||
MSG_INVOKE,
|
||||
};
|
||||
|
||||
using StringVec = std::vector<std::string>;
|
||||
using StringPair = std::pair<std::string, std::string>;
|
||||
using StringSet = std::set<std::string>;
|
||||
using LuaSourceVec = std::vector<StringPair>;
|
||||
using LuaSourcePtr = std::unique_ptr<LuaSourceVec>;
|
||||
using HashValue = std::pair<uint64_t, uint64_t>;
|
||||
using IdVector = std::vector<int64_t>;
|
||||
using StringVec = eng::vector<eng::string>;
|
||||
using StringPair = eng::pair<eng::string, eng::string>;
|
||||
using StringSet = eng::set<eng::string>;
|
||||
using LuaSourceVec = eng::vector<StringPair>;
|
||||
using LuaSourcePtr = eng::unique_ptr<LuaSourceVec>;
|
||||
using HashValue = eng::pair<uint64_t, uint64_t>;
|
||||
using IdVector = eng::vector<int64_t>;
|
||||
|
||||
// Return seconds elapsed, for profiling purposes.
|
||||
double profiling_clock();
|
||||
|
||||
// Return true if the string is a valid lua identifier.
|
||||
bool is_identifier(const std::string &str);
|
||||
bool is_identifier(const eng::string &str);
|
||||
|
||||
// Output a string to a stream using Lua string escaping and quoting.
|
||||
void quote_string(const std::string &str, std::ostream *os);
|
||||
void quote_string(const eng::string &str, eng::ostream *os);
|
||||
|
||||
// ID vector quick create.
|
||||
IdVector id_vector_create(int64_t id1=-1, int64_t id2=-1, int64_t id3=-1, int64_t id4=-1);
|
||||
|
||||
// ID vector debug string.
|
||||
std::string id_vector_debug_string(const IdVector &idv);
|
||||
eng::string id_vector_debug_string(const IdVector &idv);
|
||||
|
||||
// Unions and sorts two ID vectors.
|
||||
IdVector sort_union_id_vectors(const IdVector &v1, const IdVector &v2);
|
||||
|
||||
// Get a 64-bit hashvalue for a string.
|
||||
HashValue hash_string(const std::string &str);
|
||||
HashValue hash_string(const eng::string &str);
|
||||
|
||||
// Get a 64-bit hashvalue for an ID vector.
|
||||
HashValue hash_id_vector(const IdVector &idv);
|
||||
|
||||
// Convert a hash to a hexadecimal string.
|
||||
std::string hash_to_hex(const HashValue &hash);
|
||||
eng::string hash_to_hex(const HashValue &hash);
|
||||
|
||||
// Split a string into multiple strings
|
||||
StringVec split(const std::string &s, char sep);
|
||||
StringVec split(const eng::string &s, char sep);
|
||||
|
||||
// Split a string into multiple strings using \r or \n
|
||||
StringVec split_lines(const std::string &s);
|
||||
StringVec split_lines(const eng::string &s);
|
||||
|
||||
// Split a string into multiple lines using |, remove any leading blank line.
|
||||
StringVec split_docstring(const std::string &s);
|
||||
StringVec split_docstring(const eng::string &s);
|
||||
|
||||
// Join multiple strings into one string
|
||||
std::string join(const StringVec &strs, std::string sep);
|
||||
eng::string join(const StringVec &strs, eng::string sep);
|
||||
|
||||
// Return N repetitions of string A
|
||||
std::string repeat_string(const std::string &a, int n);
|
||||
eng::string repeat_string(const eng::string &a, int n);
|
||||
|
||||
// Return the length of the common prefix of A and B.
|
||||
int common_prefix_length(const std::string &a, const std::string &b);
|
||||
int common_prefix_length(const eng::string &a, const eng::string &b);
|
||||
|
||||
// String to lowercase/uppercase. Ascii only, no unicode.
|
||||
std::string tolower(std::string input);
|
||||
std::string toupper(std::string input);
|
||||
eng::string tolower(eng::string input);
|
||||
eng::string toupper(eng::string input);
|
||||
|
||||
// Return true if the string has the specified prefix or suffix.
|
||||
bool has_prefix(const std::string &s, const std::string &prefix);
|
||||
bool has_suffix(const std::string &s, const std::string &suffix);
|
||||
bool has_prefix(const eng::string &s, const eng::string &prefix);
|
||||
bool has_suffix(const eng::string &s, const eng::string &suffix);
|
||||
|
||||
// Return true if the string can be parsed as an integer.
|
||||
bool validinteger(const std::string &value);
|
||||
bool validinteger(const eng::string &value);
|
||||
|
||||
// String to integer. Returns errval if the number is not parseable.
|
||||
int64_t strtoint(const std::string &value, int64_t errval);
|
||||
int64_t strtoint(const eng::string &value, int64_t errval);
|
||||
|
||||
// String to double. Returns NAN if the number is not parseable.
|
||||
double strtodouble(const std::string &value);
|
||||
double strtodouble(const eng::string &value);
|
||||
|
||||
// Trim a string_view
|
||||
std::string_view sv_ltrim(std::string_view v);
|
||||
std::string_view sv_rtrim(std::string_view v);
|
||||
std::string_view sv_trim(std::string_view v);
|
||||
eng::string_view sv_ltrim(eng::string_view v);
|
||||
eng::string_view sv_rtrim(eng::string_view v);
|
||||
eng::string_view sv_trim(eng::string_view v);
|
||||
|
||||
// Trim strings: left end, right end, both ends.
|
||||
std::string ltrim(std::string_view s);
|
||||
std::string rtrim(std::string_view s);
|
||||
std::string trim(std::string_view s);
|
||||
eng::string ltrim(eng::string_view s);
|
||||
eng::string rtrim(eng::string_view s);
|
||||
eng::string trim(eng::string_view s);
|
||||
|
||||
// Read a line from a string_view
|
||||
std::string_view sv_read_line(std::string_view &source);
|
||||
eng::string_view sv_read_line(eng::string_view &source);
|
||||
|
||||
// Calculate distance between two points
|
||||
double distance_squared(double x1, double y1, double x2, double y2);
|
||||
@@ -120,15 +120,15 @@ double distance_squared(double x1, double y1, double x2, double y2);
|
||||
bool world_type_authoritative(util::WorldType wt);
|
||||
|
||||
// Make a LuaSourceVec with one element, for unit testing.
|
||||
LuaSourcePtr make_lua_source(const std::string &code);
|
||||
LuaSourcePtr make_lua_source(const eng::string &code);
|
||||
|
||||
// Return true if the line of code is a lua comment.
|
||||
bool is_lua_comment(const std::string &line);
|
||||
bool is_lua_comment(const eng::string &line);
|
||||
|
||||
// Remove nullptrs from a vector of unique pointers.
|
||||
template<class T>
|
||||
void remove_nullptrs(std::vector<std::unique_ptr<T>> &vec) {
|
||||
std::unique_ptr<T> nullp;
|
||||
void remove_nullptrs(eng::vector<eng::unique_ptr<T>> &vec) {
|
||||
eng::unique_ptr<T> nullp;
|
||||
auto iter = std::remove(vec.begin(), vec.end(), nullp);
|
||||
vec.erase(iter, vec.end());
|
||||
}
|
||||
@@ -140,10 +140,10 @@ struct XYZ {
|
||||
XYZ(float ix, float iy, float iz) { x=ix; y=iy; z=iz; }
|
||||
bool operator ==(const XYZ &o) const { return x==o.x && y == o.y && z==o.z; }
|
||||
bool operator !=(const XYZ &o) const { return x!=o.x || y != o.y || z!=o.z; }
|
||||
std::string debug_string() const;
|
||||
eng::string debug_string() const;
|
||||
};
|
||||
|
||||
// These are formatting directives that can be sent to a std::ostream.
|
||||
// These are formatting directives that can be sent to a eng::ostream.
|
||||
class hex64 {};
|
||||
class hex32 {};
|
||||
class hex16 {};
|
||||
@@ -157,9 +157,9 @@ public:
|
||||
|
||||
} // namespace util
|
||||
|
||||
std::ostream &operator<<(std::ostream &oss, const util::hex64 &v);
|
||||
std::ostream &operator<<(std::ostream &oss, const util::hex32 &v);
|
||||
std::ostream &operator<<(std::ostream &oss, const util::hex16 &v);
|
||||
std::ostream &operator<<(std::ostream &oss, const util::hex8 &v);
|
||||
eng::ostream &operator<<(eng::ostream &oss, const util::hex64 &v);
|
||||
eng::ostream &operator<<(eng::ostream &oss, const util::hex32 &v);
|
||||
eng::ostream &operator<<(eng::ostream &oss, const util::hex16 &v);
|
||||
eng::ostream &operator<<(eng::ostream &oss, const util::hex8 &v);
|
||||
|
||||
#endif // UTIL_HPP
|
||||
|
||||
Reference in New Issue
Block a user