sources/mystring.h

Wed, 27 Jan 2021 18:55:03 +0200

author
Teemu Piippo <teemu@hecknology.net>
date
Wed, 27 Jan 2021 18:55:03 +0200
changeset 186
9330b93d9946
parent 183
9b6a0daedfc0
child 189
248d0b85cbda
permissions
-rw-r--r--

cleanup ip address code

1
4dd5bde4e777 - a whole lot of supplementary source code!!
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
1 /*
109
e4966d7e615d Happy new year 2016
Teemu Piippo <crimsondusk64@gmail.com>
parents: 107
diff changeset
2 Copyright 2014 - 2016 Teemu Piippo
1
4dd5bde4e777 - a whole lot of supplementary source code!!
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
3 All rights reserved.
4dd5bde4e777 - a whole lot of supplementary source code!!
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
4
4dd5bde4e777 - a whole lot of supplementary source code!!
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
5 Redistribution and use in source and binary forms, with or without
4dd5bde4e777 - a whole lot of supplementary source code!!
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
6 modification, are permitted provided that the following conditions
4dd5bde4e777 - a whole lot of supplementary source code!!
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
7 are met:
4dd5bde4e777 - a whole lot of supplementary source code!!
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
8
4dd5bde4e777 - a whole lot of supplementary source code!!
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
9 1. Redistributions of source code must retain the above copyright
4dd5bde4e777 - a whole lot of supplementary source code!!
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
10 notice, this list of conditions and the following disclaimer.
4dd5bde4e777 - a whole lot of supplementary source code!!
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
11 2. Redistributions in binary form must reproduce the above copyright
4dd5bde4e777 - a whole lot of supplementary source code!!
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
12 notice, this list of conditions and the following disclaimer in the
4dd5bde4e777 - a whole lot of supplementary source code!!
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
13 documentation and/or other materials provided with the distribution.
4dd5bde4e777 - a whole lot of supplementary source code!!
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
14 3. Neither the name of the copyright holder nor the names of its
4dd5bde4e777 - a whole lot of supplementary source code!!
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
15 contributors may be used to endorse or promote products derived from
4dd5bde4e777 - a whole lot of supplementary source code!!
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
16 this software without specific prior written permission.
4dd5bde4e777 - a whole lot of supplementary source code!!
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
17
4dd5bde4e777 - a whole lot of supplementary source code!!
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
18 THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
4dd5bde4e777 - a whole lot of supplementary source code!!
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
19 "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
4dd5bde4e777 - a whole lot of supplementary source code!!
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
20 TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A
4dd5bde4e777 - a whole lot of supplementary source code!!
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
21 PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER
4dd5bde4e777 - a whole lot of supplementary source code!!
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
22 OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
4dd5bde4e777 - a whole lot of supplementary source code!!
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
23 EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
4dd5bde4e777 - a whole lot of supplementary source code!!
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
24 PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
4dd5bde4e777 - a whole lot of supplementary source code!!
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
25 PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
4dd5bde4e777 - a whole lot of supplementary source code!!
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
26 LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
4dd5bde4e777 - a whole lot of supplementary source code!!
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
27 NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
4dd5bde4e777 - a whole lot of supplementary source code!!
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
28 SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
4dd5bde4e777 - a whole lot of supplementary source code!!
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
29 */
4dd5bde4e777 - a whole lot of supplementary source code!!
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
30
4dd5bde4e777 - a whole lot of supplementary source code!!
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
31 #pragma once
4dd5bde4e777 - a whole lot of supplementary source code!!
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
32 #include <deque>
4dd5bde4e777 - a whole lot of supplementary source code!!
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
33 #include <string>
4dd5bde4e777 - a whole lot of supplementary source code!!
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
34 #include <stdarg.h>
4dd5bde4e777 - a whole lot of supplementary source code!!
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
35 #include "basics.h"
4dd5bde4e777 - a whole lot of supplementary source code!!
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
36 #include "list.h"
145
d0aedc9be448 Renamed String methods, and reformatted mystring.h
Teemu Piippo <teemu@compsta2.com>
parents: 129
diff changeset
37
88
08ccaf26cffd Now works with MSVC 2010/pdcurses-win32a
Teemu Piippo <tsapii@utu.fi>
parents: 87
diff changeset
38 BEGIN_ZFC_NAMESPACE
1
4dd5bde4e777 - a whole lot of supplementary source code!!
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
39
182
20ca0a6be175 removed the String class in favor of std::string
Teemu Piippo <teemu@hecknology.net>
parents: 179
diff changeset
40 using String = std::string;
20ca0a6be175 removed the String class in favor of std::string
Teemu Piippo <teemu@hecknology.net>
parents: 179
diff changeset
41 using StringList = std::vector<std::string>;
20ca0a6be175 removed the String class in favor of std::string
Teemu Piippo <teemu@hecknology.net>
parents: 179
diff changeset
42 using namespace std::string_literals;
145
d0aedc9be448 Renamed String methods, and reformatted mystring.h
Teemu Piippo <teemu@compsta2.com>
parents: 129
diff changeset
43
182
20ca0a6be175 removed the String class in favor of std::string
Teemu Piippo <teemu@hecknology.net>
parents: 179
diff changeset
44 std::string to_lowercase(const std::string& string);
183
9b6a0daedfc0 renamed String and StringList uses
Teemu Piippo <teemu@hecknology.net>
parents: 182
diff changeset
45 std::string join_string_list(const std::vector<std::string>& strings, const std::string& delim);
182
20ca0a6be175 removed the String class in favor of std::string
Teemu Piippo <teemu@hecknology.net>
parents: 179
diff changeset
46 std::string mid(const std::string& str, int rangeBegin, int rangeEnd);
20ca0a6be175 removed the String class in favor of std::string
Teemu Piippo <teemu@hecknology.net>
parents: 179
diff changeset
47 std::string right(const std::string& str, int length);
20ca0a6be175 removed the String class in favor of std::string
Teemu Piippo <teemu@hecknology.net>
parents: 179
diff changeset
48 std::string vsprintf(const char* formatString, va_list args);
20ca0a6be175 removed the String class in favor of std::string
Teemu Piippo <teemu@hecknology.net>
parents: 179
diff changeset
49 std::string __cdecl sprintf(const char* formatString, ...);
20ca0a6be175 removed the String class in favor of std::string
Teemu Piippo <teemu@hecknology.net>
parents: 179
diff changeset
50 std::string remove_range(const std::string& string, int start, int end);
20ca0a6be175 removed the String class in favor of std::string
Teemu Piippo <teemu@hecknology.net>
parents: 179
diff changeset
51 void replace_all(std::string& str, const char* text, const char* replacement);
183
9b6a0daedfc0 renamed String and StringList uses
Teemu Piippo <teemu@hecknology.net>
parents: 182
diff changeset
52 bool starts_with(const std::string& str, const std::string& other);
9b6a0daedfc0 renamed String and StringList uses
Teemu Piippo <teemu@hecknology.net>
parents: 182
diff changeset
53 std::vector<std::string> split(const std::string& string, const std::string& delimeter);
182
20ca0a6be175 removed the String class in favor of std::string
Teemu Piippo <teemu@hecknology.net>
parents: 179
diff changeset
54 std::optional<long> to_int(const char* str, int base = 10);
20ca0a6be175 removed the String class in favor of std::string
Teemu Piippo <teemu@hecknology.net>
parents: 179
diff changeset
55 void normalize(std::string& string, int (*filter)(int) = std::isspace);
145
d0aedc9be448 Renamed String methods, and reformatted mystring.h
Teemu Piippo <teemu@compsta2.com>
parents: 129
diff changeset
56
88
08ccaf26cffd Now works with MSVC 2010/pdcurses-win32a
Teemu Piippo <tsapii@utu.fi>
parents: 87
diff changeset
57 END_ZFC_NAMESPACE

mercurial