add microhttpd server

This commit is contained in:
2024-11-14 18:15:27 +03:00
parent ee34e8a72e
commit cdde340efe
12 changed files with 599 additions and 221 deletions

View File

@@ -129,6 +129,20 @@ struct base64HelpStruct {
// clang-format on
bool PIByteArray::startsWith(const PIByteArray & o) const {
if (o.isEmpty()) return false;
if (size() < o.size()) return false;
return piCompareBinary(data(), o.data(), o.size());
}
bool PIByteArray::endsWith(const PIByteArray & o) const {
if (o.isEmpty()) return false;
if (size() < o.size()) return false;
return piCompareBinary(data(size() - o.size()), o.data(), o.size());
}
PIByteArray & PIByteArray::convertToBase64() {
return *this = toBase64();
}
@@ -396,6 +410,17 @@ PIByteArray PIByteArray::fromHex(PIString str) {
}
PIByteArray PIByteArray::fromAscii(const char * str) {
PIByteArray ret;
int ind = 0;
while (str[ind] != 0) {
ret.append(str[ind]);
++ind;
}
return ret;
}
PICout operator<<(PICout s, const PIByteArray & ba) {
s.space();
s.saveAndSetControls(0);

View File

@@ -340,6 +340,10 @@ public:
//! \~\sa \a every(), \a any(), \a contains(), \a indexWhere()
inline int entries(std::function<bool(uchar e)> test, ssize_t start = 0) const { return d.entries(test, start); }
bool startsWith(const PIByteArray & o) const;
bool endsWith(const PIByteArray & o) const;
//! \~english Returns the first index at which a given element `e`
//! can be found in the array, or `-1` if it is not present.
//! \~russian Возвращает первый индекс, по которому данный элемент `e`
@@ -1165,6 +1169,8 @@ public:
static PIByteArray fromHex(PIString str);
static PIByteArray fromAscii(const char * str);
//! \~english Return converted from Base 64 data
//! \~russian Возвращает массив из Base 64 представления
static PIByteArray fromBase64(const PIByteArray & base64);