sources/mystring.cpp

changeset 145
d0aedc9be448
parent 137
485cb6d6b98c
child 147
12c93c4a137c
--- a/sources/mystring.cpp	Wed Jul 20 15:07:57 2016 +0300
+++ b/sources/mystring.cpp	Wed Jul 20 16:01:10 2016 +0300
@@ -39,7 +39,7 @@
 //
 int String::compare (const String& other) const
 {
-	return m_string.compare (other.std_string());
+	return m_string.compare (other.stdString());
 }
 
 // -------------------------------------------------------------------------------------------------
@@ -47,9 +47,9 @@
 void String::trim (int n)
 {
 	if (n > 0)
-		m_string = mid (0, length() - n).std_string();
+		m_string = mid (0, length() - n).stdString();
 	else
-		m_string = mid (n, -1).std_string();
+		m_string = mid (n, -1).stdString();
 }
 
 // -------------------------------------------------------------------------------------------------
@@ -59,7 +59,7 @@
 	String result (m_string);
 
 	for (int pos = 0; (pos = result.find (unwanted)) != -1;)
-		result.remove_at (pos--);
+		result.removeAt (pos--);
 
 	return result;
 }
@@ -72,14 +72,14 @@
 
 	for (String c : unwanted)
 	for (int pos = 0; (pos = result.find (c)) != -1;)
-		result.remove_at (pos--);
+		result.removeAt (pos--);
 
 	return result;
 }
 
 // -------------------------------------------------------------------------------------------------
 //
-String String::to_uppercase() const
+String String::toUpperCase() const
 {
 	String result (m_string);
 
@@ -94,7 +94,7 @@
 
 // -------------------------------------------------------------------------------------------------
 //
-String String::to_lowercase() const
+String String::toLowerCase() const
 {
 	String result (m_string);
 
@@ -197,21 +197,6 @@
 
 // -------------------------------------------------------------------------------------------------
 //
-int String::word_position (int n) const
-{
-	int count = 0;
-
-	for (char ch : *this)
-	{
-		if (not isspace(ch) or ++count < n)
-			continue;
-	}
-
-	return -1;
-}
-
-// -------------------------------------------------------------------------------------------------
-//
 int String::find (const char* c, int a) const
 {
 	int pos = m_string.find (c, a);
@@ -236,7 +221,7 @@
 
 // -------------------------------------------------------------------------------------------------
 //
-int String::find_last (const char* c, int a) const
+int String::findLast (const char* c, int a) const
 {
 	if (a == -1 or a >= length())
 		a = length() - 1;
@@ -250,7 +235,7 @@
 
 // -------------------------------------------------------------------------------------------------
 //
-long String::to_int (bool* ok, int base) const
+long String::toInt (bool* ok, int base) const
 {
 	errno = 0;
 	char* endptr;
@@ -264,7 +249,7 @@
 
 // -------------------------------------------------------------------------------------------------
 //
-float String::to_float (bool* ok) const
+float String::toFloat (bool* ok) const
 {
 	errno = 0;
 	char* endptr;
@@ -278,7 +263,7 @@
 
 // -------------------------------------------------------------------------------------------------
 //
-double String::to_double (bool* ok) const
+double String::toDouble (bool* ok) const
 {
 	errno = 0;
 	char* endptr;
@@ -310,7 +295,7 @@
 
 // -------------------------------------------------------------------------------------------------
 //
-bool String::is_numeric() const
+bool String::isNumeric() const
 {
 	char* endptr;
 	strtol (chars(), &endptr, 10);
@@ -319,7 +304,7 @@
 
 // -------------------------------------------------------------------------------------------------
 //
-bool String::ends_with (const String& other)
+bool String::endsWith (const String& other) const
 {
 	if (length() < other.length())
 		return false;
@@ -330,7 +315,7 @@
 
 // -------------------------------------------------------------------------------------------------
 //
-bool String::starts_with (const String& other) const
+bool String::startsWith (const String& other) const
 {
 	if (length() < other.length())
 		return false;
@@ -375,7 +360,7 @@
 
 	for (const String &item : container())
 	{
-		if (result.is_empty() == false)
+		if (result.isEmpty() == false)
 			result += delim;
 
 		result += item;
@@ -386,11 +371,11 @@
 
 // -------------------------------------------------------------------------------------------------
 //
-bool String::mask_against (const String& pattern) const
+bool String::maskAgainst (const String& pattern) const
 {
 	// Elevate to uppercase for case-insensitive matching
-	String pattern_upper = pattern.to_uppercase();
-	String this_upper = to_uppercase();
+	String pattern_upper = pattern.toUpperCase();
+	String this_upper = toUpperCase();
 	const char* maskstring = pattern_upper.chars();
 	const char* mptr = &maskstring[0];
 
@@ -434,7 +419,7 @@
 
 // -------------------------------------------------------------------------------------------------
 //
-String String::from_number (short int a)
+String String::fromNumber (short int a)
 {
 	char buf[32];
 	::sprintf (buf, "%d", a);
@@ -443,7 +428,7 @@
 
 // -------------------------------------------------------------------------------------------------
 //
-String String::from_number (int a)
+String String::fromNumber (int a)
 {
 	char buf[32];
 	::sprintf (buf, "%d", a);
@@ -452,7 +437,7 @@
 
 // -------------------------------------------------------------------------------------------------
 //
-String String::from_number (long int a)
+String String::fromNumber (long int a)
 {
 	char buf[32];
 	::sprintf (buf, "%ld", a);
@@ -461,7 +446,7 @@
 
 // -------------------------------------------------------------------------------------------------
 //
-String String::from_number (unsigned short int a)
+String String::fromNumber (unsigned short int a)
 {
 	char buf[32];
 	::sprintf (buf, "%u", a);
@@ -470,7 +455,7 @@
 
 // -------------------------------------------------------------------------------------------------
 //
-String String::from_number (unsigned int a)
+String String::fromNumber (unsigned int a)
 {
 	char buf[32];
 	::sprintf (buf, "%u", a);
@@ -479,7 +464,7 @@
 
 // -------------------------------------------------------------------------------------------------
 //
-String String::from_number (unsigned long int a)
+String String::fromNumber (unsigned long int a)
 {
 	char buf[32];
 	::sprintf (buf, "%lu", a);
@@ -488,7 +473,7 @@
 
 // -------------------------------------------------------------------------------------------------
 //
-String String::from_number (double a)
+String String::fromNumber (double a)
 {
 	char buf[64];
 	::sprintf (buf, "%f", a);

mercurial