mirror of
https://github.com/Cockatrice/Cockatrice.git
synced 2026-06-30 02:23:55 -07:00
Some checks are pending
Build Desktop / Configure (push) Waiting to run
Build Desktop / Debian 13 (push) Blocked by required conditions
Build Desktop / Debian 12 (push) Blocked by required conditions
Build Desktop / Fedora 44 (push) Blocked by required conditions
Build Desktop / Fedora 43 (push) Blocked by required conditions
Build Desktop / Servatrice_Debian 12 (push) Blocked by required conditions
Build Desktop / Ubuntu 26.04 (push) Blocked by required conditions
Build Desktop / Ubuntu 24.04 (push) Blocked by required conditions
Build Desktop / Arch (push) Blocked by required conditions
Build Desktop / macOS 14 (push) Blocked by required conditions
Build Desktop / macOS 15 (push) Blocked by required conditions
Build Desktop / macOS 13 Intel (push) Blocked by required conditions
Build Desktop / macOS 15 Debug (push) Blocked by required conditions
Build Desktop / Windows 10 (push) Blocked by required conditions
Build Docker Image / amd64 & arm64 (push) Waiting to run
* Split trice_limits.h into dedicated headers * Updated docstrings
31 lines
1.2 KiB
C++
31 lines
1.2 KiB
C++
#ifndef STRING_LIMITS_H
|
|
#define STRING_LIMITS_H
|
|
|
|
#include <QString>
|
|
#include <algorithm>
|
|
#include <string>
|
|
|
|
/** @brief Max size for short strings, like names and things that are generally a single phrase. */
|
|
constexpr int MAX_NAME_LENGTH = 0xff;
|
|
/** @brief Max size for chat messages and text contents. */
|
|
constexpr int MAX_TEXT_LENGTH = 0xfff;
|
|
/** @brief Max size for deck files and pictures (about 2 megabytes). */
|
|
constexpr int MAX_FILE_LENGTH = 0x1fffff;
|
|
|
|
/** @brief Returns a QString from a std::string, truncated to at most MAX_NAME_LENGTH bytes. */
|
|
inline QString nameFromStdString(const std::string &_string)
|
|
{
|
|
return QString::fromUtf8(_string.data(), std::min(int(_string.size()), MAX_NAME_LENGTH));
|
|
}
|
|
/** @brief Returns a QString from a std::string, truncated to at most MAX_TEXT_LENGTH bytes. */
|
|
inline QString textFromStdString(const std::string &_string)
|
|
{
|
|
return QString::fromUtf8(_string.data(), std::min(int(_string.size()), MAX_TEXT_LENGTH));
|
|
}
|
|
/** @brief Returns a QString from a std::string, truncated to at most MAX_FILE_LENGTH bytes. */
|
|
inline QString fileFromStdString(const std::string &_string)
|
|
{
|
|
return QString::fromUtf8(_string.data(), std::min(int(_string.size()), MAX_FILE_LENGTH));
|
|
}
|
|
|
|
#endif // STRING_LIMITS_H
|