Debian Codegraph @

packages/seacas/applications/exodiff/stringx.h

raw
1 // Copyright(C) 1999-2022, 2024 National Technology & Engineering Solutions
2 // of Sandia, LLC (NTESS). Under the terms of Contract DE-NA0003525 with
3 // NTESS, the U.S. Government retains certain rights in this software.
4 //
5 // See packages/seacas/LICENSE for details
6 #pragma once
7
8 #include "util.h"
9 #include <string>
10 #include <vector>
11
12 //! Compare a string against another "master" string, where the string, str,
13 //! can be abbreiviated to as little as min_length characters. Returns true
14 //! only if str has at least min_length characters and those that it does
15 //! have match the master string exactly.
16 bool abbreviation(const std::string &s, const std::string &master, unsigned min_length);
17
18 //! Compares two string ignoring letter case. Returns true if they are equal.
19 bool no_case_equals(const std::string &s1, const std::string &s2);
20
21 //! Removes whitespace from the end of the string. Returns the string given
22 //! as the argument.
23 std::string &chop_whitespace(std::string &s);
24
25 //! Separates the next token from the given string. The next token is
26 //! returned and the given string has the next token removed (so it is
27 //! modified in place).
28 std::string extract_token(std::string &s, const char *delimiters = " \t\n\r");
29
30 //! Counts how many tokens are contained in the given string.
31 int count_tokens(const std::string &s, const char *delimiters = " \t\n\r");
32
33 //! Runs each string in the vector and returns the maximum size.
34 int max_string_length(const NameList &names);
35
36 //! Replaces each character of the string with its lower case equivalent.
37 void to_lower(std::string &s);
38
39 //! Returns the first non-white space character of the string. If the string
40 //! is empty or all white space, a nullptr char is returned.
41 char first_character(const std::string &s);
42
43 //! Searches the list of strings for a particular string value. Letter case
44 //! will be ignored if the last argument is true. Returns the index of the
45 //! string in the vector if found, otherwise returns -1.
46 int find_string(const NameList &lst, const std::string &s, bool nocase);