refactor: Replace deskflow::string::stringToSizeType with QString::size()

This commit is contained in:
sithlord48 2025-12-02 17:46:51 -05:00 committed by Nick Bolton
parent f012cf2e4b
commit 53441821e0
5 changed files with 1 additions and 26 deletions

View file

@ -12,7 +12,6 @@
#include <cstdarg> #include <cstdarg>
#include <cstdint> #include <cstdint>
#include <cstring> #include <cstring>
#include <sstream>
#include <vector> #include <vector>
namespace deskflow::string { namespace deskflow::string {
@ -140,14 +139,6 @@ std::string sprintf(const char *fmt, ...)
return result; return result;
} }
size_t stringToSizeType(const std::string &string)
{
std::istringstream iss(string);
size_t value;
iss >> value;
return value;
}
// //
// CaselessCmp // CaselessCmp
// //

View file

@ -40,12 +40,6 @@ Equivalent to sprintf() except the result is returned as a String.
*/ */
std::string sprintf(const char *fmt, ...); std::string sprintf(const char *fmt, ...);
//! Convert a string to a size type
/*!
Convert an a \c string to an size type
*/
size_t stringToSizeType(const std::string &string);
//! Case-insensitive comparisons //! Case-insensitive comparisons
/*! /*!
This class provides case-insensitve comparison functions. This class provides case-insensitve comparison functions.

View file

@ -74,7 +74,7 @@ ClipboardChunk::assemble(deskflow::IStream *stream, std::string &dataCached, Cli
} }
if (mark == ChunkType::DataStart) { if (mark == ChunkType::DataStart) {
s_expectedSize = deskflow::string::stringToSizeType(data); s_expectedSize = QString::fromStdString(data).size();
LOG_DEBUG("start receiving clipboard data"); LOG_DEBUG("start receiving clipboard data");
dataCached.clear(); dataCached.clear();
return Started; return Started;

View file

@ -9,8 +9,6 @@
#include "base/String.h" #include "base/String.h"
#include <string.h>
void StringTests::formatWithArgs() void StringTests::formatWithArgs()
{ {
const char *format = "%%%{1}=%{2}"; const char *format = "%%%{1}=%{2}";
@ -33,11 +31,4 @@ void StringTests::formatedString()
QCOMPARE("answer=42", result); QCOMPARE("answer=42", result);
} }
void StringTests::stringToInt()
{
std::string number = "123";
size_t value = deskflow::string::stringToSizeType(number);
QCOMPARE(value, 123);
}
QTEST_MAIN(StringTests) QTEST_MAIN(StringTests)

View file

@ -12,5 +12,4 @@ class StringTests : public QObject
private Q_SLOTS: private Q_SLOTS:
void formatWithArgs(); void formatWithArgs();
void formatedString(); void formatedString();
void stringToInt();
}; };