2021-10-29 21:25:12 +01:00
|
|
|
// This file is part of the Luau programming language and is licensed under MIT License; see LICENSE.txt for details
|
|
|
|
#pragma once
|
|
|
|
|
2022-10-14 20:48:41 +01:00
|
|
|
#include "Luau/Common.h"
|
|
|
|
|
2021-10-29 21:25:12 +01:00
|
|
|
#include <vector>
|
|
|
|
#include <string>
|
|
|
|
|
|
|
|
#include <stdarg.h>
|
|
|
|
|
|
|
|
namespace Luau
|
|
|
|
{
|
|
|
|
|
|
|
|
std::string format(const char* fmt, ...) LUAU_PRINTF_ATTR(1, 2);
|
|
|
|
std::string vformat(const char* fmt, va_list args);
|
|
|
|
|
|
|
|
void formatAppend(std::string& str, const char* fmt, ...) LUAU_PRINTF_ATTR(2, 3);
|
2022-04-21 22:44:27 +01:00
|
|
|
void vformatAppend(std::string& ret, const char* fmt, va_list args);
|
2021-10-29 21:25:12 +01:00
|
|
|
|
|
|
|
std::string join(const std::vector<std::string_view>& segments, std::string_view delimiter);
|
|
|
|
std::string join(const std::vector<std::string>& segments, std::string_view delimiter);
|
|
|
|
|
|
|
|
std::vector<std::string_view> split(std::string_view s, char delimiter);
|
|
|
|
|
|
|
|
// Computes the Damerau-Levenshtein distance of A and B.
|
|
|
|
// https://en.wikipedia.org/wiki/Damerau-Levenshtein_distance#Distance_with_adjacent_transpositions
|
|
|
|
size_t editDistance(std::string_view a, std::string_view b);
|
|
|
|
|
|
|
|
bool startsWith(std::string_view lhs, std::string_view rhs);
|
|
|
|
bool equalsLower(std::string_view lhs, std::string_view rhs);
|
|
|
|
|
|
|
|
size_t hashRange(const char* data, size_t size);
|
|
|
|
|
2022-08-24 20:01:00 +01:00
|
|
|
std::string escape(std::string_view s, bool escapeForInterpString = false);
|
2021-11-19 16:10:07 +00:00
|
|
|
bool isIdentifier(std::string_view s);
|
2021-10-29 21:25:12 +01:00
|
|
|
} // namespace Luau
|