| #pragma once |
|
|
| #include <optional> |
| #include <string> |
| #include <vector> |
|
|
| #include "utils.h" |
|
|
| namespace jinja { |
|
|
| |
| |
| |
| |
| |
| struct string_part { |
| bool is_input = false; |
| std::string val; |
|
|
| bool is_uppercase() const; |
| bool is_lowercase() const; |
| }; |
|
|
| struct string { |
| std::vector<string_part> parts; |
| string() = default; |
| string(const std::string & v, bool user_input = false) { |
| parts.push_back({user_input, v}); |
| } |
| string(int v) { |
| parts.push_back({false, std::to_string(v)}); |
| } |
| string(double v) { |
| parts.push_back({false, std::to_string(v)}); |
| } |
|
|
| |
| void mark_input(); |
|
|
| std::string str() const; |
| size_t length() const; |
| void hash_update(hasher & hash) const noexcept; |
| bool all_parts_are_input() const; |
| bool is_uppercase() const; |
| bool is_lowercase() const; |
|
|
| |
| void mark_input_based_on(const string & other); |
|
|
| string append(const string & other); |
|
|
| |
|
|
| string uppercase(); |
| string lowercase(); |
| string capitalize(); |
| string titlecase(); |
| string strip(bool left, bool right, std::optional<const std::string_view> chars = std::nullopt); |
| }; |
|
|
| } |
|
|