Cockatrice 2025-11-30-Development-2.11.0-beta.38
A cross-platform virtual tabletop for multiplayer card games
Loading...
Searching...
No Matches
trice_limits.h
Go to the documentation of this file.
1#ifndef TRICE_LIMITS_H
2#define TRICE_LIMITS_H
3
4#include <QString>
5
6// max size for short strings, like names and things that are generally a single phrase
7constexpr int MAX_NAME_LENGTH = 0xff;
8// max size for chat messages and text contents
9constexpr int MAX_TEXT_LENGTH = 0xfff;
10// max size for deck files and pictures
11constexpr int MAX_FILE_LENGTH = 0x1fffff; // about 2 megabytes
12
13constexpr uint MINIMUM_DIE_SIDES = 2;
14constexpr uint MAXIMUM_DIE_SIDES = 1000000;
15constexpr uint MINIMUM_DICE_TO_ROLL = 1;
16constexpr uint MAXIMUM_DICE_TO_ROLL = 100;
17
18// optimized functions to get qstrings that are at most that long
19static inline QString nameFromStdString(const std::string &_string)
20{
21 return QString::fromUtf8(_string.data(), std::min(int(_string.size()), MAX_NAME_LENGTH));
22}
23static inline QString textFromStdString(const std::string &_string)
24{
25 return QString::fromUtf8(_string.data(), std::min(int(_string.size()), MAX_TEXT_LENGTH));
26}
27static inline QString fileFromStdString(const std::string &_string)
28{
29 return QString::fromUtf8(_string.data(), std::min(int(_string.size()), MAX_FILE_LENGTH));
30}
31
32#endif // TRICE_LIMITS_H
constexpr uint MINIMUM_DIE_SIDES
Definition trice_limits.h:13
constexpr uint MAXIMUM_DICE_TO_ROLL
Definition trice_limits.h:16
constexpr int MAX_NAME_LENGTH
Definition trice_limits.h:7
constexpr uint MAXIMUM_DIE_SIDES
Definition trice_limits.h:14
constexpr uint MINIMUM_DICE_TO_ROLL
Definition trice_limits.h:15
static QString textFromStdString(const std::string &_string)
Definition trice_limits.h:23
static QString nameFromStdString(const std::string &_string)
Definition trice_limits.h:19
constexpr int MAX_TEXT_LENGTH
Definition trice_limits.h:9
constexpr int MAX_FILE_LENGTH
Definition trice_limits.h:11
static QString fileFromStdString(const std::string &_string)
Definition trice_limits.h:27