2018-12-31 20:04:05 +01:00
|
|
|
//
|
2022-12-31 22:28:08 +01:00
|
|
|
// Copyright Aliaksei Levin (levlam@telegram.org), Arseny Smirnov (arseny30@gmail.com) 2014-2023
|
2018-12-31 20:04:05 +01:00
|
|
|
//
|
|
|
|
// Distributed under the Boost Software License, Version 1.0. (See accompanying
|
|
|
|
// file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
|
|
|
|
//
|
|
|
|
#pragma once
|
|
|
|
|
|
|
|
#include "td/utils/common.h"
|
2022-10-12 15:09:42 +02:00
|
|
|
#include "td/utils/Slice.h"
|
2023-02-26 23:17:22 +01:00
|
|
|
#include "td/utils/Status.h"
|
2018-12-31 20:04:05 +01:00
|
|
|
|
|
|
|
namespace td {
|
|
|
|
|
|
|
|
// cleans user name/dialog title
|
|
|
|
string clean_name(string str, size_t max_length) TD_WARN_UNUSED_RESULT;
|
|
|
|
|
|
|
|
// prepares username/stickername for search
|
|
|
|
string clean_username(string str) TD_WARN_UNUSED_RESULT;
|
|
|
|
|
2022-02-18 14:57:08 +01:00
|
|
|
// prepares phone number for search
|
|
|
|
void clean_phone_number(string &phone_number);
|
|
|
|
|
2020-04-08 00:23:05 +02:00
|
|
|
// replaces some offending characters without changing string length
|
|
|
|
void replace_offending_characters(string &str);
|
|
|
|
|
2018-12-31 20:04:05 +01:00
|
|
|
// removes control characters from the string, will fail if input string is not in UTF-8
|
|
|
|
bool clean_input_string(string &str) TD_WARN_UNUSED_RESULT;
|
|
|
|
|
|
|
|
// strips empty characters and ensures that string length is no more than max_length
|
2019-10-04 17:00:51 +02:00
|
|
|
string strip_empty_characters(string str, size_t max_length, bool strip_rtlo = false) TD_WARN_UNUSED_RESULT;
|
2018-12-31 20:04:05 +01:00
|
|
|
|
|
|
|
// checks if string is empty after strip_empty_characters
|
|
|
|
bool is_empty_string(const string &str) TD_WARN_UNUSED_RESULT;
|
|
|
|
|
2022-10-12 15:09:42 +02:00
|
|
|
// checks whether a string could be a valid username
|
|
|
|
bool is_valid_username(Slice username);
|
|
|
|
|
2022-08-31 16:46:03 +02:00
|
|
|
// calculates hash of list of uint64
|
2021-09-03 11:27:59 +02:00
|
|
|
int64 get_vector_hash(const vector<uint64> &numbers) TD_WARN_UNUSED_RESULT;
|
2018-12-31 20:04:05 +01:00
|
|
|
|
|
|
|
// returns emoji corresponding to the specified number
|
|
|
|
string get_emoji_fingerprint(uint64 num);
|
|
|
|
|
2022-09-22 18:33:43 +02:00
|
|
|
// checks whether currency amount is valid
|
|
|
|
bool check_currency_amount(int64 amount);
|
|
|
|
|
2023-02-26 23:17:22 +01:00
|
|
|
// checks whether language code is valid for bot settings
|
|
|
|
Status validate_bot_language_code(const string &language_code);
|
|
|
|
|
2023-08-16 12:39:59 +02:00
|
|
|
// returns 0-based indexes of strings matching the query by prefixes
|
|
|
|
vector<int32> search_strings_by_prefix(const vector<string> &strings, const string &query, int32 limit,
|
|
|
|
bool return_all_for_empty_query, int32 &total_count);
|
|
|
|
|
2018-12-31 20:04:05 +01:00
|
|
|
} // namespace td
|