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

View File

@ -40,12 +40,6 @@ Equivalent to sprintf() except the result is returned as a String.
*/
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
/*!
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) {
s_expectedSize = deskflow::string::stringToSizeType(data);
s_expectedSize = QString::fromStdString(data).size();
LOG_DEBUG("start receiving clipboard data");
dataCached.clear();
return Started;

View File

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

View File

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