osmanip
Library with useful output stream tools like: color and style manipulators, progress bars and terminal graphics.
strings.hpp
Go to the documentation of this file.
1 //====================================================
2 // File data
3 //====================================================
12 //====================================================
13 // Preprocessor settings
14 //====================================================
15 #pragma once
16 #ifndef OSMANIP_UTILITY_STRINGS_HPP
17 #define OSMANIP_UTILITY_STRINGS_HPP
18 
19 //====================================================
20 // Headers
21 //====================================================
22 
23 // STD headers
24 #include <stdint.h>
25 
26 #include <string>
27 
28 namespace osm {
29 
30  //====================================================
31  // Functions
32  //====================================================
33 
34  extern std::string get_formatted_from_ansi(const std::string &str, int32_t *last_pos = nullptr,
35  int32_t *last_size = nullptr);
36  [[maybe_unused]] extern std::string trim_string(std::string &str);
37  [[maybe_unused]] extern size_t find_first_alpha(std::string_view str, size_t pos);
38  [[maybe_unused]] extern std::string get_ansi_csi_string(const std::string &str, size_t esc_pos);
39  [[maybe_unused]] extern int32_t get_ansi_csi_number(const std::string &csi);
40  [[maybe_unused]] extern char get_ansi_csi_code(const std::string &csi);
41  [[maybe_unused]] extern void handle_csi(const std::string &csi_str, std::string &dst_str, int32_t *dst_crsr_pos);
42 
43 } // namespace osm
44 
45 #endif
Definition: canvas.cpp:30
void handle_csi(const std::string &csi_str, std::string &dst_str, int32_t *dst_crsr_pos)
size_t find_first_alpha(std::string_view str, size_t pos)
Finds the index of the first alphabetic character in the str, starting from the given position.
Definition: strings.cpp:73
std::string get_formatted_from_ansi(const std::string &str, int32_t *last_pos, int32_t *last_size)
Formats a string according to the ANSI (Control Sequence Introducer) escape sequences present within ...
Definition: strings.cpp:94
int32_t get_ansi_csi_number(const std::string &csi)
Definition: strings.cpp:197
std::string trim_string(const std::string &str)
Removes all leading and trailing spaces from a string.
Definition: strings.cpp:43
std::string get_ansi_csi_string(const std::string &str, size_t esc_pos)
Definition: strings.cpp:176
char get_ansi_csi_code(const std::string &csi)
Definition: strings.cpp:234