remove superfluous c_str() v_0
authorFrantišek Kučera <franta-hg@frantovo.cz>
Sat, 23 Apr 2022 18:49:25 +0200
branchv_0
changeset 58 a4907b207f0c
parent 57 723621f9b14a
child 59 a1775ba6d056
remove superfluous c_str()
src/ResultSet.cpp
src/SqlHandler.h
--- a/src/ResultSet.cpp	Sat Dec 04 21:14:54 2021 +0100
+++ b/src/ResultSet.cpp	Sat Apr 23 18:49:25 2022 +0200
@@ -67,9 +67,9 @@
 		return L"";
 	} else if (stringLength >= 0) {
 		std::string value;
-		value.reserve(stringLength);
+		value.resize(stringLength);
 		result = SQLGetData(statement, columnNumber, SQL_C_CHAR, (SQLCHAR*) value.c_str(), value.capacity() + 1, &stringLength); // trailing null byte = + 1
-		if (OdbcCommon::isSuccessful(result)) return convertor.from_bytes(value.c_str());
+		if (OdbcCommon::isSuccessful(result)) return convertor.from_bytes(value);
 	}
 	throw SqlException(L"Unable to get string value", result, SQL_HANDLE_STMT, statement);
 }
@@ -128,8 +128,8 @@
 	}
 
 	std::wstringstream errorMessage;
-	errorMessage << L"Unable to find column with name „" << columnName.c_str() << L"“ Availalable columns are: ";
-	for (MetaData::ColumnDescriptor cd : columnDescriptors) errorMessage << L"„" << cd.name.c_str() << L"“ ";
+	errorMessage << L"Unable to find column with name „" << columnName << L"“ Availalable columns are: ";
+	for (MetaData::ColumnDescriptor cd : columnDescriptors) errorMessage << L"„" << cd.name << L"“ ";
 	throw SqlException(errorMessage.str());
 }
 
--- a/src/SqlHandler.h	Sat Dec 04 21:14:54 2021 +0100
+++ b/src/SqlHandler.h	Sat Apr 23 18:49:25 2022 +0200
@@ -70,7 +70,7 @@
 
 		for (wchar_t ch; *input >> ch;) {
 			if (scanner.append(ch)) {
-				*sql << scanner.getAndReset().c_str();
+				*sql << scanner.getAndReset();
 				return true;
 			}
 		}