summaryrefslogtreecommitdiffstats
path: root/src/common/string_util.h
diff options
context:
space:
mode:
Diffstat (limited to 'src/common/string_util.h')
-rw-r--r--src/common/string_util.h29
1 files changed, 15 insertions, 14 deletions
diff --git a/src/common/string_util.h b/src/common/string_util.h
index ceb8df48e..1f5a383cb 100644
--- a/src/common/string_util.h
+++ b/src/common/string_util.h
@@ -4,7 +4,6 @@
#pragma once
-#include <cstdarg>
#include <cstddef>
#include <iomanip>
#include <sstream>
@@ -20,21 +19,10 @@ std::string ToLower(std::string str);
/// Make a string uppercase
std::string ToUpper(std::string str);
-std::string StringFromFormat(const char* format, ...);
-// Cheap!
-bool CharArrayFromFormatV(char* out, int outsize, const char* format, va_list args);
-
-template <size_t Count>
-inline void CharArrayFromFormat(char (&out)[Count], const char* format, ...) {
- va_list args;
- va_start(args, format);
- CharArrayFromFormatV(out, Count, format, args);
- va_end(args);
-}
-
-// Good
std::string ArrayToString(const u8* data, size_t size, int line_len = 20, bool spaces = true);
+std::string StringFromBuffer(const std::vector<u8>& data);
+
std::string StripSpaces(const std::string& s);
std::string StripQuotes(const std::string& s);
@@ -134,4 +122,17 @@ bool ComparePartialString(InIt begin, InIt end, const char* other) {
* NUL-terminated then the string ends at max_len characters.
*/
std::string StringFromFixedZeroTerminatedBuffer(const char* buffer, size_t max_len);
+
+/**
+ * Attempts to trim an arbitrary prefix from `path`, leaving only the part starting at `root`. It's
+ * intended to be used to strip a system-specific build directory from the `__FILE__` macro,
+ * leaving only the path relative to the sources root.
+ *
+ * @param path The input file path as a null-terminated string
+ * @param root The name of the root source directory as a null-terminated string. Path up to and
+ * including the last occurrence of this name will be stripped
+ * @return A pointer to the same string passed as `path`, but starting at the trimmed portion
+ */
+const char* TrimSourcePath(const char* path, const char* root = "src");
+
} // namespace Common