sources/mystring.h

branch
protocol5
changeset 131
4996c8684b93
parent 108
5900be70c619
parent 129
a556ce001e26
child 150
37db42ad451a
equal deleted inserted replaced
130:9f54db6f9922 131:4996c8684b93
1 /* 1 /*
2 Copyright 2014, 2015 Teemu Piippo 2 Copyright 2014 - 2016 Teemu Piippo
3 All rights reserved. 3 All rights reserved.
4 4
5 Redistribution and use in source and binary forms, with or without 5 Redistribution and use in source and binary forms, with or without
6 modification, are permitted provided that the following conditions 6 modification, are permitted provided that the following conditions
7 are met: 7 are met:
67 ConstIterator begin() const { return m_string.cbegin(); } 67 ConstIterator begin() const { return m_string.cbegin(); }
68 int compare (const String &other) const; 68 int compare (const String &other) const;
69 int count (char needle) const; 69 int count (char needle) const;
70 const char* chars() const { return m_string.c_str(); } 70 const char* chars() const { return m_string.c_str(); }
71 ConstIterator end() const { return m_string.end(); } 71 ConstIterator end() const { return m_string.end(); }
72 int find (const char*c, int a = 0) const; 72 int find (const char* c, int a = 0) const;
73 int find (char ch, int a = 0) const;
73 bool is_empty() const { return m_string[0] == '\0'; } 74 bool is_empty() const { return m_string[0] == '\0'; }
74 bool is_numeric() const; 75 bool is_numeric() const;
75 int find_last (const char*c, int a) const; 76 int find_last (const char*c, int a) const;
76 int length() const { return m_string.length(); } 77 int length() const { return m_string.length(); }
77 bool mask_against (const String &pattern) const; 78 bool mask_against (const String &pattern) const;
78 String md5() const; 79 String md5() const;
79 String mid (long a, long b) const; 80 String mid (int a, int b) const;
80 String right (int length) const; 81 String right (int length) const;
81 StringList split (const String &del) const; 82 StringList split (const String &del) const;
82 StringList split (char del) const; 83 StringList split (char del) const;
83 const std::string& std_string() const { return m_string; } 84 const std::string& std_string() const { return m_string; }
85 String strip (char unwanted) const;
86 String strip (const List<char> &unwanted) const;
84 double to_double (bool* ok = nullptr) const; 87 double to_double (bool* ok = nullptr) const;
85 float to_float (bool* ok = nullptr) const; 88 float to_float (bool* ok = nullptr) const;
86 long to_int (bool* ok = nullptr, int base = 10) const; 89 long to_int (bool* ok = nullptr, int base = 10) const;
87 String to_lowercase() const; 90 String to_lowercase() const;
88 String to_uppercase() const; 91 String to_uppercase() const;
110 void replace (int pos, int n, const String &a) { m_string.replace (pos, n, a.chars()); } 113 void replace (int pos, int n, const String &a) { m_string.replace (pos, n, a.chars()); }
111 void shrink_to_fit() { m_string.shrink_to_fit(); } 114 void shrink_to_fit() { m_string.shrink_to_fit(); }
112 void __cdecl sprintf (const char* fmtstr, ...); 115 void __cdecl sprintf (const char* fmtstr, ...);
113 void vsprintf (const char* fmtstr, va_list args); 116 void vsprintf (const char* fmtstr, va_list args);
114 bool starts_with (const String &other) const; 117 bool starts_with (const String &other) const;
115 String strip (char unwanted) { return strip ({unwanted}); }
116 String strip (const List<char> &unwanted);
117 void trim (int n); 118 void trim (int n);
118 119
119 static String from_number (short int a); 120 static String from_number (short int a);
120 static String from_number (int a); 121 static String from_number (int a);
121 static String from_number (long int a); 122 static String from_number (long int a);

mercurial