ArkScript
A small, fast, functional and scripting language for video games
Utils.hpp
Go to the documentation of this file.
1/**
2 * @file Utils.hpp
3 * @author Alexandre Plateau ([email protected])
4 * @brief replxx utilities
5 * @version 1.1
6 * @date 2020-10-27
7 *
8 * @copyright Copyright (c) 2020-2024
9 *
10 */
11
12#ifndef REPL_REPLXX_UTIL_HPP
13#define REPL_REPLXX_UTIL_HPP
14
15#include <vector>
16#include <string>
17
18#include <replxx.hxx>
19
20namespace Ark::internal
21{
22 /**
23 * @brief Count the open enclosure and its counterpart: (), {}, []
24 * @param line data to operate on
25 * @param open the open char: (, { or [
26 * @param close the closing char: ), } or ]
27 * @return positive if there are more open enclosures than closed. 0 when both are equal, negative otherwise
28 */
29 long countOpenEnclosures(const std::string& line, char open, char close);
30
31 /**
32 * @brief Remove whitespaces at the start and end of a string
33 * @param line string modified in place
34 */
35 void trimWhitespace(std::string& line);
36
37 replxx::Replxx::completions_t hookCompletion(const std::vector<std::string>& words, const std::string& context, int& length);
38
39 void hookColor(const std::vector<std::pair<std::string, replxx::Replxx::Color>>& words_colors, const std::string& context, replxx::Replxx::colors_t& colors);
40
41 replxx::Replxx::hints_t hookHint(const std::vector<std::string>& words, const std::string& context, int& length, replxx::Replxx::Color& color);
42}
43
44#endif
long countOpenEnclosures(const std::string &line, char open, char close)
Count the open enclosure and its counterpart: (), {}, [].
Definition Utils.cpp:8
void hookColor(const std::vector< std::pair< std::string, replxx::Replxx::Color > > &words_colors, const std::string &context, replxx::Replxx::colors_t &colors)
Definition Utils.cpp:73
constexpr std::array colors
Definition Logger.cpp:8
replxx::Replxx::completions_t hookCompletion(const std::vector< std::string > &words, const std::string &context, int &length)
Definition Utils.cpp:49
replxx::Replxx::hints_t hookHint(const std::vector< std::string > &words, const std::string &context, int &length, replxx::Replxx::Color &color)
Definition Utils.cpp:98
void trimWhitespace(std::string &line)
Remove whitespaces at the start and end of a string.
Definition Utils.cpp:13