style: run clang-format over all files
This commit is contained in:
@@ -1,63 +1,69 @@
|
|||||||
#include "pip.h"
|
#include "pip.h"
|
||||||
|
|
||||||
void _() {
|
void _() {
|
||||||
//! [0]
|
//! [0]
|
||||||
PIByteArray ba;
|
PIByteArray ba;
|
||||||
int i = -1, j = 2;
|
int i = -1, j = 2;
|
||||||
float f = 1.;
|
float f = 1.;
|
||||||
PIString text("123");
|
PIString text("123");
|
||||||
ba << i << j << f << text; // form binary data
|
ba << i << j << f << text; // form binary data
|
||||||
piCout << "data =" << ba;
|
piCout << "data =" << ba;
|
||||||
i = j = 0; // clear variables
|
i = j = 0; // clear variables
|
||||||
f = 0; // clear variables
|
f = 0; // clear variables
|
||||||
text.clear(); // clear variables
|
text.clear(); // clear variables
|
||||||
piCout << i << j << f << text; // show variables
|
piCout << i << j << f << text; // show variables
|
||||||
ba >> i >> j >> f >> text; // restore data
|
ba >> i >> j >> f >> text; // restore data
|
||||||
piCout << i << j << f << text; // show variables
|
piCout << i << j << f << text; // show variables
|
||||||
piCout << "data =" << ba;
|
piCout << "data =" << ba;
|
||||||
//! [0]
|
//! [0]
|
||||||
//! [1]
|
//! [1]
|
||||||
struct MyType {
|
struct MyType {
|
||||||
MyType(int i_ = 0, const PIString & t_ = PIString()) {
|
MyType(int i_ = 0, const PIString & t_ = PIString()) {
|
||||||
m_i = i_;
|
m_i = i_;
|
||||||
m_text = t_;
|
m_text = t_;
|
||||||
|
}
|
||||||
|
int m_i;
|
||||||
|
PIString m_text;
|
||||||
|
};
|
||||||
|
|
||||||
|
inline PIByteArray & operator<<(PIByteArray & s, const MyType & v) {
|
||||||
|
s << v.m_i << v.m_text;
|
||||||
|
return s;
|
||||||
|
}
|
||||||
|
inline PIByteArray & operator>>(PIByteArray & s, MyType & v) {
|
||||||
|
s >> v.m_i >> v.m_text;
|
||||||
|
return s;
|
||||||
}
|
}
|
||||||
int m_i;
|
|
||||||
PIString m_text;
|
|
||||||
};
|
|
||||||
|
|
||||||
inline PIByteArray & operator <<(PIByteArray & s, const MyType & v) {s << v.m_i << v.m_text; return s;}
|
PIByteArray ba;
|
||||||
inline PIByteArray & operator >>(PIByteArray & s, MyType & v) {s >> v.m_i >> v.m_text; return s;}
|
PIVector<MyType> my_vec;
|
||||||
|
my_vec << MyType(1, "s1") << MyType(10, "s10"); // add to vector
|
||||||
PIByteArray ba;
|
ba << my_vec; // store to byte array
|
||||||
PIVector<MyType> my_vec;
|
piCout << "data =" << ba;
|
||||||
my_vec << MyType(1, "s1") << MyType(10, "s10"); // add to vector
|
my_vec.clear(); // clear vector
|
||||||
ba << my_vec; // store to byte array
|
ba >> my_vec; // restore from byte array
|
||||||
piCout << "data =" << ba;
|
//! [1]
|
||||||
my_vec.clear(); // clear vector
|
//! [2]
|
||||||
ba >> my_vec; // restore from byte array
|
PIByteArray ba;
|
||||||
//! [1]
|
const char * chars = "8 bytes";
|
||||||
//! [2]
|
ba << PIByteArray::RawData(chars, 8); // form binary data
|
||||||
PIByteArray ba;
|
piCout << "data =" << ba;
|
||||||
const char * chars = "8 bytes";
|
char rchars[16];
|
||||||
ba << PIByteArray::RawData(chars, 8); // form binary data
|
memset(rchars, 0, 16); // clear data
|
||||||
piCout << "data =" << ba;
|
ba >> PIByteArray::RawData(rchars, 8); // restore data
|
||||||
char rchars[16];
|
piCout << rchars;
|
||||||
memset(rchars, 0, 16); // clear data
|
piCout << "data =" << ba;
|
||||||
ba >> PIByteArray::RawData(rchars, 8); // restore data
|
//! [2]
|
||||||
piCout << rchars;
|
//! [3]
|
||||||
piCout << "data =" << ba;
|
PIByteArray ba, sba;
|
||||||
//! [2]
|
uchar uc(127);
|
||||||
//! [3]
|
sba << uc; // byte array with one byte
|
||||||
PIByteArray ba, sba;
|
ba << sba; // stream operator
|
||||||
uchar uc(127);
|
piCout << ba; // result
|
||||||
sba << uc; // byte array with one byte
|
// {1, 0, 0, 0, 127}
|
||||||
ba << sba; // stream operator
|
ba.clear();
|
||||||
piCout << ba; // result
|
ba.append(sba);
|
||||||
// {1, 0, 0, 0, 127}
|
piCout << ba; // result
|
||||||
ba.clear();
|
// {127}
|
||||||
ba.append(sba);
|
//! [3]
|
||||||
piCout << ba; // result
|
|
||||||
// {127}
|
|
||||||
//! [3]
|
|
||||||
};
|
};
|
||||||
|
|||||||
@@ -3,5 +3,4 @@
|
|||||||
//! [main]
|
//! [main]
|
||||||
//! [main]
|
//! [main]
|
||||||
|
|
||||||
void _() {
|
void _() {};
|
||||||
};
|
|
||||||
|
|||||||
@@ -26,23 +26,23 @@ class ElementD: public PIObject {
|
|||||||
int main() {
|
int main() {
|
||||||
ElementD * el_d = new ElementD();
|
ElementD * el_d = new ElementD();
|
||||||
ADD_TO_COLLECTION(ab_group, el_d)
|
ADD_TO_COLLECTION(ab_group, el_d)
|
||||||
|
|
||||||
PIStringList gl = PICollection::groups();
|
PIStringList gl = PICollection::groups();
|
||||||
piCout << gl; // {"ab_group", "c_group"}
|
piCout << gl; // {"ab_group", "c_group"}
|
||||||
piForeachC (PIString g, gl) {
|
piForeachC(PIString g, gl) {
|
||||||
PIVector<const PIObject * > go = PICollection::groupElements(g);
|
PIVector<const PIObject *> go = PICollection::groupElements(g);
|
||||||
piCout << "group" << g << ":";
|
piCout << "group" << g << ":";
|
||||||
piForeachC (PIObject * o, go)
|
piForeachC(PIObject * o, go)
|
||||||
piCout << Tab << o->className();
|
piCout << Tab << o->className();
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
group ab_group :
|
group ab_group :
|
||||||
ElementA
|
ElementA
|
||||||
ElementB
|
ElementB
|
||||||
ElementD
|
ElementD
|
||||||
group c_group :
|
group c_group :
|
||||||
ElementC
|
ElementC
|
||||||
*/
|
*/
|
||||||
};
|
};
|
||||||
//! [main]
|
//! [main]
|
||||||
|
|||||||
+21
-23
@@ -1,27 +1,25 @@
|
|||||||
#include "pip.h"
|
#include "pip.h"
|
||||||
|
|
||||||
|
|
||||||
void _() {
|
void _() {
|
||||||
|
//! [PIConfig::Entry]
|
||||||
//! [PIConfig::Entry]
|
/* "example.conf"
|
||||||
/* "example.conf"
|
a = 1
|
||||||
a = 1
|
s0.a = A
|
||||||
s0.a = A
|
s0.b = B
|
||||||
s0.b = B
|
*/
|
||||||
*/
|
PIConfig conf("example.conf", PIIODevice::ReadOnly);
|
||||||
PIConfig conf("example.conf", PIIODevice::ReadOnly);
|
PIConfig::Entry ce = conf.getValue("a");
|
||||||
PIConfig::Entry ce = conf.getValue("a");
|
int a = ce; // a = 1
|
||||||
int a = ce; // a = 1
|
PIString A = ce; // A = "1"
|
||||||
PIString A = ce; // A = "1"
|
ce = conf.getValue("s0");
|
||||||
ce = conf.getValue("s0");
|
piCout << ce.childCount(); // 2
|
||||||
piCout << ce.childCount(); // 2
|
A = ce.getValue("b"); // A = "B"
|
||||||
A = ce.getValue("b"); // A = "B"
|
A = conf.getValue("s0.a"); // A = "A"
|
||||||
A = conf.getValue("s0.a"); // A = "A"
|
//! [PIConfig::Entry]
|
||||||
//! [PIConfig::Entry]
|
//! [fullName]
|
||||||
//! [fullName]
|
PIConfig conf("example.conf", PIIODevice::ReadOnly);
|
||||||
PIConfig conf("example.conf", PIIODevice::ReadOnly);
|
piCout << conf.getValue("a.b.c").name(); // "c"
|
||||||
piCout << conf.getValue("a.b.c").name(); // "c"
|
piCout << conf.getValue("a.b.c").fullName(); // "a.b.c"
|
||||||
piCout << conf.getValue("a.b.c").fullName(); // "a.b.c"
|
//! [fullName]
|
||||||
//! [fullName]
|
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|||||||
+207
-206
@@ -1,213 +1,214 @@
|
|||||||
#include "pip.h"
|
#include "pip.h"
|
||||||
void _() {
|
void _() {
|
||||||
|
//! [foreach]
|
||||||
//! [foreach]
|
PIVector<int> vec;
|
||||||
PIVector<int> vec;
|
vec << 1 << 2 << 3;
|
||||||
vec << 1 << 2 << 3;
|
|
||||||
|
|
||||||
piForeach (int & i, vec) piCout << i;
|
piForeach(int & i, vec)
|
||||||
// 1
|
piCout << i;
|
||||||
// 2
|
// 1
|
||||||
// 3
|
// 2
|
||||||
|
// 3
|
||||||
|
|
||||||
piForeach (int & i, vec) i++;
|
piForeach(int & i, vec)
|
||||||
piForeach (int & i, vec) piCout << i;
|
i++;
|
||||||
// 2
|
piForeach(int & i, vec)
|
||||||
// 3
|
piCout << i;
|
||||||
// 4
|
// 2
|
||||||
//! [foreach]
|
// 3
|
||||||
//! [foreachC]
|
// 4
|
||||||
PIVector<int> vec;
|
//! [foreach]
|
||||||
vec << 1 << 2 << 3;
|
//! [foreachC]
|
||||||
piForeachC (int & i, vec)
|
PIVector<int> vec;
|
||||||
cout << i << ", ";
|
vec << 1 << 2 << 3;
|
||||||
// 1, 2, 3,
|
piForeachC(int & i, vec)
|
||||||
piForeachC (int & i, vec)
|
cout << i << ", ";
|
||||||
i++; // ERROR! const iterator
|
// 1, 2, 3,
|
||||||
//! [foreachC]
|
piForeachC(int & i, vec)
|
||||||
//! [foreachR]
|
i++; // ERROR! const iterator
|
||||||
PIVector<int> vec;
|
//! [foreachC]
|
||||||
vec << 1 << 2 << 3;
|
//! [foreachR]
|
||||||
piForeachR (int & i, vec)
|
PIVector<int> vec;
|
||||||
cout << i << ", ";
|
vec << 1 << 2 << 3;
|
||||||
// 3, 2, 1,
|
piForeachR(int & i, vec)
|
||||||
piForeachR (int & i, vec)
|
cout << i << ", ";
|
||||||
i++;
|
// 3, 2, 1,
|
||||||
piForeachR (int & i, vec)
|
piForeachR(int & i, vec)
|
||||||
cout << i << ", ";
|
i++;
|
||||||
// 4, 3, 2,
|
piForeachR(int & i, vec)
|
||||||
//! [foreachR]
|
cout << i << ", ";
|
||||||
//! [foreachCR]
|
// 4, 3, 2,
|
||||||
PIVector<int> vec;
|
//! [foreachR]
|
||||||
vec << 1 << 2 << 3;
|
//! [foreachCR]
|
||||||
piForeachCR (int & i, vec)
|
PIVector<int> vec;
|
||||||
cout << i << ", ";
|
vec << 1 << 2 << 3;
|
||||||
// 3, 2, 1,
|
piForeachCR(int & i, vec)
|
||||||
piForeachCR (int & i, vec)
|
cout << i << ", ";
|
||||||
i++; // ERROR! const iterator
|
// 3, 2, 1,
|
||||||
//! [foreachCR]
|
piForeachCR(int & i, vec)
|
||||||
|
i++; // ERROR! const iterator
|
||||||
|
//! [foreachCR]
|
||||||
|
|
||||||
//! [PIVector::PIVector]
|
//! [PIVector::PIVector]
|
||||||
PIVector<char> vec(4u, 'p');
|
PIVector<char> vec(4u, 'p');
|
||||||
piForeachC (char i, vec)
|
piForeachC(char i, vec)
|
||||||
cout << i << ", ";
|
cout << i << ", ";
|
||||||
// p, p, p, p,
|
// p, p, p, p,
|
||||||
|
|
||||||
piCout << PIVector<int>({1, 2, 3});
|
|
||||||
// 1, 2, 3
|
|
||||||
//! [PIVector::PIVector]
|
|
||||||
//! [PIVector::at_c]
|
|
||||||
PIVector<int> vec;
|
|
||||||
vec << 1 << 3 << 5;
|
|
||||||
for (int i = 0; i < vec.size_s(); ++i)
|
|
||||||
cout << vec.at(i) << ", ";
|
|
||||||
// 1, 3, 5,
|
|
||||||
//! [PIVector::at_c]
|
|
||||||
//! [PIVector::at]
|
|
||||||
PIVector<int> vec;
|
|
||||||
vec << 1 << 3 << 5;
|
|
||||||
for (int i = 0; i < vec.size_s(); ++i)
|
|
||||||
vec.at(i) += 1;
|
|
||||||
for (int i = 0; i < vec.size_s(); ++i)
|
|
||||||
cout << vec.at(i) << ", ";
|
|
||||||
// 2, 4, 6,
|
|
||||||
//! [PIVector::at]
|
|
||||||
//! [PIVector::()_c]
|
|
||||||
PIVector<int> vec;
|
|
||||||
vec << 1 << 3 << 5;
|
|
||||||
for (int i = 0; i < vec.size_s(); ++i)
|
|
||||||
cout << vec[i] << ", ";
|
|
||||||
// 1, 3, 5,
|
|
||||||
//! [PIVector::()_c]
|
|
||||||
//! [PIVector::()]
|
|
||||||
PIVector<int> vec;
|
|
||||||
vec << 1 << 3 << 5;
|
|
||||||
for (int i = 0; i < vec.size_s(); ++i)
|
|
||||||
vec[i] += 1;
|
|
||||||
for (int i = 0; i < vec.size_s(); ++i)
|
|
||||||
cout << vec[i] << ", ";
|
|
||||||
// 2, 4, 6,
|
|
||||||
//! [PIVector::()]
|
|
||||||
//! [PIVector::data_c]
|
|
||||||
PIVector<int> vec;
|
|
||||||
vec << 1 << 3 << 5;
|
|
||||||
int carr[3];
|
|
||||||
// copy data from "vec" to "carr"
|
|
||||||
memcpy(carr, vec.data(), vec.size() * sizeof(int));
|
|
||||||
for (int i = 0; i < vec.size_s(); ++i)
|
|
||||||
cout << carr[i] << ", ";
|
|
||||||
// 1, 3, 5,
|
|
||||||
//! [PIVector::data_c]
|
|
||||||
//! [PIVector::data]
|
|
||||||
PIVector<int> vec;
|
|
||||||
vec << 1 << 3 << 5;
|
|
||||||
int carr[2] = {12, 13};
|
|
||||||
// copy data from "carr" to "vec" with offset
|
|
||||||
memcpy(vec.data(1), carr, 2 * sizeof(int));
|
|
||||||
for (int i = 0; i < vec.size_s(); ++i)
|
|
||||||
cout << vec[i] << ", ";
|
|
||||||
// 1, 12, 13,
|
|
||||||
//! [PIVector::data]
|
|
||||||
//! [PIVector::resize]
|
|
||||||
PIVector<int> vec;
|
|
||||||
vec << 1 << 2;
|
|
||||||
vec.resize(4);
|
|
||||||
piForeachC (int & i, vec)
|
|
||||||
cout << i << ", ";
|
|
||||||
// 1, 2, 0, 0,
|
|
||||||
vec.resize(3);
|
|
||||||
piForeachC (int & i, vec)
|
|
||||||
cout << i << ", ";
|
|
||||||
// 1, 2, 0,
|
|
||||||
//! [PIVector::resize]
|
|
||||||
//! [PIVector::sort_0]
|
|
||||||
PIVector<int> vec;
|
|
||||||
vec << 3 << 2 << 5 << 1 << 4;
|
|
||||||
vec.sort();
|
|
||||||
piForeachC (int & i, vec)
|
|
||||||
cout << i << ", ";
|
|
||||||
// 1, 2, 3, 4, 5,
|
|
||||||
//! [PIVector::sort_0]
|
|
||||||
//! [PIVector::sort_1]
|
|
||||||
static int mycomp(const int * v0, const int * v1) {
|
|
||||||
if (*v0 == *v1) return 0;
|
|
||||||
return *v0 < *v1 ? 1 : -1;
|
|
||||||
}
|
|
||||||
PIVector<int> vec;
|
|
||||||
vec << 3 << 2 << 5 << 1 << 4;
|
|
||||||
vec.sort(mycomp);
|
|
||||||
piForeachC (int & i, vec)
|
|
||||||
cout << i << ", ";
|
|
||||||
// 5, 4, 3, 2, 1,
|
|
||||||
//! [PIVector::sort_1]
|
|
||||||
//! [PIVector::fill]
|
|
||||||
PIVector<char> vec;
|
|
||||||
vec << '1' << '2' << '3' << '4' << '5';
|
|
||||||
vec.fill('0');
|
|
||||||
piForeachC (char i, vec)
|
|
||||||
cout << i << ", ";
|
|
||||||
// 0, 0, 0, 0, 0,
|
|
||||||
//! [PIVector::fill]
|
|
||||||
//! [PIVector::remove_0]
|
|
||||||
PIVector<char> vec;
|
|
||||||
vec << '1' << '2' << '3' << '4' << '5';
|
|
||||||
vec.remove(1);
|
|
||||||
piForeachC (char i, vec)
|
|
||||||
cout << i << ", ";
|
|
||||||
// 1, 3, 4, 5,
|
|
||||||
//! [PIVector::remove_0]
|
|
||||||
//! [PIVector::remove_1]
|
|
||||||
PIVector<char> vec;
|
|
||||||
vec << '1' << '2' << '3' << '4' << '5';
|
|
||||||
vec.remove(2, 2);
|
|
||||||
piForeachC (char i, vec)
|
|
||||||
cout << i << ", ";
|
|
||||||
// 1, 2, 5,
|
|
||||||
//! [PIVector::remove_1]
|
|
||||||
//! [PIVector::removeOne]
|
|
||||||
PIVector<char> vec;
|
|
||||||
vec << '1' << '2' << '3' << '2' << '1';
|
|
||||||
vec.removeOne('2');
|
|
||||||
piForeachC (char i, vec)
|
|
||||||
cout << i << ", ";
|
|
||||||
// 1, 3, 2, 1,
|
|
||||||
//! [PIVector::removeOne]
|
|
||||||
//! [PIVector::removeAll]
|
|
||||||
PIVector<char> vec;
|
|
||||||
vec << '1' << '2' << '3' << '2' << '1';
|
|
||||||
vec.removeAll('2');
|
|
||||||
piForeachC (char i, vec)
|
|
||||||
cout << i << ", ";
|
|
||||||
// 1, 3, 1,
|
|
||||||
//! [PIVector::removeAll]
|
|
||||||
//! [PIVector::insert_0]
|
|
||||||
PIVector<char> vec;
|
|
||||||
vec << '1' << '3' << '4';
|
|
||||||
vec.insert(1, '2');
|
|
||||||
piForeachC (char i, vec)
|
|
||||||
cout << i << ", ";
|
|
||||||
// 1, 2, 3, 4,
|
|
||||||
//! [PIVector::insert_0]
|
|
||||||
//! [PIVector::insert_1]
|
|
||||||
PIVector<char> vec, vec2;
|
|
||||||
vec << '1' << '4' << '5';
|
|
||||||
vec2 << '2' << '3';
|
|
||||||
vec.insert(1, vec2);
|
|
||||||
piForeachC (char i, vec)
|
|
||||||
cout << i << ", ";
|
|
||||||
// 1, 2, 3, 4, 5,
|
|
||||||
//! [PIVector::insert_1]
|
|
||||||
//! [PIVector::ostream<<]
|
|
||||||
PIVector<char> vec;
|
|
||||||
vec << '1' << '2' << '3' << '4' << '5';
|
|
||||||
cout << vec << endl;
|
|
||||||
// {1, 2, 3, 4, 5}
|
|
||||||
//! [PIVector::ostream<<]
|
|
||||||
//! [PIVector::PICout<<]
|
|
||||||
PIVector<char> vec;
|
|
||||||
vec << '1' << '2' << '3' << '4' << '5';
|
|
||||||
piCout << vec;
|
|
||||||
// {1, 2, 3, 4, 5}
|
|
||||||
//! [PIVector::PICout<<]
|
|
||||||
|
|
||||||
|
piCout << PIVector<int>({1, 2, 3});
|
||||||
|
// 1, 2, 3
|
||||||
|
//! [PIVector::PIVector]
|
||||||
|
//! [PIVector::at_c]
|
||||||
|
PIVector<int> vec;
|
||||||
|
vec << 1 << 3 << 5;
|
||||||
|
for (int i = 0; i < vec.size_s(); ++i)
|
||||||
|
cout << vec.at(i) << ", ";
|
||||||
|
// 1, 3, 5,
|
||||||
|
//! [PIVector::at_c]
|
||||||
|
//! [PIVector::at]
|
||||||
|
PIVector<int> vec;
|
||||||
|
vec << 1 << 3 << 5;
|
||||||
|
for (int i = 0; i < vec.size_s(); ++i)
|
||||||
|
vec.at(i) += 1;
|
||||||
|
for (int i = 0; i < vec.size_s(); ++i)
|
||||||
|
cout << vec.at(i) << ", ";
|
||||||
|
// 2, 4, 6,
|
||||||
|
//! [PIVector::at]
|
||||||
|
//! [PIVector::()_c]
|
||||||
|
PIVector<int> vec;
|
||||||
|
vec << 1 << 3 << 5;
|
||||||
|
for (int i = 0; i < vec.size_s(); ++i)
|
||||||
|
cout << vec[i] << ", ";
|
||||||
|
// 1, 3, 5,
|
||||||
|
//! [PIVector::()_c]
|
||||||
|
//! [PIVector::()]
|
||||||
|
PIVector<int> vec;
|
||||||
|
vec << 1 << 3 << 5;
|
||||||
|
for (int i = 0; i < vec.size_s(); ++i)
|
||||||
|
vec[i] += 1;
|
||||||
|
for (int i = 0; i < vec.size_s(); ++i)
|
||||||
|
cout << vec[i] << ", ";
|
||||||
|
// 2, 4, 6,
|
||||||
|
//! [PIVector::()]
|
||||||
|
//! [PIVector::data_c]
|
||||||
|
PIVector<int> vec;
|
||||||
|
vec << 1 << 3 << 5;
|
||||||
|
int carr[3];
|
||||||
|
// copy data from "vec" to "carr"
|
||||||
|
memcpy(carr, vec.data(), vec.size() * sizeof(int));
|
||||||
|
for (int i = 0; i < vec.size_s(); ++i)
|
||||||
|
cout << carr[i] << ", ";
|
||||||
|
// 1, 3, 5,
|
||||||
|
//! [PIVector::data_c]
|
||||||
|
//! [PIVector::data]
|
||||||
|
PIVector<int> vec;
|
||||||
|
vec << 1 << 3 << 5;
|
||||||
|
int carr[2] = {12, 13};
|
||||||
|
// copy data from "carr" to "vec" with offset
|
||||||
|
memcpy(vec.data(1), carr, 2 * sizeof(int));
|
||||||
|
for (int i = 0; i < vec.size_s(); ++i)
|
||||||
|
cout << vec[i] << ", ";
|
||||||
|
// 1, 12, 13,
|
||||||
|
//! [PIVector::data]
|
||||||
|
//! [PIVector::resize]
|
||||||
|
PIVector<int> vec;
|
||||||
|
vec << 1 << 2;
|
||||||
|
vec.resize(4);
|
||||||
|
piForeachC(int & i, vec)
|
||||||
|
cout << i << ", ";
|
||||||
|
// 1, 2, 0, 0,
|
||||||
|
vec.resize(3);
|
||||||
|
piForeachC(int & i, vec)
|
||||||
|
cout << i << ", ";
|
||||||
|
// 1, 2, 0,
|
||||||
|
//! [PIVector::resize]
|
||||||
|
//! [PIVector::sort_0]
|
||||||
|
PIVector<int> vec;
|
||||||
|
vec << 3 << 2 << 5 << 1 << 4;
|
||||||
|
vec.sort();
|
||||||
|
piForeachC(int & i, vec)
|
||||||
|
cout << i << ", ";
|
||||||
|
// 1, 2, 3, 4, 5,
|
||||||
|
//! [PIVector::sort_0]
|
||||||
|
//! [PIVector::sort_1]
|
||||||
|
static int mycomp(const int * v0, const int * v1) {
|
||||||
|
if (*v0 == *v1) return 0;
|
||||||
|
return *v0 < *v1 ? 1 : -1;
|
||||||
|
}
|
||||||
|
PIVector<int> vec;
|
||||||
|
vec << 3 << 2 << 5 << 1 << 4;
|
||||||
|
vec.sort(mycomp);
|
||||||
|
piForeachC(int & i, vec)
|
||||||
|
cout << i << ", ";
|
||||||
|
// 5, 4, 3, 2, 1,
|
||||||
|
//! [PIVector::sort_1]
|
||||||
|
//! [PIVector::fill]
|
||||||
|
PIVector<char> vec;
|
||||||
|
vec << '1' << '2' << '3' << '4' << '5';
|
||||||
|
vec.fill('0');
|
||||||
|
piForeachC(char i, vec)
|
||||||
|
cout << i << ", ";
|
||||||
|
// 0, 0, 0, 0, 0,
|
||||||
|
//! [PIVector::fill]
|
||||||
|
//! [PIVector::remove_0]
|
||||||
|
PIVector<char> vec;
|
||||||
|
vec << '1' << '2' << '3' << '4' << '5';
|
||||||
|
vec.remove(1);
|
||||||
|
piForeachC(char i, vec)
|
||||||
|
cout << i << ", ";
|
||||||
|
// 1, 3, 4, 5,
|
||||||
|
//! [PIVector::remove_0]
|
||||||
|
//! [PIVector::remove_1]
|
||||||
|
PIVector<char> vec;
|
||||||
|
vec << '1' << '2' << '3' << '4' << '5';
|
||||||
|
vec.remove(2, 2);
|
||||||
|
piForeachC(char i, vec)
|
||||||
|
cout << i << ", ";
|
||||||
|
// 1, 2, 5,
|
||||||
|
//! [PIVector::remove_1]
|
||||||
|
//! [PIVector::removeOne]
|
||||||
|
PIVector<char> vec;
|
||||||
|
vec << '1' << '2' << '3' << '2' << '1';
|
||||||
|
vec.removeOne('2');
|
||||||
|
piForeachC(char i, vec)
|
||||||
|
cout << i << ", ";
|
||||||
|
// 1, 3, 2, 1,
|
||||||
|
//! [PIVector::removeOne]
|
||||||
|
//! [PIVector::removeAll]
|
||||||
|
PIVector<char> vec;
|
||||||
|
vec << '1' << '2' << '3' << '2' << '1';
|
||||||
|
vec.removeAll('2');
|
||||||
|
piForeachC(char i, vec)
|
||||||
|
cout << i << ", ";
|
||||||
|
// 1, 3, 1,
|
||||||
|
//! [PIVector::removeAll]
|
||||||
|
//! [PIVector::insert_0]
|
||||||
|
PIVector<char> vec;
|
||||||
|
vec << '1' << '3' << '4';
|
||||||
|
vec.insert(1, '2');
|
||||||
|
piForeachC(char i, vec)
|
||||||
|
cout << i << ", ";
|
||||||
|
// 1, 2, 3, 4,
|
||||||
|
//! [PIVector::insert_0]
|
||||||
|
//! [PIVector::insert_1]
|
||||||
|
PIVector<char> vec, vec2;
|
||||||
|
vec << '1' << '4' << '5';
|
||||||
|
vec2 << '2' << '3';
|
||||||
|
vec.insert(1, vec2);
|
||||||
|
piForeachC(char i, vec)
|
||||||
|
cout << i << ", ";
|
||||||
|
// 1, 2, 3, 4, 5,
|
||||||
|
//! [PIVector::insert_1]
|
||||||
|
//! [PIVector::ostream<<]
|
||||||
|
PIVector<char> vec;
|
||||||
|
vec << '1' << '2' << '3' << '4' << '5';
|
||||||
|
cout << vec << endl;
|
||||||
|
// {1, 2, 3, 4, 5}
|
||||||
|
//! [PIVector::ostream<<]
|
||||||
|
//! [PIVector::PICout<<]
|
||||||
|
PIVector<char> vec;
|
||||||
|
vec << '1' << '2' << '3' << '4' << '5';
|
||||||
|
piCout << vec;
|
||||||
|
// {1, 2, 3, 4, 5}
|
||||||
|
//! [PIVector::PICout<<]
|
||||||
};
|
};
|
||||||
|
|||||||
@@ -1,31 +1,31 @@
|
|||||||
#include "pip.h"
|
#include "pip.h"
|
||||||
|
|
||||||
void _() {
|
void _() {
|
||||||
//! [main]
|
//! [main]
|
||||||
PIEvaluator eval;
|
PIEvaluator eval;
|
||||||
|
|
||||||
eval.check("2*sin(pi/2)");
|
eval.check("2*sin(pi/2)");
|
||||||
|
|
||||||
piCout << eval.expression() << "=" << eval.evaluate().real();
|
piCout << eval.expression() << "=" << eval.evaluate().real();
|
||||||
// 2*sin(pi/2) = 2
|
// 2*sin(pi/2) = 2
|
||||||
|
|
||||||
eval.check("10x");
|
eval.check("10x");
|
||||||
|
|
||||||
piCout << eval.error() << eval.unknownVariables();
|
piCout << eval.error() << eval.unknownVariables();
|
||||||
// Unknown variables: "x" {"x"}
|
// Unknown variables: "x" {"x"}
|
||||||
|
|
||||||
eval.setVariable("x", complexd(1, 2));
|
eval.setVariable("x", complexd(1, 2));
|
||||||
eval.check("10x");
|
eval.check("10x");
|
||||||
|
|
||||||
piCout << eval.error() << eval.unknownVariables();
|
piCout << eval.error() << eval.unknownVariables();
|
||||||
// Correct {}
|
// Correct {}
|
||||||
|
|
||||||
piCout << eval.expression() << "=" << eval.evaluate();
|
piCout << eval.expression() << "=" << eval.evaluate();
|
||||||
// 10*x = (10; 20)
|
// 10*x = (10; 20)
|
||||||
|
|
||||||
eval.setVariable("x", complexd(-2, 0));
|
eval.setVariable("x", complexd(-2, 0));
|
||||||
|
|
||||||
piCout << eval.expression() << "=" << eval.evaluate();
|
piCout << eval.expression() << "=" << eval.evaluate();
|
||||||
// 10*x = (-20; 0)
|
// 10*x = (-20; 0)
|
||||||
//! [main]
|
//! [main]
|
||||||
};
|
};
|
||||||
|
|||||||
+54
-52
@@ -1,55 +1,57 @@
|
|||||||
#include "pip.h"
|
#include "pip.h"
|
||||||
void _() {
|
void _() {
|
||||||
|
//! [swap]
|
||||||
//! [swap]
|
int v1 = 1, v2 = 2;
|
||||||
int v1 = 1, v2 = 2;
|
piCout << v1 << v2; // 1 2
|
||||||
piCout << v1 << v2; // 1 2
|
piSwap<int>(v1, v2);
|
||||||
piSwap<int>(v1, v2);
|
piCout << v1 << v2; // 2 1
|
||||||
piCout << v1 << v2; // 2 1
|
//! [swap]
|
||||||
//! [swap]
|
//! [round]
|
||||||
//! [round]
|
piCout << piRoundf(0.6f) << piRoundd(0.2); // 1 0
|
||||||
piCout << piRoundf(0.6f) << piRoundd(0.2); // 1 0
|
piCout << piRoundf(-0.6f) << piRoundd(-0.2); // -1 0
|
||||||
piCout << piRoundf(-0.6f) << piRoundd(-0.2); // -1 0
|
//! [round]
|
||||||
//! [round]
|
//! [floor]
|
||||||
//! [floor]
|
piCout << piFloorf(0.6f) << piFloorf(0.2); // 0 0
|
||||||
piCout << piFloorf(0.6f) << piFloorf(0.2); // 0 0
|
piCout << piFloorf(-0.6f) << piFloorf(-0.2f); // -1 -1
|
||||||
piCout << piFloorf(-0.6f) << piFloorf(-0.2f); // -1 -1
|
//! [floor]
|
||||||
//! [floor]
|
//! [ceil]
|
||||||
//! [ceil]
|
piCout << piCeilf(0.6f) << piCeilf(0.2); // 1 1
|
||||||
piCout << piCeilf(0.6f) << piCeilf(0.2); // 1 1
|
piCout << piCeilf(-0.6f) << piCeilf(-0.2f); // 0 0
|
||||||
piCout << piCeilf(-0.6f) << piCeilf(-0.2f); // 0 0
|
//! [ceil]
|
||||||
//! [ceil]
|
//! [abs]
|
||||||
//! [abs]
|
piCout << piAbsi(5) << piAbsi(-11); // 5 11
|
||||||
piCout << piAbsi(5) << piAbsi(-11); // 5 11
|
piCout << piAbsf(-0.6f) << piAbsf(-0.2f); // 0.6 0.2
|
||||||
piCout << piAbsf(-0.6f) << piAbsf(-0.2f); // 0.6 0.2
|
//! [abs]
|
||||||
//! [abs]
|
//! [min2]
|
||||||
//! [min2]
|
piCout << piMini(5, 1); // 1
|
||||||
piCout << piMini(5, 1); // 1
|
piCout << piMinf(-0.6f, -0.2f); // -0.6
|
||||||
piCout << piMinf(-0.6f, -0.2f); // -0.6
|
//! [min2]
|
||||||
//! [min2]
|
//! [min3]
|
||||||
//! [min3]
|
piCout << piMini(5, 1, -1); // -1
|
||||||
piCout << piMini(5, 1, -1); // -1
|
piCout << piMinf(-0.6f, -0.2f, 1.f); // -0.6
|
||||||
piCout << piMinf(-0.6f, -0.2f, 1.f); // -0.6
|
//! [min3]
|
||||||
//! [min3]
|
//! [max2]
|
||||||
//! [max2]
|
piCout << piMaxi(5, 1); // 5
|
||||||
piCout << piMaxi(5, 1); // 5
|
piCout << piMaxf(-0.6f, -0.2f); // -0.2
|
||||||
piCout << piMaxf(-0.6f, -0.2f); // -0.2
|
//! [max2]
|
||||||
//! [max2]
|
//! [max3]
|
||||||
//! [max3]
|
piCout << piMaxi(5, 1, -1); // 5
|
||||||
piCout << piMaxi(5, 1, -1); // 5
|
piCout << piMaxf(-0.6f, -0.2f, 1.f); // 1
|
||||||
piCout << piMaxf(-0.6f, -0.2f, 1.f); // 1
|
//! [max3]
|
||||||
//! [max3]
|
//! [clamp]
|
||||||
//! [clamp]
|
piCout << piClampf(-5, -3, 2); // -3
|
||||||
piCout << piClampf(-5, -3, 2); // -3
|
piCout << piClampf(1, -3, 2); // 1
|
||||||
piCout << piClampf(1, -3, 2); // 1
|
piCout << piClampf(5, -3, 2); // 2
|
||||||
piCout << piClampf(5, -3, 2); // 2
|
//! [clamp]
|
||||||
//! [clamp]
|
//! [flags]
|
||||||
//! [flags]
|
enum TestEnum {
|
||||||
enum TestEnum {First = 0x1, Second = 0x2, Third = 0x4};
|
First = 0x1,
|
||||||
PIFlags<TestEnum> testFlags(First);
|
Second = 0x2,
|
||||||
testFlags |= Third;
|
Third = 0x4
|
||||||
piCout << testFlags[First] << testFlags[Second] << testFlags[Third]; // 1 0 1
|
};
|
||||||
piCout << (int)testFlags; // 5
|
PIFlags<TestEnum> testFlags(First);
|
||||||
//! [flags]
|
testFlags |= Third;
|
||||||
|
piCout << testFlags[First] << testFlags[Second] << testFlags[Third]; // 1 0 1
|
||||||
|
piCout << (int)testFlags; // 5
|
||||||
|
//! [flags]
|
||||||
};
|
};
|
||||||
|
|||||||
+45
-48
@@ -1,52 +1,49 @@
|
|||||||
#include "pip.h"
|
#include "pip.h"
|
||||||
void _() {
|
void _() {
|
||||||
|
//! [0]
|
||||||
//! [0]
|
class SomeIO: public PIIODevice {
|
||||||
class SomeIO: public PIIODevice {
|
PIIODEVICE(SomeIO, "myio")
|
||||||
PIIODEVICE(SomeIO, "myio")
|
|
||||||
public:
|
|
||||||
SomeIO(): PIIODevice() {}
|
|
||||||
protected:
|
|
||||||
bool openDevice() override {
|
|
||||||
// open your device here
|
|
||||||
return if_success;
|
|
||||||
}
|
|
||||||
ssize_t readDevice(void * read_to, ssize_t max_size) override {
|
|
||||||
// read from your device here
|
|
||||||
return readed_bytes;
|
|
||||||
}
|
|
||||||
ssize_t writeDevice(const void * data, ssize_t max_size) override {
|
|
||||||
// write to your device here
|
|
||||||
return written_bytes;
|
|
||||||
}
|
|
||||||
void configureFromFullPathDevice(const PIString & full_path) override {
|
|
||||||
// parse full_path and configure device here
|
|
||||||
}
|
|
||||||
};
|
|
||||||
REGISTER_DEVICE(SomeIO)
|
|
||||||
//! [0]
|
|
||||||
//! [configure]
|
|
||||||
// file example.conf
|
|
||||||
dev.reopenEnabled = false
|
|
||||||
dev.device = /dev/ttyS0
|
|
||||||
dev.speed = 9600
|
|
||||||
// end example.conf
|
|
||||||
// code
|
|
||||||
PISerial ser;
|
|
||||||
ser.configure("example.conf", "dev");
|
|
||||||
//! [configure]
|
|
||||||
//! [configureDevice]
|
|
||||||
class SomeIO: public PIIODevice {
|
|
||||||
...
|
|
||||||
bool configureDevice(const void * e_main, const void * e_parent) override {
|
|
||||||
PIConfig::Entry * em = (PIConfig::Entry * )e_main;
|
|
||||||
PIConfig::Entry * ep = (PIConfig::Entry * )e_parent;
|
|
||||||
setStringParam(readDeviceSetting<PIString>("stringParam", stringParam(), em, ep));
|
|
||||||
setIntParam(readDeviceSetting<int>("intParam", intParam(), em, ep));
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
...
|
|
||||||
};
|
|
||||||
//! [configureDevice]
|
|
||||||
|
|
||||||
|
public:
|
||||||
|
SomeIO(): PIIODevice() {}
|
||||||
|
|
||||||
|
protected:
|
||||||
|
bool openDevice() override {
|
||||||
|
// open your device here
|
||||||
|
return if_success;
|
||||||
|
}
|
||||||
|
ssize_t readDevice(void * read_to, ssize_t max_size) override {
|
||||||
|
// read from your device here
|
||||||
|
return readed_bytes;
|
||||||
|
}
|
||||||
|
ssize_t writeDevice(const void * data, ssize_t max_size) override {
|
||||||
|
// write to your device here
|
||||||
|
return written_bytes;
|
||||||
|
}
|
||||||
|
void configureFromFullPathDevice(const PIString & full_path) override {
|
||||||
|
// parse full_path and configure device here
|
||||||
|
}
|
||||||
|
};
|
||||||
|
REGISTER_DEVICE(SomeIO)
|
||||||
|
//! [0]
|
||||||
|
//! [configure]
|
||||||
|
// file example.conf
|
||||||
|
dev.reopenEnabled = false dev.device = / dev / ttyS0 dev.speed = 9600
|
||||||
|
// end example.conf
|
||||||
|
// code
|
||||||
|
PISerial ser;
|
||||||
|
ser.configure("example.conf", "dev");
|
||||||
|
//! [configure]
|
||||||
|
//! [configureDevice]
|
||||||
|
class SomeIO: public PIIODevice {
|
||||||
|
... bool configureDevice(const void * e_main, const void * e_parent) override {
|
||||||
|
PIConfig::Entry * em = (PIConfig::Entry *)e_main;
|
||||||
|
PIConfig::Entry * ep = (PIConfig::Entry *)e_parent;
|
||||||
|
setStringParam(readDeviceSetting<PIString>("stringParam", stringParam(), em, ep));
|
||||||
|
setIntParam(readDeviceSetting<int>("intParam", intParam(), em, ep));
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
...
|
||||||
|
};
|
||||||
|
//! [configureDevice]
|
||||||
};
|
};
|
||||||
|
|||||||
@@ -1,7 +1,7 @@
|
|||||||
#include "pip.h"
|
#include "pip.h"
|
||||||
|
|
||||||
//! [main]
|
//! [main]
|
||||||
void key_event(char key, void * ) {
|
void key_event(char key, void *) {
|
||||||
piCout << "key" << key << "pressed";
|
piCout << "key" << key << "pressed";
|
||||||
}
|
}
|
||||||
int main(int argc, char ** argv) {
|
int main(int argc, char ** argv) {
|
||||||
@@ -13,5 +13,4 @@ int main(int argc, char ** argv) {
|
|||||||
}
|
}
|
||||||
//! [main]
|
//! [main]
|
||||||
|
|
||||||
void _() {
|
void _() {};
|
||||||
};
|
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
#include "pip.h"
|
#include "pip.h"
|
||||||
|
|
||||||
void _() {
|
void _() {
|
||||||
//! [main]
|
//! [main]
|
||||||
//! [main]
|
//! [main]
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -3,34 +3,36 @@
|
|||||||
//! [main]
|
//! [main]
|
||||||
class ObjectA: public PIObject {
|
class ObjectA: public PIObject {
|
||||||
PIOBJECT(ObjectA)
|
PIOBJECT(ObjectA)
|
||||||
|
|
||||||
public:
|
public:
|
||||||
EVENT_HANDLER1(void, handlerA, const PIString & , str) {piCoutObj << "handler A:" << str;}
|
EVENT_HANDLER1(void, handlerA, const PIString &, str) { piCoutObj << "handler A:" << str; }
|
||||||
EVENT1(eventA1, const PIString & , str);
|
EVENT1(eventA1, const PIString &, str);
|
||||||
EVENT2(eventA2, int, i, float, f);
|
EVENT2(eventA2, int, i, float, f);
|
||||||
};
|
};
|
||||||
|
|
||||||
class ObjectB: public PIObject {
|
class ObjectB: public PIObject {
|
||||||
PIOBJECT(ObjectB)
|
PIOBJECT(ObjectB)
|
||||||
|
|
||||||
public:
|
public:
|
||||||
EVENT_HANDLER2(void, handlerB, int, i, float, f) {piCoutObj << "handler B:" << i << "," << f;}
|
EVENT_HANDLER2(void, handlerB, int, i, float, f) { piCoutObj << "handler B:" << i << "," << f; }
|
||||||
EVENT1(eventB, PIString, str);
|
EVENT1(eventB, PIString, str);
|
||||||
};
|
};
|
||||||
|
|
||||||
int main(int argc, char * argv[]) {
|
int main(int argc, char * argv[]) {
|
||||||
ObjectA obj_a;
|
ObjectA obj_a;
|
||||||
ObjectB obj_b;
|
ObjectB obj_b;
|
||||||
|
|
||||||
CONNECT2(void, int, float, &obj_a, eventA2, &obj_b, handlerB);
|
CONNECT2(void, int, float, &obj_a, eventA2, &obj_b, handlerB);
|
||||||
obj_a.eventA2(2, 0.5);
|
obj_a.eventA2(2, 0.5);
|
||||||
|
|
||||||
CONNECT1(void, PIString, &obj_b, eventB, &obj_a, handlerA);
|
CONNECT1(void, PIString, &obj_b, eventB, &obj_a, handlerA);
|
||||||
obj_b.eventB("event to handler");
|
obj_b.eventB("event to handler");
|
||||||
|
|
||||||
CONNECTU(&obj_a, eventA1, &obj_b, eventB);
|
CONNECTU(&obj_a, eventA1, &obj_b, eventB);
|
||||||
obj_a.eventA1("event to event");
|
obj_a.eventA1("event to event");
|
||||||
|
|
||||||
obj_a.piDisconnect("eventA1");
|
obj_a.piDisconnect("eventA1");
|
||||||
CONNECTL(&obj_a, eventA1, ([](const PIString & str){piCout << str;}));
|
CONNECTL(&obj_a, eventA1, ([](const PIString & str) { piCout << str; }));
|
||||||
obj_a.eventA1("event to lambda");
|
obj_a.eventA1("event to lambda");
|
||||||
};
|
};
|
||||||
//! [main]
|
//! [main]
|
||||||
|
|||||||
@@ -7,22 +7,25 @@ enum Header {
|
|||||||
hVoid
|
hVoid
|
||||||
};
|
};
|
||||||
|
|
||||||
class MyObj: public PIObject, public PIParseHelper<uchar> {
|
class MyObj
|
||||||
|
: public PIObject
|
||||||
|
, public PIParseHelper<uchar> {
|
||||||
PIOBJECT(MyObj);
|
PIOBJECT(MyObj);
|
||||||
|
|
||||||
public:
|
public:
|
||||||
MyObj(): PIParseHelper<uchar>(this) {
|
MyObj(): PIParseHelper<uchar>(this) {
|
||||||
// Keys with 1 argument
|
// Keys with 1 argument
|
||||||
assign(hInt, std::function<void(int)>([this](int i){piCout << "lambda type Int" << i;}));
|
assign(hInt, std::function<void(int)>([this](int i) { piCout << "lambda type Int" << i; }));
|
||||||
assign(hInt, HANDLER(methodI));
|
assign(hInt, HANDLER(methodI));
|
||||||
assign(hString, HANDLER(methodS));
|
assign(hString, HANDLER(methodS));
|
||||||
|
|
||||||
// hVoid key, without arguments
|
// hVoid key, without arguments
|
||||||
assign(hVoid, [](){piCout << "type void";});
|
assign(hVoid, []() { piCout << "type void"; });
|
||||||
assign(hVoid, HANDLER(method));
|
assign(hVoid, HANDLER(method));
|
||||||
}
|
}
|
||||||
EVENT_HANDLER1(void, methodI, int, i) {piCout << "methodI" << i;}
|
EVENT_HANDLER1(void, methodI, int, i) { piCout << "methodI" << i; }
|
||||||
EVENT_HANDLER1(void, methodS, PIString, s) {piCout << "methodS" << s;}
|
EVENT_HANDLER1(void, methodS, PIString, s) { piCout << "methodS" << s; }
|
||||||
EVENT_HANDLER0(void, method) {piCout << "method";}
|
EVENT_HANDLER0(void, method) { piCout << "method"; }
|
||||||
};
|
};
|
||||||
|
|
||||||
int main() {
|
int main() {
|
||||||
@@ -58,10 +61,11 @@ enum Header {
|
|||||||
|
|
||||||
class MyObj: public PIObject {
|
class MyObj: public PIObject {
|
||||||
PIOBJECT(MyObj);
|
PIOBJECT(MyObj);
|
||||||
|
|
||||||
public:
|
public:
|
||||||
EVENT_HANDLER1(void, methodI, int, i) {piCout << "methodI" << i;}
|
EVENT_HANDLER1(void, methodI, int, i) { piCout << "methodI" << i; }
|
||||||
EVENT_HANDLER1(void, methodS, PIString, s) {piCout << "methodS" << s;}
|
EVENT_HANDLER1(void, methodS, PIString, s) { piCout << "methodS" << s; }
|
||||||
EVENT_HANDLER0(void, method) {piCout << "method";}
|
EVENT_HANDLER0(void, method) { piCout << "method"; }
|
||||||
};
|
};
|
||||||
|
|
||||||
int main() {
|
int main() {
|
||||||
|
|||||||
@@ -1,10 +1,17 @@
|
|||||||
//! [main]
|
//! [main]
|
||||||
#include "pip.h"
|
#include "pip.h"
|
||||||
|
|
||||||
enum Mode {Start, Manual, Auto, Finish, End};
|
enum Mode {
|
||||||
|
Start,
|
||||||
|
Manual,
|
||||||
|
Auto,
|
||||||
|
Finish,
|
||||||
|
End
|
||||||
|
};
|
||||||
|
|
||||||
class Machine: public PIStateMachine<Mode> {
|
class Machine: public PIStateMachine<Mode> {
|
||||||
PIOBJECT_SUBCLASS(Machine, PIObject)
|
PIOBJECT_SUBCLASS(Machine, PIObject)
|
||||||
|
|
||||||
public:
|
public:
|
||||||
Machine() {
|
Machine() {
|
||||||
addState(Start, "start", HANDLER(startFunc));
|
addState(Start, "start", HANDLER(startFunc));
|
||||||
@@ -12,7 +19,7 @@ public:
|
|||||||
addState(Auto, "auto", HANDLER(autoFunc));
|
addState(Auto, "auto", HANDLER(autoFunc));
|
||||||
addState(Finish, "finish", HANDLER(finishFunc));
|
addState(Finish, "finish", HANDLER(finishFunc));
|
||||||
addState(End, "end", HANDLER(endFunc));
|
addState(End, "end", HANDLER(endFunc));
|
||||||
|
|
||||||
addRule(Start, Manual, "init_ok", HANDLER(beginManualFunc));
|
addRule(Start, Manual, "init_ok", HANDLER(beginManualFunc));
|
||||||
addRule(Start, Auto, "init_ok", HANDLER(beginAutoFunc));
|
addRule(Start, Auto, "init_ok", HANDLER(beginAutoFunc));
|
||||||
addRule(Manual, Auto, HANDLER(manualToAutoFunc));
|
addRule(Manual, Auto, HANDLER(manualToAutoFunc));
|
||||||
@@ -23,35 +30,31 @@ public:
|
|||||||
r.addCondition("finish_0_ok");
|
r.addCondition("finish_0_ok");
|
||||||
r.addCondition("finish_1_ok", 2);
|
r.addCondition("finish_1_ok", 2);
|
||||||
addRule(r);
|
addRule(r);
|
||||||
|
|
||||||
setInitialState(Start);
|
setInitialState(Start);
|
||||||
|
|
||||||
CONNECT2(void, void*, int, &timer, timeout, this, tick);
|
CONNECT2(void, void *, int, &timer, timeout, this, tick);
|
||||||
timer.start(500);
|
timer.start(500);
|
||||||
}
|
}
|
||||||
virtual void execution(const State & state) {
|
virtual void execution(const State & state) { piCout << "performed conditions:" << currentConditions(); }
|
||||||
piCout << "performed conditions:" << currentConditions();
|
virtual void transition(const State & from, const State & to) { piCout << "switch from" << from.name << "to" << to.name << "state"; }
|
||||||
}
|
|
||||||
virtual void transition(const State & from, const State & to) {
|
EVENT_HANDLER(void, startFunc) { piCout << "start function"; }
|
||||||
piCout << "switch from" << from.name << "to" << to.name << "state";
|
EVENT_HANDLER(void, manualFunc) { piCout << "manual function"; }
|
||||||
}
|
EVENT_HANDLER(void, autoFunc) { piCout << "auto function"; }
|
||||||
|
EVENT_HANDLER(void, finishFunc) { piCout << "finish function"; }
|
||||||
EVENT_HANDLER(void, startFunc) {piCout << "start function";}
|
EVENT_HANDLER(void, endFunc) { piCout << "end function"; }
|
||||||
EVENT_HANDLER(void, manualFunc) {piCout << "manual function";}
|
EVENT_HANDLER(void, beginManualFunc) { piCout << "begin manual function"; }
|
||||||
EVENT_HANDLER(void, autoFunc) {piCout << "auto function";}
|
EVENT_HANDLER(void, beginAutoFunc) { piCout << "begin auto function"; }
|
||||||
EVENT_HANDLER(void, finishFunc) {piCout << "finish function";}
|
EVENT_HANDLER(void, autoToManualFunc) { piCout << "switch from auto to manual function"; }
|
||||||
EVENT_HANDLER(void, endFunc) {piCout << "end function";}
|
EVENT_HANDLER(void, manualToAutoFunc) { piCout << "switch from manual to auto function"; }
|
||||||
EVENT_HANDLER(void, beginManualFunc) {piCout << "begin manual function";}
|
|
||||||
EVENT_HANDLER(void, beginAutoFunc) {piCout << "begin auto function";}
|
|
||||||
EVENT_HANDLER(void, autoToManualFunc) {piCout << "switch from auto to manual function";}
|
|
||||||
EVENT_HANDLER(void, manualToAutoFunc) {piCout << "switch from manual to auto function";}
|
|
||||||
|
|
||||||
PITimer timer;
|
PITimer timer;
|
||||||
};
|
};
|
||||||
|
|
||||||
Machine machine;
|
Machine machine;
|
||||||
|
|
||||||
void key_event(char key, void*) {
|
void key_event(char key, void *) {
|
||||||
switch (key) {
|
switch (key) {
|
||||||
case 's': machine.switchToState(Start); break;
|
case 's': machine.switchToState(Start); break;
|
||||||
case 'm': machine.switchToState(Manual); break;
|
case 'm': machine.switchToState(Manual); break;
|
||||||
|
|||||||
@@ -60,7 +60,7 @@ int main() {
|
|||||||
};
|
};
|
||||||
//! [system_time]
|
//! [system_time]
|
||||||
|
|
||||||
void _(){
|
void _() {
|
||||||
|
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|||||||
@@ -135,8 +135,7 @@ PIPair<PICloud::TCP::Type, PICloud::TCP::Role> PICloud::TCP::parseHeader(PIByteA
|
|||||||
PICloud::TCP::Header hdr;
|
PICloud::TCP::Header hdr;
|
||||||
ba >> hdr;
|
ba >> hdr;
|
||||||
if (hdr.version != header.version) {
|
if (hdr.version != header.version) {
|
||||||
piCout << "[PICloud]"
|
piCout << "[PICloud]" << "Invalid PICloud::TCP version!"_tr("PICloud");
|
||||||
<< "Invalid PICloud::TCP version!"_tr("PICloud");
|
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
ret.first = (Type)hdr.type;
|
ret.first = (Type)hdr.type;
|
||||||
|
|||||||
@@ -40,8 +40,7 @@ PIByteArray piCompress(const PIByteArray & ba, int level) {
|
|||||||
ulong sz = zba.size();
|
ulong sz = zba.size();
|
||||||
ret = compress2(zba.data(), &sz, ba.data(), ba.size(), level);
|
ret = compress2(zba.data(), &sz, ba.data(), ba.size(), level);
|
||||||
if (ret != Z_OK) {
|
if (ret != Z_OK) {
|
||||||
piCout << "[PICompress]"
|
piCout << "[PICompress]" << "Error: invalid input or not enought memory"_tr("PICompress");
|
||||||
<< "Error: invalid input or not enought memory"_tr("PICompress");
|
|
||||||
return ba;
|
return ba;
|
||||||
}
|
}
|
||||||
zba.resize(sz);
|
zba.resize(sz);
|
||||||
@@ -59,8 +58,7 @@ PIByteArray piDecompress(const PIByteArray & zba) {
|
|||||||
#ifdef PIP_COMPRESS
|
#ifdef PIP_COMPRESS
|
||||||
ullong sz = 0;
|
ullong sz = 0;
|
||||||
if (zba.size() < sizeof(ullong)) {
|
if (zba.size() < sizeof(ullong)) {
|
||||||
piCout << "[PICompress]"
|
piCout << "[PICompress]" << "Error: invalid input"_tr("PICompress");
|
||||||
<< "Error: invalid input"_tr("PICompress");
|
|
||||||
return zba;
|
return zba;
|
||||||
}
|
}
|
||||||
PIByteArray ba(zba.data(zba.size() - sizeof(ullong)), sizeof(ullong));
|
PIByteArray ba(zba.data(zba.size() - sizeof(ullong)), sizeof(ullong));
|
||||||
@@ -70,8 +68,7 @@ PIByteArray piDecompress(const PIByteArray & zba) {
|
|||||||
ulong s = sz;
|
ulong s = sz;
|
||||||
ret = uncompress(ba.data(), &s, zba.data(), zba.size() - sizeof(ullong));
|
ret = uncompress(ba.data(), &s, zba.data(), zba.size() - sizeof(ullong));
|
||||||
if (ret != Z_OK) {
|
if (ret != Z_OK) {
|
||||||
piCout << "[PICompress]"
|
piCout << "[PICompress]" << "Error: invalid input or not enought memory"_tr("PICompress");
|
||||||
<< "Error: invalid input or not enought memory"_tr("PICompress");
|
|
||||||
return zba;
|
return zba;
|
||||||
}
|
}
|
||||||
return ba;
|
return ba;
|
||||||
|
|||||||
@@ -20,74 +20,74 @@
|
|||||||
#include "piscreendrawer.h"
|
#include "piscreendrawer.h"
|
||||||
|
|
||||||
// comment for use ascii instead of unicode symbols
|
// comment for use ascii instead of unicode symbols
|
||||||
# define USE_UNICODE
|
#define USE_UNICODE
|
||||||
|
|
||||||
using namespace PIScreenTypes;
|
using namespace PIScreenTypes;
|
||||||
|
|
||||||
|
|
||||||
PIScreenDrawer::PIScreenDrawer(PIVector<PIVector<Cell>> & c): cells(c) {
|
PIScreenDrawer::PIScreenDrawer(PIVector<PIVector<Cell>> & c): cells(c) {
|
||||||
arts_[LineVertical] =
|
arts_[LineVertical] =
|
||||||
# ifdef USE_UNICODE
|
#ifdef USE_UNICODE
|
||||||
PIChar::fromUTF8("│");
|
PIChar::fromUTF8("│");
|
||||||
# else
|
#else
|
||||||
PIChar('|');
|
PIChar('|');
|
||||||
# endif
|
#endif
|
||||||
|
|
||||||
arts_[LineHorizontal] =
|
arts_[LineHorizontal] =
|
||||||
# ifdef USE_UNICODE
|
#ifdef USE_UNICODE
|
||||||
PIChar::fromUTF8("─");
|
PIChar::fromUTF8("─");
|
||||||
# else
|
#else
|
||||||
PIChar('-');
|
PIChar('-');
|
||||||
# endif
|
#endif
|
||||||
|
|
||||||
arts_[Cross] =
|
arts_[Cross] =
|
||||||
# ifdef USE_UNICODE
|
#ifdef USE_UNICODE
|
||||||
PIChar::fromUTF8("┼");
|
PIChar::fromUTF8("┼");
|
||||||
# else
|
#else
|
||||||
PIChar('+');
|
PIChar('+');
|
||||||
# endif
|
#endif
|
||||||
|
|
||||||
arts_[CornerTopLeft] =
|
arts_[CornerTopLeft] =
|
||||||
# ifdef USE_UNICODE
|
#ifdef USE_UNICODE
|
||||||
PIChar::fromUTF8("┌");
|
PIChar::fromUTF8("┌");
|
||||||
# else
|
#else
|
||||||
PIChar('+');
|
PIChar('+');
|
||||||
# endif
|
#endif
|
||||||
|
|
||||||
arts_[CornerTopRight] =
|
arts_[CornerTopRight] =
|
||||||
# ifdef USE_UNICODE
|
#ifdef USE_UNICODE
|
||||||
PIChar::fromUTF8("┐");
|
PIChar::fromUTF8("┐");
|
||||||
# else
|
#else
|
||||||
PIChar('+');
|
PIChar('+');
|
||||||
# endif
|
#endif
|
||||||
|
|
||||||
arts_[CornerBottomLeft] =
|
arts_[CornerBottomLeft] =
|
||||||
# ifdef USE_UNICODE
|
#ifdef USE_UNICODE
|
||||||
PIChar::fromUTF8("└");
|
PIChar::fromUTF8("└");
|
||||||
# else
|
#else
|
||||||
PIChar('+');
|
PIChar('+');
|
||||||
# endif
|
#endif
|
||||||
|
|
||||||
arts_[CornerBottomRight] =
|
arts_[CornerBottomRight] =
|
||||||
# ifdef USE_UNICODE
|
#ifdef USE_UNICODE
|
||||||
PIChar::fromUTF8("┘");
|
PIChar::fromUTF8("┘");
|
||||||
# else
|
#else
|
||||||
PIChar('+');
|
PIChar('+');
|
||||||
# endif
|
#endif
|
||||||
|
|
||||||
arts_[Unchecked] =
|
arts_[Unchecked] =
|
||||||
# ifdef USE_UNICODE
|
#ifdef USE_UNICODE
|
||||||
PIChar::fromUTF8("☐");
|
PIChar::fromUTF8("☐");
|
||||||
# else
|
#else
|
||||||
PIChar('O');
|
PIChar('O');
|
||||||
# endif
|
#endif
|
||||||
|
|
||||||
arts_[Checked] =
|
arts_[Checked] =
|
||||||
# ifdef USE_UNICODE
|
#ifdef USE_UNICODE
|
||||||
PIChar::fromUTF8("☑");
|
PIChar::fromUTF8("☑");
|
||||||
# else
|
#else
|
||||||
PIChar('0');
|
PIChar('0');
|
||||||
# endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -348,8 +348,8 @@ void PITerminal::getCursor(int & x, int & y) {
|
|||||||
int sz = 0;
|
int sz = 0;
|
||||||
PRIVATE->shm->read(&sz, 4);
|
PRIVATE->shm->read(&sz, 4);
|
||||||
# else
|
# else
|
||||||
x = PRIVATE->cur_x;
|
x = PRIVATE->cur_x;
|
||||||
y = PRIVATE->cur_y;
|
y = PRIVATE->cur_y;
|
||||||
# endif
|
# endif
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -980,5 +980,3 @@ bool PITerminal::resize(int cols, int rows) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
#endif // PIP_HAS_PROCESS
|
#endif // PIP_HAS_PROCESS
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -32,8 +32,7 @@ constexpr int hash_def_key_size = 9;
|
|||||||
|
|
||||||
PICrypt::PICrypt() {
|
PICrypt::PICrypt() {
|
||||||
if (!init()) {
|
if (!init()) {
|
||||||
piCout << "[PICrypt]"
|
piCout << "[PICrypt]" << "Error while initialize sodium!"_tr("PICrypt");
|
||||||
<< "Error while initialize sodium!"_tr("PICrypt");
|
|
||||||
}
|
}
|
||||||
nonce_.resize(crypto_secretbox_NONCEBYTES);
|
nonce_.resize(crypto_secretbox_NONCEBYTES);
|
||||||
key_.resize(crypto_secretbox_KEYBYTES);
|
key_.resize(crypto_secretbox_KEYBYTES);
|
||||||
@@ -183,9 +182,7 @@ ullong PICrypt::shorthash(const PIString & s, PIByteArray key) {
|
|||||||
key.fill(0);
|
key.fill(0);
|
||||||
return hash;
|
return hash;
|
||||||
}
|
}
|
||||||
if (crypto_shorthash_BYTES != sizeof(hash))
|
if (crypto_shorthash_BYTES != sizeof(hash)) piCout << "[PICrypt]" << "internal error: bad hash size"_tr("PICrypt");
|
||||||
piCout << "[PICrypt]"
|
|
||||||
<< "internal error: bad hash size"_tr("PICrypt");
|
|
||||||
if (key.size() != crypto_shorthash_KEYBYTES) {
|
if (key.size() != crypto_shorthash_KEYBYTES) {
|
||||||
piCout << "[PICrypt]"
|
piCout << "[PICrypt]"
|
||||||
<< "invalid key size %1, should be %2, filled with zeros"_tr("PICrypt").arg(key.size()).arg(crypto_shorthash_KEYBYTES);
|
<< "invalid key size %1, should be %2, filled with zeros"_tr("PICrypt").arg(key.size()).arg(crypto_shorthash_KEYBYTES);
|
||||||
|
|||||||
@@ -68,8 +68,8 @@ bool MicrohttpdServerConnection::checkBasicAuth() {
|
|||||||
}
|
}
|
||||||
// piCout << "miss authorization";
|
// piCout << "miss authorization";
|
||||||
sendReply(MessageMutable::fromCode(Code::Unauthorized)
|
sendReply(MessageMutable::fromCode(Code::Unauthorized)
|
||||||
.addHeader(Header::WWWAuthenticate, "Basic realm=\"%1\", charset=\"UTF-8\""_a.arg(server->realm))
|
.addHeader(Header::WWWAuthenticate, "Basic realm=\"%1\", charset=\"UTF-8\""_a.arg(server->realm))
|
||||||
.setBody(PIByteArray::fromAscii("Authorization required")));
|
.setBody(PIByteArray::fromAscii("Authorization required")));
|
||||||
// piCout << "answer sent";
|
// piCout << "answer sent";
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
@@ -226,9 +226,7 @@ int answer_callback(void * cls,
|
|||||||
m = Method::Patch;
|
m = Method::Patch;
|
||||||
|
|
||||||
if (m == Method::Unknown) {
|
if (m == Method::Unknown) {
|
||||||
piCout << "[MicrohttpdServer]"
|
piCout << "[MicrohttpdServer]" << "Warning:" << "Unknown method!";
|
||||||
<< "Warning:"
|
|
||||||
<< "Unknown method!";
|
|
||||||
return MHD_NO;
|
return MHD_NO;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -329,14 +327,14 @@ bool MicrohttpdServer::listen(PINetworkAddress addr) {
|
|||||||
}
|
}
|
||||||
options.append({MHD_OPTION_END, 0, nullptr});
|
options.append({MHD_OPTION_END, 0, nullptr});
|
||||||
PRIVATE->daemon = MHD_start_daemon(flags,
|
PRIVATE->daemon = MHD_start_daemon(flags,
|
||||||
addr.port(),
|
addr.port(),
|
||||||
nullptr,
|
nullptr,
|
||||||
nullptr,
|
nullptr,
|
||||||
(MHD_AccessHandlerCallback)answer_callback,
|
(MHD_AccessHandlerCallback)answer_callback,
|
||||||
this,
|
this,
|
||||||
MHD_OPTION_ARRAY,
|
MHD_OPTION_ARRAY,
|
||||||
options.data(),
|
options.data(),
|
||||||
MHD_OPTION_END);
|
MHD_OPTION_END);
|
||||||
return isListen();
|
return isListen();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -21,10 +21,10 @@
|
|||||||
|
|
||||||
#ifdef PIP_HAS_SOCKET
|
#ifdef PIP_HAS_SOCKET
|
||||||
|
|
||||||
#include "pitranslator.h"
|
# include "pitranslator.h"
|
||||||
#ifdef PIP_CRYPT
|
# ifdef PIP_CRYPT
|
||||||
# include "picrypt.h"
|
# include "picrypt.h"
|
||||||
#endif
|
# endif
|
||||||
|
|
||||||
/** \class PIEthUtilBase
|
/** \class PIEthUtilBase
|
||||||
* \brief Base class for ethernet utils
|
* \brief Base class for ethernet utils
|
||||||
@@ -85,13 +85,12 @@ void PIEthUtilBase::setCryptKey(const PIByteArray & k) {
|
|||||||
|
|
||||||
|
|
||||||
void PIEthUtilBase::createCryptKey(const PIString & k) {
|
void PIEthUtilBase::createCryptKey(const PIString & k) {
|
||||||
#ifdef PIP_CRYPT
|
# ifdef PIP_CRYPT
|
||||||
_key = PICrypt::hash("sodium_bug");
|
_key = PICrypt::hash("sodium_bug");
|
||||||
_key = PICrypt::hash(k);
|
_key = PICrypt::hash(k);
|
||||||
#else
|
# else
|
||||||
piCout << "[PIEthUtilBase]"
|
piCout << "[PIEthUtilBase]" << "PICrypt wasn`t built!"_tr("PIEthUtilBase");
|
||||||
<< "PICrypt wasn`t built!"_tr("PIEthUtilBase");
|
# endif
|
||||||
#endif
|
|
||||||
_crypt = true;
|
_crypt = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -104,32 +103,32 @@ PIByteArray PIEthUtilBase::cryptKey() const {
|
|||||||
PIByteArray PIEthUtilBase::cryptData(const PIByteArray & data) {
|
PIByteArray PIEthUtilBase::cryptData(const PIByteArray & data) {
|
||||||
if (!_crypt) return data;
|
if (!_crypt) return data;
|
||||||
return
|
return
|
||||||
#ifdef PIP_CRYPT
|
# ifdef PIP_CRYPT
|
||||||
PICrypt::crypt(data, _key);
|
PICrypt::crypt(data, _key);
|
||||||
#else
|
# else
|
||||||
PIByteArray();
|
PIByteArray();
|
||||||
#endif
|
# endif
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
PIByteArray PIEthUtilBase::decryptData(const PIByteArray & data) {
|
PIByteArray PIEthUtilBase::decryptData(const PIByteArray & data) {
|
||||||
if (!_crypt) return data;
|
if (!_crypt) return data;
|
||||||
#ifdef PIP_CRYPT
|
# ifdef PIP_CRYPT
|
||||||
bool ok = false;
|
bool ok = false;
|
||||||
PIByteArray ret = PICrypt::decrypt(data, _key, &ok);
|
PIByteArray ret = PICrypt::decrypt(data, _key, &ok);
|
||||||
if (!ok) return PIByteArray();
|
if (!ok) return PIByteArray();
|
||||||
return ret;
|
return ret;
|
||||||
#else
|
# else
|
||||||
return PIByteArray();
|
return PIByteArray();
|
||||||
#endif
|
# endif
|
||||||
}
|
}
|
||||||
|
|
||||||
size_t PIEthUtilBase::cryptSizeAddition() {
|
size_t PIEthUtilBase::cryptSizeAddition() {
|
||||||
#ifdef PIP_CRYPT
|
# ifdef PIP_CRYPT
|
||||||
return PICrypt::sizeCrypt();
|
return PICrypt::sizeCrypt();
|
||||||
#else
|
# else
|
||||||
return 0;
|
return 0;
|
||||||
#endif
|
# endif
|
||||||
}
|
}
|
||||||
|
|
||||||
#endif // PIP_HAS_SOCKET
|
#endif // PIP_HAS_SOCKET
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
/*
|
/*
|
||||||
PIP - Platform Independent Primitives
|
PIP - Platform Independent Primitives
|
||||||
PIPackedTCP
|
PIPackedTCP
|
||||||
Ivan Pelipenko peri4ko@yandex.ru, Andrey Bychkov work.a.b@yandex.ru
|
Ivan Pelipenko peri4ko@yandex.ru, Andrey Bychkov work.a.b@yandex.ru
|
||||||
|
|
||||||
This program is free software: you can redistribute it and/or modify
|
This program is free software: you can redistribute it and/or modify
|
||||||
@@ -168,9 +168,9 @@ ssize_t PIPackedTCP::writeDevice(const void * data, ssize_t max_size) {
|
|||||||
// piCout << m_role << "write" << eth;
|
// piCout << m_role << "write" << eth;
|
||||||
return max_size;
|
return max_size;
|
||||||
/*if (m_role == Client) {
|
/*if (m_role == Client) {
|
||||||
return eth->write(data, max_size);
|
return eth->write(data, max_size);
|
||||||
} else {
|
} else {
|
||||||
if (client) return client->write(data, max_size);
|
if (client) return client->write(data, max_size);
|
||||||
}*/
|
}*/
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -27,9 +27,9 @@
|
|||||||
#include "pitranslator.h"
|
#include "pitranslator.h"
|
||||||
|
|
||||||
#ifdef PIP_HAS_SOCKET
|
#ifdef PIP_HAS_SOCKET
|
||||||
#ifdef __GNUC__
|
# ifdef __GNUC__
|
||||||
# pragma GCC diagnostic pop
|
# pragma GCC diagnostic pop
|
||||||
#endif
|
# endif
|
||||||
|
|
||||||
/** \class PIStreamPacker
|
/** \class PIStreamPacker
|
||||||
* \brief Simple packet wrap aroud any PIIODevice
|
* \brief Simple packet wrap aroud any PIIODevice
|
||||||
|
|||||||
@@ -296,10 +296,8 @@ private:
|
|||||||
//! \~russian Оператор вывода в \a PICout
|
//! \~russian Оператор вывода в \a PICout
|
||||||
inline PICout operator<<(PICout s, const PISystemMonitor::ThreadStats & v) {
|
inline PICout operator<<(PICout s, const PISystemMonitor::ThreadStats & v) {
|
||||||
s.saveAndSetControls(0);
|
s.saveAndSetControls(0);
|
||||||
s << "ThreadInfo(\"" << v.name << "\", created " << v.created << ", work " << v.work_time.toMilliseconds() << " ms"
|
s << "ThreadInfo(\"" << v.name << "\", created " << v.created << ", work " << v.work_time.toMilliseconds() << " ms" << ", kernel "
|
||||||
<< ", kernel " << v.kernel_time.toMilliseconds() << " ms"
|
<< v.kernel_time.toMilliseconds() << " ms" << ", user " << v.user_time.toMilliseconds() << " ms" << ")\n";
|
||||||
<< ", user " << v.user_time.toMilliseconds() << " ms"
|
|
||||||
<< ")\n";
|
|
||||||
s.restoreControls();
|
s.restoreControls();
|
||||||
return s;
|
return s;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
/*
|
/*
|
||||||
PIP - Platform Independent Primitives
|
PIP - Platform Independent Primitives
|
||||||
Translation private
|
Translation private
|
||||||
Ivan Pelipenko peri4ko@yandex.ru
|
Ivan Pelipenko peri4ko@yandex.ru
|
||||||
|
|
||||||
This program is free software: you can redistribute it and/or modify
|
This program is free software: you can redistribute it and/or modify
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
/*
|
/*
|
||||||
PIP - Platform Independent Primitives
|
PIP - Platform Independent Primitives
|
||||||
Translation private
|
Translation private
|
||||||
Ivan Pelipenko peri4ko@yandex.ru
|
Ivan Pelipenko peri4ko@yandex.ru
|
||||||
|
|
||||||
This program is free software: you can redistribute it and/or modify
|
This program is free software: you can redistribute it and/or modify
|
||||||
|
|||||||
@@ -52,12 +52,12 @@ public:
|
|||||||
//! \~english Constructs a disconnected client connection object.
|
//! \~english Constructs a disconnected client connection object.
|
||||||
//! \~russian Создает объект клиентского соединения в отключенном состоянии.
|
//! \~russian Создает объект клиентского соединения в отключенном состоянии.
|
||||||
ClientBase();
|
ClientBase();
|
||||||
|
|
||||||
//! \~english Destroys the client connection and releases owned resources.
|
//! \~english Destroys the client connection and releases owned resources.
|
||||||
//! \~russian Уничтожает клиентское соединение и освобождает связанные ресурсы.
|
//! \~russian Уничтожает клиентское соединение и освобождает связанные ресурсы.
|
||||||
virtual ~ClientBase();
|
virtual ~ClientBase();
|
||||||
|
|
||||||
|
|
||||||
//! \~english Returns the underlying TCP transport object.
|
//! \~english Returns the underlying TCP transport object.
|
||||||
//! \~russian Возвращает базовый объект TCP-транспорта.
|
//! \~russian Возвращает базовый объект TCP-транспорта.
|
||||||
const PIEthernet * getTCP() const { return tcp; }
|
const PIEthernet * getTCP() const { return tcp; }
|
||||||
@@ -89,18 +89,20 @@ public:
|
|||||||
PIDiagnostics::State diagnostics() const;
|
PIDiagnostics::State diagnostics() const;
|
||||||
|
|
||||||
|
|
||||||
//! \~english Returns how many payload bytes of the current packet are already received (all bytes count passed in \a receivePacketStart()).
|
//! \~english Returns how many payload bytes of the current packet are already received (all bytes count passed in \a
|
||||||
//! \~russian Возвращает, сколько байтов полезной нагрузки текущего пакета уже получено (общее количество передается в \a receivePacketStart()).
|
//! receivePacketStart()).
|
||||||
|
//! \~russian Возвращает, сколько байтов полезной нагрузки текущего пакета уже получено (общее количество передается в \a
|
||||||
|
//! receivePacketStart()).
|
||||||
int receivePacketProgress() const;
|
int receivePacketProgress() const;
|
||||||
|
|
||||||
//! \~english Returns the current packet framing configuration.
|
//! \~english Returns the current packet framing configuration.
|
||||||
//! \~russian Возвращает текущую конфигурацию пакетирования.
|
//! \~russian Возвращает текущую конфигурацию пакетирования.
|
||||||
const PIStreamPackerConfig & configuration() const { return stream.configuration(); }
|
const PIStreamPackerConfig & configuration() const { return stream.configuration(); }
|
||||||
|
|
||||||
//! \~english Returns the current packet framing configuration for modification.
|
//! \~english Returns the current packet framing configuration for modification.
|
||||||
//! \~russian Возвращает текущую конфигурацию пакетирования для изменения.
|
//! \~russian Возвращает текущую конфигурацию пакетирования для изменения.
|
||||||
PIStreamPackerConfig & configuration() { return stream.configuration(); }
|
PIStreamPackerConfig & configuration() { return stream.configuration(); }
|
||||||
|
|
||||||
//! \~english Replaces the packet framing configuration.
|
//! \~english Replaces the packet framing configuration.
|
||||||
//! \~russian Заменяет конфигурацию пакетирования.
|
//! \~russian Заменяет конфигурацию пакетирования.
|
||||||
void setConfiguration(const PIStreamPackerConfig & config) { stream.setConfiguration(config); }
|
void setConfiguration(const PIStreamPackerConfig & config) { stream.setConfiguration(config); }
|
||||||
|
|||||||
+17
-108
@@ -202,137 +202,46 @@ void PICodeParser::clear() {
|
|||||||
defines << Define(PIStringAscii("PICODE"), "") << custom_defines;
|
defines << Define(PIStringAscii("PICODE"), "") << custom_defines;
|
||||||
macros << Macro(PIStringAscii("PIOBJECT"), "", PIStringList() << "name")
|
macros << Macro(PIStringAscii("PIOBJECT"), "", PIStringList() << "name")
|
||||||
<< Macro(PIStringAscii("PIOBJECT_PARENT"), "", PIStringList() << "parent")
|
<< Macro(PIStringAscii("PIOBJECT_PARENT"), "", PIStringList() << "parent")
|
||||||
<< Macro(PIStringAscii("PIOBJECT_SUBCLASS"),
|
<< Macro(PIStringAscii("PIOBJECT_SUBCLASS"), "", PIStringList() << "name" << "parent")
|
||||||
"",
|
|
||||||
PIStringList() << "name"
|
|
||||||
<< "parent")
|
|
||||||
<< Macro(PIStringAscii("PIIODEVICE"), "", PIStringList() << "name")
|
<< Macro(PIStringAscii("PIIODEVICE"), "", PIStringList() << "name")
|
||||||
<< Macro(PIStringAscii("NO_COPY_CLASS"), "", PIStringList() << "name") << Macro(PIStringAscii("PRIVATE_DECLARATION"))
|
<< Macro(PIStringAscii("NO_COPY_CLASS"), "", PIStringList() << "name") << Macro(PIStringAscii("PRIVATE_DECLARATION"))
|
||||||
|
|
||||||
<< Macro(PIStringAscii("EVENT"), "void name();", PIStringList() << "name")
|
<< Macro(PIStringAscii("EVENT"), "void name();", PIStringList() << "name")
|
||||||
<< Macro(PIStringAscii("EVENT0"), "void name();", PIStringList() << "name")
|
<< Macro(PIStringAscii("EVENT0"), "void name();", PIStringList() << "name")
|
||||||
<< Macro(PIStringAscii("EVENT1"),
|
<< Macro(PIStringAscii("EVENT1"), "void name(a0 n0);", PIStringList() << "name" << "a0" << "n0")
|
||||||
"void name(a0 n0);",
|
<< Macro(PIStringAscii("EVENT2"), "void name(a0 n0, a1 n1);", PIStringList() << "name" << "a0" << "n0" << "a1" << "n1")
|
||||||
PIStringList() << "name"
|
|
||||||
<< "a0"
|
|
||||||
<< "n0")
|
|
||||||
<< Macro(PIStringAscii("EVENT2"),
|
|
||||||
"void name(a0 n0, a1 n1);",
|
|
||||||
PIStringList() << "name"
|
|
||||||
<< "a0"
|
|
||||||
<< "n0"
|
|
||||||
<< "a1"
|
|
||||||
<< "n1")
|
|
||||||
<< Macro(PIStringAscii("EVENT3"),
|
<< Macro(PIStringAscii("EVENT3"),
|
||||||
"void name(a0 n0, a1 n1, a2 n2);",
|
"void name(a0 n0, a1 n1, a2 n2);",
|
||||||
PIStringList() << "name"
|
PIStringList() << "name" << "a0" << "n0" << "a1" << "n1" << "a2" << "n2")
|
||||||
<< "a0"
|
|
||||||
<< "n0"
|
|
||||||
<< "a1"
|
|
||||||
<< "n1"
|
|
||||||
<< "a2"
|
|
||||||
<< "n2")
|
|
||||||
<< Macro(PIStringAscii("EVENT4"),
|
<< Macro(PIStringAscii("EVENT4"),
|
||||||
"void name(a0 n0, a1 n1, a2 n2, a3 n3);",
|
"void name(a0 n0, a1 n1, a2 n2, a3 n3);",
|
||||||
PIStringList() << "name"
|
PIStringList() << "name" << "a0" << "n0" << "a1" << "n1" << "a2" << "n2" << "a3" << "n3")
|
||||||
<< "a0"
|
|
||||||
<< "n0"
|
|
||||||
<< "a1"
|
|
||||||
<< "n1"
|
|
||||||
<< "a2"
|
|
||||||
<< "n2"
|
|
||||||
<< "a3"
|
|
||||||
<< "n3")
|
|
||||||
|
|
||||||
<< Macro(PIStringAscii("EVENT_HANDLER"),
|
<< Macro(PIStringAscii("EVENT_HANDLER"), "ret name()", PIStringList() << "ret" << "name")
|
||||||
"ret name()",
|
<< Macro(PIStringAscii("EVENT_HANDLER0"), "ret name()", PIStringList() << "ret" << "name")
|
||||||
PIStringList() << "ret"
|
<< Macro(PIStringAscii("EVENT_HANDLER1"), "ret name(a0 n0)", PIStringList() << "ret" << "name" << "a0" << "n0")
|
||||||
<< "name")
|
|
||||||
<< Macro(PIStringAscii("EVENT_HANDLER0"),
|
|
||||||
"ret name()",
|
|
||||||
PIStringList() << "ret"
|
|
||||||
<< "name")
|
|
||||||
<< Macro(PIStringAscii("EVENT_HANDLER1"),
|
|
||||||
"ret name(a0 n0)",
|
|
||||||
PIStringList() << "ret"
|
|
||||||
<< "name"
|
|
||||||
<< "a0"
|
|
||||||
<< "n0")
|
|
||||||
<< Macro(PIStringAscii("EVENT_HANDLER2"),
|
<< Macro(PIStringAscii("EVENT_HANDLER2"),
|
||||||
"ret name(a0 n0, a1 n1)",
|
"ret name(a0 n0, a1 n1)",
|
||||||
PIStringList() << "ret"
|
PIStringList() << "ret" << "name" << "a0" << "n0" << "a1" << "n1")
|
||||||
<< "name"
|
|
||||||
<< "a0"
|
|
||||||
<< "n0"
|
|
||||||
<< "a1"
|
|
||||||
<< "n1")
|
|
||||||
<< Macro(PIStringAscii("EVENT_HANDLER3"),
|
<< Macro(PIStringAscii("EVENT_HANDLER3"),
|
||||||
"ret name(a0 n0, a1 n1, a2 n2)",
|
"ret name(a0 n0, a1 n1, a2 n2)",
|
||||||
PIStringList() << "ret"
|
PIStringList() << "ret" << "name" << "a0" << "n0" << "a1" << "n1" << "a2" << "n2")
|
||||||
<< "name"
|
|
||||||
<< "a0"
|
|
||||||
<< "n0"
|
|
||||||
<< "a1"
|
|
||||||
<< "n1"
|
|
||||||
<< "a2"
|
|
||||||
<< "n2")
|
|
||||||
<< Macro(PIStringAscii("EVENT_HANDLER4"),
|
<< Macro(PIStringAscii("EVENT_HANDLER4"),
|
||||||
"ret name(a0 n0, a1 n1, a2 n2, a3 n3)",
|
"ret name(a0 n0, a1 n1, a2 n2, a3 n3)",
|
||||||
PIStringList() << "ret"
|
PIStringList() << "ret" << "name" << "a0" << "n0" << "a1" << "n1" << "a2" << "n2" << "a3" << "n3")
|
||||||
<< "name"
|
|
||||||
<< "a0"
|
|
||||||
<< "n0"
|
|
||||||
<< "a1"
|
|
||||||
<< "n1"
|
|
||||||
<< "a2"
|
|
||||||
<< "n2"
|
|
||||||
<< "a3"
|
|
||||||
<< "n3")
|
|
||||||
|
|
||||||
<< Macro(PIStringAscii("EVENT_VHANDLER"),
|
<< Macro(PIStringAscii("EVENT_VHANDLER"), "virtual ret name()", PIStringList() << "ret" << "name")
|
||||||
"virtual ret name()",
|
<< Macro(PIStringAscii("EVENT_VHANDLER0"), "virtual ret name()", PIStringList() << "ret" << "name")
|
||||||
PIStringList() << "ret"
|
<< Macro(PIStringAscii("EVENT_VHANDLER1"), "virtual ret name(a0 n0)", PIStringList() << "ret" << "name" << "a0" << "n0")
|
||||||
<< "name")
|
|
||||||
<< Macro(PIStringAscii("EVENT_VHANDLER0"),
|
|
||||||
"virtual ret name()",
|
|
||||||
PIStringList() << "ret"
|
|
||||||
<< "name")
|
|
||||||
<< Macro(PIStringAscii("EVENT_VHANDLER1"),
|
|
||||||
"virtual ret name(a0 n0)",
|
|
||||||
PIStringList() << "ret"
|
|
||||||
<< "name"
|
|
||||||
<< "a0"
|
|
||||||
<< "n0")
|
|
||||||
<< Macro(PIStringAscii("EVENT_VHANDLER2"),
|
<< Macro(PIStringAscii("EVENT_VHANDLER2"),
|
||||||
"virtual ret name(a0 n0, a1 n1)",
|
"virtual ret name(a0 n0, a1 n1)",
|
||||||
PIStringList() << "ret"
|
PIStringList() << "ret" << "name" << "a0" << "n0" << "a1" << "n1")
|
||||||
<< "name"
|
|
||||||
<< "a0"
|
|
||||||
<< "n0"
|
|
||||||
<< "a1"
|
|
||||||
<< "n1")
|
|
||||||
<< Macro(PIStringAscii("EVENT_VHANDLER3"),
|
<< Macro(PIStringAscii("EVENT_VHANDLER3"),
|
||||||
"virtual ret name(a0 n0, a1 n1, a2 n2)",
|
"virtual ret name(a0 n0, a1 n1, a2 n2)",
|
||||||
PIStringList() << "ret"
|
PIStringList() << "ret" << "name" << "a0" << "n0" << "a1" << "n1" << "a2" << "n2")
|
||||||
<< "name"
|
|
||||||
<< "a0"
|
|
||||||
<< "n0"
|
|
||||||
<< "a1"
|
|
||||||
<< "n1"
|
|
||||||
<< "a2"
|
|
||||||
<< "n2")
|
|
||||||
<< Macro(PIStringAscii("EVENT_VHANDLER4"),
|
<< Macro(PIStringAscii("EVENT_VHANDLER4"),
|
||||||
"virtual ret name(a0 n0, a1 n1, a2 n2, a3 n3)",
|
"virtual ret name(a0 n0, a1 n1, a2 n2, a3 n3)",
|
||||||
PIStringList() << "ret"
|
PIStringList() << "ret" << "name" << "a0" << "n0" << "a1" << "n1" << "a2" << "n2" << "a3" << "n3");
|
||||||
<< "name"
|
|
||||||
<< "a0"
|
|
||||||
<< "n0"
|
|
||||||
<< "a1"
|
|
||||||
<< "n1"
|
|
||||||
<< "a2"
|
|
||||||
<< "n2"
|
|
||||||
<< "a3"
|
|
||||||
<< "n3");
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -122,7 +122,7 @@ const PIKbdListener::EscSeq PIKbdListener::esc_seq[] = {
|
|||||||
{"[23~", PIKbdListener::F11, 0, vt_all, 0},
|
{"[23~", PIKbdListener::F11, 0, vt_all, 0},
|
||||||
{"O[", PIKbdListener::F12, 0, 0, 0},
|
{"O[", PIKbdListener::F12, 0, 0, 0},
|
||||||
{"[24~", PIKbdListener::F12, 0, vt_all, 0},
|
{"[24~", PIKbdListener::F12, 0, vt_all, 0},
|
||||||
// End
|
// End
|
||||||
{0, 0, 0, 0, 0},
|
{0, 0, 0, 0, 0},
|
||||||
};
|
};
|
||||||
void setupTerminal(bool on) {
|
void setupTerminal(bool on) {
|
||||||
|
|||||||
@@ -36,12 +36,12 @@
|
|||||||
//! \~\brief
|
//! \~\brief
|
||||||
//! \~english Waits until the active listener captures the configured exit key and then stops it.
|
//! \~english Waits until the active listener captures the configured exit key and then stops it.
|
||||||
//! \~russian Ожидает, пока активный слушатель перехватит настроенную клавишу выхода, и затем останавливает его.
|
//! \~russian Ожидает, пока активный слушатель перехватит настроенную клавишу выхода, и затем останавливает его.
|
||||||
# define WAIT_FOR_EXIT \
|
# define WAIT_FOR_EXIT \
|
||||||
while (!PIKbdListener::exiting) \
|
while (!PIKbdListener::exiting) \
|
||||||
piMSleep(PIP_MIN_MSLEEP * 5); \
|
piMSleep(PIP_MIN_MSLEEP * 5); \
|
||||||
if (PIKbdListener::instance()) { \
|
if (PIKbdListener::instance()) { \
|
||||||
if (!PIKbdListener::instance()->stopAndWait(PISystemTime::fromSeconds(1))) PIKbdListener::instance()->terminate(); \
|
if (!PIKbdListener::instance()->stopAndWait(PISystemTime::fromSeconds(1))) PIKbdListener::instance()->terminate(); \
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
//! \~\ingroup Console
|
//! \~\ingroup Console
|
||||||
|
|||||||
@@ -52,7 +52,7 @@ enum Color {
|
|||||||
Yellow /** \~english Yellow \~russian Желтый */,
|
Yellow /** \~english Yellow \~russian Желтый */,
|
||||||
White /** \~english White \~russian Белый */,
|
White /** \~english White \~russian Белый */,
|
||||||
Transparent /** \~english Preserve the background already stored in the target cell \~russian Сохранить фон, уже записанный в целевой
|
Transparent /** \~english Preserve the background already stored in the target cell \~russian Сохранить фон, уже записанный в целевой
|
||||||
ячейке */
|
ячейке */
|
||||||
};
|
};
|
||||||
|
|
||||||
//! \~english Character formatting flags.
|
//! \~english Character formatting flags.
|
||||||
@@ -61,7 +61,7 @@ enum CharFlag {
|
|||||||
Bold = 0x1 /** \~english Bold or bright text \~russian Жирный или яркий текст */,
|
Bold = 0x1 /** \~english Bold or bright text \~russian Жирный или яркий текст */,
|
||||||
Blink = 0x2 /** \~english Blinking text \~russian Мигание текста */,
|
Blink = 0x2 /** \~english Blinking text \~russian Мигание текста */,
|
||||||
Underline = 0x4 /** \~english Underlined text \~russian Подчеркнутый текст */,
|
Underline = 0x4 /** \~english Underlined text \~russian Подчеркнутый текст */,
|
||||||
Inverse = 0x08 /** \~english Inverted foreground and background \~russian Инвертированные цвета текста и фона */
|
Inverse = 0x08 /** \~english Inverted foreground and background \~russian Инвертированные цвета текста и фона */
|
||||||
};
|
};
|
||||||
|
|
||||||
//! \~english Horizontal text alignment inside a tile.
|
//! \~english Horizontal text alignment inside a tile.
|
||||||
@@ -77,13 +77,13 @@ enum Alignment {
|
|||||||
enum SizePolicy {
|
enum SizePolicy {
|
||||||
Fixed /** \~english Keep the requested size \~russian Сохранять запрошенный размер */,
|
Fixed /** \~english Keep the requested size \~russian Сохранять запрошенный размер */,
|
||||||
Preferred /** \~english Use preferred size first and share extra space after fixed tiles \~russian Сначала использовать предпочтительный
|
Preferred /** \~english Use preferred size first and share extra space after fixed tiles \~russian Сначала использовать предпочтительный
|
||||||
размер и затем делить свободное место после фиксированных тайлов */
|
размер и затем делить свободное место после фиксированных тайлов */
|
||||||
,
|
,
|
||||||
Expanding /** \~english Take extra space before preferred tiles when the parent can grow children \~russian Получать дополнительное
|
Expanding /** \~english Take extra space before preferred tiles when the parent can grow children \~russian Получать дополнительное
|
||||||
пространство раньше тайлов с предпочтительным размером, если родитель может расширять дочерние элементы */
|
пространство раньше тайлов с предпочтительным размером, если родитель может расширять дочерние элементы */
|
||||||
,
|
,
|
||||||
Ignore /** \~english Skip automatic layout; geometry must be managed manually \~russian Не участвовать в автоматической компоновке;
|
Ignore /** \~english Skip automatic layout; geometry must be managed manually \~russian Не участвовать в автоматической компоновке;
|
||||||
геометрию нужно задавать вручную */
|
геометрию нужно задавать вручную */
|
||||||
};
|
};
|
||||||
|
|
||||||
//! \~english Child layout direction.
|
//! \~english Child layout direction.
|
||||||
@@ -96,16 +96,16 @@ enum Direction {
|
|||||||
//! \~english Focus and navigation flags for tiles.
|
//! \~english Focus and navigation flags for tiles.
|
||||||
//! \~russian Флаги фокуса и навигации для тайлов.
|
//! \~russian Флаги фокуса и навигации для тайлов.
|
||||||
enum FocusFlag {
|
enum FocusFlag {
|
||||||
CanHasFocus = 0x1 /** \~english Tile can receive focus \~russian Тайл может получать фокус */,
|
CanHasFocus = 0x1 /** \~english Tile can receive focus \~russian Тайл может получать фокус */,
|
||||||
NextByTab = 0x2 /** \~english Tab moves focus to the next tile \~russian Клавиша Tab переводит фокус к следующему тайлу */,
|
NextByTab = 0x2 /** \~english Tab moves focus to the next tile \~russian Клавиша Tab переводит фокус к следующему тайлу */,
|
||||||
NextByArrowsHorizontal = 0x4 /** \~english Left and right arrows move focus \~russian Стрелки влево и вправо переводят фокус */,
|
NextByArrowsHorizontal = 0x4 /** \~english Left and right arrows move focus \~russian Стрелки влево и вправо переводят фокус */,
|
||||||
NextByArrowsVertical = 0x8 /** \~english Up and down arrows move focus \~russian Стрелки вверх и вниз переводят фокус */,
|
NextByArrowsVertical = 0x8 /** \~english Up and down arrows move focus \~russian Стрелки вверх и вниз переводят фокус */,
|
||||||
NextByArrowsAll /** \~english Any arrow key moves focus \~russian Любая стрелка переводит фокус */ =
|
NextByArrowsAll /** \~english Any arrow key moves focus \~russian Любая стрелка переводит фокус */ =
|
||||||
NextByArrowsHorizontal | NextByArrowsVertical,
|
NextByArrowsHorizontal | NextByArrowsVertical,
|
||||||
FocusOnMouse = 0x10 /** \~english Mouse press gives focus to the tile \~russian Нажатие мышью переводит фокус на тайл */,
|
FocusOnMouse = 0x10 /** \~english Mouse press gives focus to the tile \~russian Нажатие мышью переводит фокус на тайл */,
|
||||||
FocusOnWheel = 0x20 /** \~english Mouse wheel gives focus to the tile \~russian Колесо мыши переводит фокус на тайл */,
|
FocusOnWheel = 0x20 /** \~english Mouse wheel gives focus to the tile \~russian Колесо мыши переводит фокус на тайл */,
|
||||||
FocusOnMouseOrWheel /** \~english Mouse press or wheel gives focus to the tile \~russian Нажатие мышью или колесо переводят фокус на
|
FocusOnMouseOrWheel /** \~english Mouse press or wheel gives focus to the tile \~russian Нажатие мышью или колесо переводят фокус на
|
||||||
тайл */
|
тайл */
|
||||||
= FocusOnMouse | FocusOnWheel
|
= FocusOnMouse | FocusOnWheel
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|||||||
@@ -1234,7 +1234,10 @@ public:
|
|||||||
//! \~english The function can modify the elements.
|
//! \~english The function can modify the elements.
|
||||||
//! \~russian Функция может изменять элементы.
|
//! \~russian Функция может изменять элементы.
|
||||||
//! \~\sa forEach (read-only), PIVector::forEach()
|
//! \~\sa forEach (read-only), PIVector::forEach()
|
||||||
inline PIVector2D<T> & forEach(std::function<void(T &)> func) { mat.forEach(func); return *this; }
|
inline PIVector2D<T> & forEach(std::function<void(T &)> func) {
|
||||||
|
mat.forEach(func);
|
||||||
|
return *this;
|
||||||
|
}
|
||||||
|
|
||||||
//! \~english Applies a function to each element and returns a new 2D array of a different type.
|
//! \~english Applies a function to each element and returns a new 2D array of a different type.
|
||||||
//! \~russian Применяет функцию к каждому элементу и возвращает новый двумерный массив другого типа.
|
//! \~russian Применяет функцию к каждому элементу и возвращает новый двумерный массив другого типа.
|
||||||
|
|||||||
@@ -727,6 +727,7 @@ inline bool piDeleteSafety(T *& pointer) {
|
|||||||
//! \~russian В данном примере будет выведен "Error!" при каждом \b false возврате из функции.
|
//! \~russian В данном примере будет выведен "Error!" при каждом \b false возврате из функции.
|
||||||
class PIP_EXPORT PIScopeExitCall {
|
class PIP_EXPORT PIScopeExitCall {
|
||||||
NO_COPY_CLASS(PIScopeExitCall)
|
NO_COPY_CLASS(PIScopeExitCall)
|
||||||
|
|
||||||
public:
|
public:
|
||||||
//! \~\brief
|
//! \~\brief
|
||||||
//! \~english Constructor that takes a function to execute
|
//! \~english Constructor that takes a function to execute
|
||||||
@@ -767,14 +768,14 @@ private:
|
|||||||
//! \~english Inherit from this class to make your class non-trivially copyable.
|
//! \~english Inherit from this class to make your class non-trivially copyable.
|
||||||
//! \~russian Наследуйтесь от этого класса чтобы сделать свой класс нетривиально копируемым.
|
//! \~russian Наследуйтесь от этого класса чтобы сделать свой класс нетривиально копируемым.
|
||||||
struct PIP_EXPORT PINonTriviallyCopyable {
|
struct PIP_EXPORT PINonTriviallyCopyable {
|
||||||
PINonTriviallyCopyable() = default;
|
PINonTriviallyCopyable() = default;
|
||||||
PINonTriviallyCopyable(const PINonTriviallyCopyable &) = default;
|
PINonTriviallyCopyable(const PINonTriviallyCopyable &) = default;
|
||||||
PINonTriviallyCopyable(PINonTriviallyCopyable &&) ;
|
PINonTriviallyCopyable(PINonTriviallyCopyable &&);
|
||||||
PINonTriviallyCopyable & operator=(const PINonTriviallyCopyable &) = default;
|
PINonTriviallyCopyable & operator=(const PINonTriviallyCopyable &) = default;
|
||||||
PINonTriviallyCopyable & operator=(PINonTriviallyCopyable &&) = default;
|
PINonTriviallyCopyable & operator=(PINonTriviallyCopyable &&) = default;
|
||||||
~PINonTriviallyCopyable() = default;
|
~PINonTriviallyCopyable() = default;
|
||||||
};
|
};
|
||||||
inline PINonTriviallyCopyable::PINonTriviallyCopyable(PINonTriviallyCopyable &&) = default;
|
inline PINonTriviallyCopyable::PINonTriviallyCopyable(PINonTriviallyCopyable &&) = default;
|
||||||
|
|
||||||
|
|
||||||
//! \~\brief
|
//! \~\brief
|
||||||
|
|||||||
+25
-25
@@ -409,32 +409,32 @@ void PICout::writeChar(char c) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
#define PIINTCOUT(v) \
|
#define PIINTCOUT(v) \
|
||||||
{ \
|
{ \
|
||||||
if (!actve_) return *this; \
|
if (!actve_) return *this; \
|
||||||
space(); \
|
space(); \
|
||||||
if (int_base_ == 10) { \
|
if (int_base_ == 10) { \
|
||||||
if (buffer_) { \
|
if (buffer_) { \
|
||||||
(*buffer_) += PIString::fromNumber(v); \
|
(*buffer_) += PIString::fromNumber(v); \
|
||||||
} else { \
|
} else { \
|
||||||
if (isOutputDeviceActive(Console)) getStdStream(stream_) << (v); \
|
if (isOutputDeviceActive(Console)) getStdStream(stream_) << (v); \
|
||||||
if (isOutputDeviceActive(Buffer)) PICout::__string__() += PIString::fromNumber(v); \
|
if (isOutputDeviceActive(Buffer)) PICout::__string__() += PIString::fromNumber(v); \
|
||||||
} \
|
} \
|
||||||
} else \
|
} else \
|
||||||
write(PIString::fromNumber(v, int_base_)); \
|
write(PIString::fromNumber(v, int_base_)); \
|
||||||
return *this; \
|
return *this; \
|
||||||
}
|
}
|
||||||
|
|
||||||
#define PIFLOATCOUT(v) \
|
#define PIFLOATCOUT(v) \
|
||||||
{ \
|
{ \
|
||||||
if (buffer_) { \
|
if (buffer_) { \
|
||||||
(*buffer_) += PIString::fromNumber(v, 'g'); \
|
(*buffer_) += PIString::fromNumber(v, 'g'); \
|
||||||
} else { \
|
} else { \
|
||||||
if (isOutputDeviceActive(Console)) getStdStream(stream_) << (v); \
|
if (isOutputDeviceActive(Console)) getStdStream(stream_) << (v); \
|
||||||
if (isOutputDeviceActive(Buffer)) PICout::__string__() += PIString::fromNumber(v, 'g'); \
|
if (isOutputDeviceActive(Buffer)) PICout::__string__() += PIString::fromNumber(v, 'g'); \
|
||||||
} \
|
} \
|
||||||
} \
|
} \
|
||||||
return *this;
|
return *this;
|
||||||
|
|
||||||
|
|
||||||
PICout & PICout::operator<<(const PIString & v) {
|
PICout & PICout::operator<<(const PIString & v) {
|
||||||
|
|||||||
@@ -51,13 +51,13 @@
|
|||||||
|
|
||||||
#else
|
#else
|
||||||
# define piCout PICout(piDebug, PICoutStdStream::StdOut)
|
# define piCout PICout(piDebug, PICoutStdStream::StdOut)
|
||||||
# define piCoutObj \
|
# define piCoutObj \
|
||||||
PICout(piDebug && debug(), PICoutStdStream::StdOut) \
|
PICout(piDebug && debug(), PICoutStdStream::StdOut) \
|
||||||
<< (PIStringAscii("[") + className() + (name().isEmpty() ? "]" : PIStringAscii(" \"") + name() + PIStringAscii("\"]")))
|
<< (PIStringAscii("[") + className() + (name().isEmpty() ? "]" : PIStringAscii(" \"") + name() + PIStringAscii("\"]")))
|
||||||
# define piCerr PICout(piDebug, PICoutStdStream::StdErr)
|
# define piCerr PICout(piDebug, PICoutStdStream::StdErr)
|
||||||
# define piCerrObj \
|
# define piCerrObj \
|
||||||
PICout(piDebug && debug(), PICoutStdStream::StdErr) \
|
PICout(piDebug && debug(), PICoutStdStream::StdErr) \
|
||||||
<< (PIStringAscii("[") + className() + (name().isEmpty() ? "]" : PIStringAscii(" \"") + name() + PIStringAscii("\"]")))
|
<< (PIStringAscii("[") + className() + (name().isEmpty() ? "]" : PIStringAscii(" \"") + name() + PIStringAscii("\"]")))
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -33,7 +33,6 @@
|
|||||||
#define PIMEMORYBLOCK_H
|
#define PIMEMORYBLOCK_H
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
//! \~\brief
|
//! \~\brief
|
||||||
//! \~english Helper struct to store and restore custom blocks of data to/from PIBinaryStream
|
//! \~english Helper struct to store and restore custom blocks of data to/from PIBinaryStream
|
||||||
//! \~russian Вспомогательная структура для сохранения и извлечения произвольных блоков данных в/из PIBinaryStream
|
//! \~russian Вспомогательная структура для сохранения и извлечения произвольных блоков данных в/из PIBinaryStream
|
||||||
|
|||||||
@@ -43,13 +43,13 @@ public:
|
|||||||
enum State {
|
enum State {
|
||||||
NotConnected /** \~english No active authentication session. \~russian Активной сессии аутентификации нет. */,
|
NotConnected /** \~english No active authentication session. \~russian Активной сессии аутентификации нет. */,
|
||||||
AuthProbe /** \~english Initial probe stage with signed peer introduction. \~russian Начальный этап с подписанным представлением
|
AuthProbe /** \~english Initial probe stage with signed peer introduction. \~russian Начальный этап с подписанным представлением
|
||||||
узла. */
|
узла. */
|
||||||
,
|
,
|
||||||
PassRequest /** \~english Password verification stage for unknown peers. \~russian Этап проверки пароля для неизвестных узлов. */,
|
PassRequest /** \~english Password verification stage for unknown peers. \~russian Этап проверки пароля для неизвестных узлов. */,
|
||||||
AuthReply /** \~english Reply with client authentication data. \~russian Ответ с данными аутентификации клиента. */,
|
AuthReply /** \~english Reply with client authentication data. \~russian Ответ с данными аутентификации клиента. */,
|
||||||
KeyExchange /** \~english Session key exchange stage. \~russian Этап обмена сеансовым ключом. */,
|
KeyExchange /** \~english Session key exchange stage. \~russian Этап обмена сеансовым ключом. */,
|
||||||
Connected /** \~english Authentication finished and session key is established. \~russian Аутентификация завершена и сеансовый ключ
|
Connected /** \~english Authentication finished and session key is established. \~russian Аутентификация завершена и сеансовый ключ
|
||||||
установлен. */
|
установлен. */
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -1,20 +1,20 @@
|
|||||||
/*
|
/*
|
||||||
PIP - Platform Independent Primitives
|
PIP - Platform Independent Primitives
|
||||||
Digest algorithms
|
Digest algorithms
|
||||||
Ivan Pelipenko peri4ko@yandex.ru
|
Ivan Pelipenko peri4ko@yandex.ru
|
||||||
|
|
||||||
This program is free software: you can redistribute it and/or modify
|
This program is free software: you can redistribute it and/or modify
|
||||||
it under the terms of the GNU Lesser General Public License as published by
|
it under the terms of the GNU Lesser General Public License as published by
|
||||||
the Free Software Foundation, either version 3 of the License, or
|
the Free Software Foundation, either version 3 of the License, or
|
||||||
(at your option) any later version.
|
(at your option) any later version.
|
||||||
|
|
||||||
This program is distributed in the hope that it will be useful,
|
This program is distributed in the hope that it will be useful,
|
||||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
GNU Lesser General Public License for more details.
|
GNU Lesser General Public License for more details.
|
||||||
|
|
||||||
You should have received a copy of the GNU Lesser General Public License
|
You should have received a copy of the GNU Lesser General Public License
|
||||||
along with this program. If not, see <http://www.gnu.org/licenses/>.
|
along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#include "pidigest.h"
|
#include "pidigest.h"
|
||||||
|
|||||||
+13
-13
@@ -4,22 +4,22 @@
|
|||||||
//! \~english Digest calculation helpers
|
//! \~english Digest calculation helpers
|
||||||
//! \~russian Вспомогательные методы вычисления хэш-сумм
|
//! \~russian Вспомогательные методы вычисления хэш-сумм
|
||||||
/*
|
/*
|
||||||
PIP - Platform Independent Primitives
|
PIP - Platform Independent Primitives
|
||||||
Digest algorithms
|
Digest algorithms
|
||||||
Ivan Pelipenko peri4ko@yandex.ru
|
Ivan Pelipenko peri4ko@yandex.ru
|
||||||
|
|
||||||
This program is free software: you can redistribute it and/or modify
|
This program is free software: you can redistribute it and/or modify
|
||||||
it under the terms of the GNU Lesser General Public License as published by
|
it under the terms of the GNU Lesser General Public License as published by
|
||||||
the Free Software Foundation, either version 3 of the License, or
|
the Free Software Foundation, either version 3 of the License, or
|
||||||
(at your option) any later version.
|
(at your option) any later version.
|
||||||
|
|
||||||
This program is distributed in the hope that it will be useful,
|
This program is distributed in the hope that it will be useful,
|
||||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
GNU Lesser General Public License for more details.
|
GNU Lesser General Public License for more details.
|
||||||
|
|
||||||
You should have received a copy of the GNU Lesser General Public License
|
You should have received a copy of the GNU Lesser General Public License
|
||||||
along with this program. If not, see <http://www.gnu.org/licenses/>.
|
along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#ifndef pidigest_h
|
#ifndef pidigest_h
|
||||||
|
|||||||
@@ -1,20 +1,20 @@
|
|||||||
/*
|
/*
|
||||||
PIP - Platform Independent Primitives
|
PIP - Platform Independent Primitives
|
||||||
Digest algorithms
|
Digest algorithms
|
||||||
Ivan Pelipenko peri4ko@yandex.ru
|
Ivan Pelipenko peri4ko@yandex.ru
|
||||||
|
|
||||||
This program is free software: you can redistribute it and/or modify
|
This program is free software: you can redistribute it and/or modify
|
||||||
it under the terms of the GNU Lesser General Public License as published by
|
it under the terms of the GNU Lesser General Public License as published by
|
||||||
the Free Software Foundation, either version 3 of the License, or
|
the Free Software Foundation, either version 3 of the License, or
|
||||||
(at your option) any later version.
|
(at your option) any later version.
|
||||||
|
|
||||||
This program is distributed in the hope that it will be useful,
|
This program is distributed in the hope that it will be useful,
|
||||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
GNU Lesser General Public License for more details.
|
GNU Lesser General Public License for more details.
|
||||||
|
|
||||||
You should have received a copy of the GNU Lesser General Public License
|
You should have received a copy of the GNU Lesser General Public License
|
||||||
along with this program. If not, see <http://www.gnu.org/licenses/>.
|
along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#include "pidigest_blake2_p.h"
|
#include "pidigest_blake2_p.h"
|
||||||
|
|||||||
@@ -1,20 +1,20 @@
|
|||||||
/*
|
/*
|
||||||
PIP - Platform Independent Primitives
|
PIP - Platform Independent Primitives
|
||||||
Digest algorithms
|
Digest algorithms
|
||||||
Ivan Pelipenko peri4ko@yandex.ru
|
Ivan Pelipenko peri4ko@yandex.ru
|
||||||
|
|
||||||
This program is free software: you can redistribute it and/or modify
|
This program is free software: you can redistribute it and/or modify
|
||||||
it under the terms of the GNU Lesser General Public License as published by
|
it under the terms of the GNU Lesser General Public License as published by
|
||||||
the Free Software Foundation, either version 3 of the License, or
|
the Free Software Foundation, either version 3 of the License, or
|
||||||
(at your option) any later version.
|
(at your option) any later version.
|
||||||
|
|
||||||
This program is distributed in the hope that it will be useful,
|
This program is distributed in the hope that it will be useful,
|
||||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
GNU Lesser General Public License for more details.
|
GNU Lesser General Public License for more details.
|
||||||
|
|
||||||
You should have received a copy of the GNU Lesser General Public License
|
You should have received a copy of the GNU Lesser General Public License
|
||||||
along with this program. If not, see <http://www.gnu.org/licenses/>.
|
along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#ifndef pidigest_blake2_h
|
#ifndef pidigest_blake2_h
|
||||||
|
|||||||
@@ -1,20 +1,20 @@
|
|||||||
/*
|
/*
|
||||||
PIP - Platform Independent Primitives
|
PIP - Platform Independent Primitives
|
||||||
Digest algorithms
|
Digest algorithms
|
||||||
Ivan Pelipenko peri4ko@yandex.ru
|
Ivan Pelipenko peri4ko@yandex.ru
|
||||||
|
|
||||||
This program is free software: you can redistribute it and/or modify
|
This program is free software: you can redistribute it and/or modify
|
||||||
it under the terms of the GNU Lesser General Public License as published by
|
it under the terms of the GNU Lesser General Public License as published by
|
||||||
the Free Software Foundation, either version 3 of the License, or
|
the Free Software Foundation, either version 3 of the License, or
|
||||||
(at your option) any later version.
|
(at your option) any later version.
|
||||||
|
|
||||||
This program is distributed in the hope that it will be useful,
|
This program is distributed in the hope that it will be useful,
|
||||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
GNU Lesser General Public License for more details.
|
GNU Lesser General Public License for more details.
|
||||||
|
|
||||||
You should have received a copy of the GNU Lesser General Public License
|
You should have received a copy of the GNU Lesser General Public License
|
||||||
along with this program. If not, see <http://www.gnu.org/licenses/>.
|
along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#include "pidigest_md2_p.h"
|
#include "pidigest_md2_p.h"
|
||||||
|
|||||||
@@ -1,20 +1,20 @@
|
|||||||
/*
|
/*
|
||||||
PIP - Platform Independent Primitives
|
PIP - Platform Independent Primitives
|
||||||
Digest algorithms
|
Digest algorithms
|
||||||
Ivan Pelipenko peri4ko@yandex.ru
|
Ivan Pelipenko peri4ko@yandex.ru
|
||||||
|
|
||||||
This program is free software: you can redistribute it and/or modify
|
This program is free software: you can redistribute it and/or modify
|
||||||
it under the terms of the GNU Lesser General Public License as published by
|
it under the terms of the GNU Lesser General Public License as published by
|
||||||
the Free Software Foundation, either version 3 of the License, or
|
the Free Software Foundation, either version 3 of the License, or
|
||||||
(at your option) any later version.
|
(at your option) any later version.
|
||||||
|
|
||||||
This program is distributed in the hope that it will be useful,
|
This program is distributed in the hope that it will be useful,
|
||||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
GNU Lesser General Public License for more details.
|
GNU Lesser General Public License for more details.
|
||||||
|
|
||||||
You should have received a copy of the GNU Lesser General Public License
|
You should have received a copy of the GNU Lesser General Public License
|
||||||
along with this program. If not, see <http://www.gnu.org/licenses/>.
|
along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#ifndef pidigest_md2_h
|
#ifndef pidigest_md2_h
|
||||||
|
|||||||
@@ -1,20 +1,20 @@
|
|||||||
/*
|
/*
|
||||||
PIP - Platform Independent Primitives
|
PIP - Platform Independent Primitives
|
||||||
Digest algorithms
|
Digest algorithms
|
||||||
Ivan Pelipenko peri4ko@yandex.ru
|
Ivan Pelipenko peri4ko@yandex.ru
|
||||||
|
|
||||||
This program is free software: you can redistribute it and/or modify
|
This program is free software: you can redistribute it and/or modify
|
||||||
it under the terms of the GNU Lesser General Public License as published by
|
it under the terms of the GNU Lesser General Public License as published by
|
||||||
the Free Software Foundation, either version 3 of the License, or
|
the Free Software Foundation, either version 3 of the License, or
|
||||||
(at your option) any later version.
|
(at your option) any later version.
|
||||||
|
|
||||||
This program is distributed in the hope that it will be useful,
|
This program is distributed in the hope that it will be useful,
|
||||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
GNU Lesser General Public License for more details.
|
GNU Lesser General Public License for more details.
|
||||||
|
|
||||||
You should have received a copy of the GNU Lesser General Public License
|
You should have received a copy of the GNU Lesser General Public License
|
||||||
along with this program. If not, see <http://www.gnu.org/licenses/>.
|
along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#include "pidigest_md4_p.h"
|
#include "pidigest_md4_p.h"
|
||||||
|
|||||||
@@ -1,20 +1,20 @@
|
|||||||
/*
|
/*
|
||||||
PIP - Platform Independent Primitives
|
PIP - Platform Independent Primitives
|
||||||
Digest algorithms
|
Digest algorithms
|
||||||
Ivan Pelipenko peri4ko@yandex.ru
|
Ivan Pelipenko peri4ko@yandex.ru
|
||||||
|
|
||||||
This program is free software: you can redistribute it and/or modify
|
This program is free software: you can redistribute it and/or modify
|
||||||
it under the terms of the GNU Lesser General Public License as published by
|
it under the terms of the GNU Lesser General Public License as published by
|
||||||
the Free Software Foundation, either version 3 of the License, or
|
the Free Software Foundation, either version 3 of the License, or
|
||||||
(at your option) any later version.
|
(at your option) any later version.
|
||||||
|
|
||||||
This program is distributed in the hope that it will be useful,
|
This program is distributed in the hope that it will be useful,
|
||||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
GNU Lesser General Public License for more details.
|
GNU Lesser General Public License for more details.
|
||||||
|
|
||||||
You should have received a copy of the GNU Lesser General Public License
|
You should have received a copy of the GNU Lesser General Public License
|
||||||
along with this program. If not, see <http://www.gnu.org/licenses/>.
|
along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#ifndef pidigest_md4_h
|
#ifndef pidigest_md4_h
|
||||||
|
|||||||
@@ -1,20 +1,20 @@
|
|||||||
/*
|
/*
|
||||||
PIP - Platform Independent Primitives
|
PIP - Platform Independent Primitives
|
||||||
Digest algorithms
|
Digest algorithms
|
||||||
Ivan Pelipenko peri4ko@yandex.ru
|
Ivan Pelipenko peri4ko@yandex.ru
|
||||||
|
|
||||||
This program is free software: you can redistribute it and/or modify
|
This program is free software: you can redistribute it and/or modify
|
||||||
it under the terms of the GNU Lesser General Public License as published by
|
it under the terms of the GNU Lesser General Public License as published by
|
||||||
the Free Software Foundation, either version 3 of the License, or
|
the Free Software Foundation, either version 3 of the License, or
|
||||||
(at your option) any later version.
|
(at your option) any later version.
|
||||||
|
|
||||||
This program is distributed in the hope that it will be useful,
|
This program is distributed in the hope that it will be useful,
|
||||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
GNU Lesser General Public License for more details.
|
GNU Lesser General Public License for more details.
|
||||||
|
|
||||||
You should have received a copy of the GNU Lesser General Public License
|
You should have received a copy of the GNU Lesser General Public License
|
||||||
along with this program. If not, see <http://www.gnu.org/licenses/>.
|
along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#include "pidigest_md5_p.h"
|
#include "pidigest_md5_p.h"
|
||||||
@@ -36,8 +36,8 @@ PIByteArray MD5::md5(const PIByteArray & in) {
|
|||||||
0xAB9423A7u, 0xFC93A039u, 0x655B59C3u, 0x8F0CCC92u, 0xFFEFF47Du, 0x85845DD1u, 0x6FA87E4Fu, 0xFE2CE6E0u, 0xA3014314u, 0x4E0811A1u,
|
0xAB9423A7u, 0xFC93A039u, 0x655B59C3u, 0x8F0CCC92u, 0xFFEFF47Du, 0x85845DD1u, 0x6FA87E4Fu, 0xFE2CE6E0u, 0xA3014314u, 0x4E0811A1u,
|
||||||
0xF7537E82u, 0xBD3AF235u, 0x2AD7D2BBu, 0xEB86D391u};
|
0xF7537E82u, 0xBD3AF235u, 0x2AD7D2BBu, 0xEB86D391u};
|
||||||
static constexpr uint32_t s[64] = {7, 12, 17, 22, 7, 12, 17, 22, 7, 12, 17, 22, 7, 12, 17, 22, 5, 9, 14, 20, 5, 9,
|
static constexpr uint32_t s[64] = {7, 12, 17, 22, 7, 12, 17, 22, 7, 12, 17, 22, 7, 12, 17, 22, 5, 9, 14, 20, 5, 9,
|
||||||
14, 20, 5, 9, 14, 20, 5, 9, 14, 20, 4, 11, 16, 23, 4, 11, 16, 23, 4, 11, 16, 23,
|
14, 20, 5, 9, 14, 20, 5, 9, 14, 20, 4, 11, 16, 23, 4, 11, 16, 23, 4, 11, 16, 23,
|
||||||
4, 11, 16, 23, 6, 10, 15, 21, 6, 10, 15, 21, 6, 10, 15, 21, 6, 10, 15, 21};
|
4, 11, 16, 23, 6, 10, 15, 21, 6, 10, 15, 21, 6, 10, 15, 21, 6, 10, 15, 21};
|
||||||
|
|
||||||
uint32_t a0 = 0x67452301u;
|
uint32_t a0 = 0x67452301u;
|
||||||
uint32_t b0 = 0xefcdab89u;
|
uint32_t b0 = 0xefcdab89u;
|
||||||
|
|||||||
@@ -1,20 +1,20 @@
|
|||||||
/*
|
/*
|
||||||
PIP - Platform Independent Primitives
|
PIP - Platform Independent Primitives
|
||||||
Digest algorithms
|
Digest algorithms
|
||||||
Ivan Pelipenko peri4ko@yandex.ru
|
Ivan Pelipenko peri4ko@yandex.ru
|
||||||
|
|
||||||
This program is free software: you can redistribute it and/or modify
|
This program is free software: you can redistribute it and/or modify
|
||||||
it under the terms of the GNU Lesser General Public License as published by
|
it under the terms of the GNU Lesser General Public License as published by
|
||||||
the Free Software Foundation, either version 3 of the License, or
|
the Free Software Foundation, either version 3 of the License, or
|
||||||
(at your option) any later version.
|
(at your option) any later version.
|
||||||
|
|
||||||
This program is distributed in the hope that it will be useful,
|
This program is distributed in the hope that it will be useful,
|
||||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
GNU Lesser General Public License for more details.
|
GNU Lesser General Public License for more details.
|
||||||
|
|
||||||
You should have received a copy of the GNU Lesser General Public License
|
You should have received a copy of the GNU Lesser General Public License
|
||||||
along with this program. If not, see <http://www.gnu.org/licenses/>.
|
along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#ifndef pidigest_md5_h
|
#ifndef pidigest_md5_h
|
||||||
|
|||||||
@@ -1,20 +1,20 @@
|
|||||||
/*
|
/*
|
||||||
PIP - Platform Independent Primitives
|
PIP - Platform Independent Primitives
|
||||||
Digest algorithms
|
Digest algorithms
|
||||||
Ivan Pelipenko peri4ko@yandex.ru
|
Ivan Pelipenko peri4ko@yandex.ru
|
||||||
|
|
||||||
This program is free software: you can redistribute it and/or modify
|
This program is free software: you can redistribute it and/or modify
|
||||||
it under the terms of the GNU Lesser General Public License as published by
|
it under the terms of the GNU Lesser General Public License as published by
|
||||||
the Free Software Foundation, either version 3 of the License, or
|
the Free Software Foundation, either version 3 of the License, or
|
||||||
(at your option) any later version.
|
(at your option) any later version.
|
||||||
|
|
||||||
This program is distributed in the hope that it will be useful,
|
This program is distributed in the hope that it will be useful,
|
||||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
GNU Lesser General Public License for more details.
|
GNU Lesser General Public License for more details.
|
||||||
|
|
||||||
You should have received a copy of the GNU Lesser General Public License
|
You should have received a copy of the GNU Lesser General Public License
|
||||||
along with this program. If not, see <http://www.gnu.org/licenses/>.
|
along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#include "pidigest_sha1_p.h"
|
#include "pidigest_sha1_p.h"
|
||||||
|
|||||||
@@ -1,20 +1,20 @@
|
|||||||
/*
|
/*
|
||||||
PIP - Platform Independent Primitives
|
PIP - Platform Independent Primitives
|
||||||
Digest algorithms
|
Digest algorithms
|
||||||
Ivan Pelipenko peri4ko@yandex.ru
|
Ivan Pelipenko peri4ko@yandex.ru
|
||||||
|
|
||||||
This program is free software: you can redistribute it and/or modify
|
This program is free software: you can redistribute it and/or modify
|
||||||
it under the terms of the GNU Lesser General Public License as published by
|
it under the terms of the GNU Lesser General Public License as published by
|
||||||
the Free Software Foundation, either version 3 of the License, or
|
the Free Software Foundation, either version 3 of the License, or
|
||||||
(at your option) any later version.
|
(at your option) any later version.
|
||||||
|
|
||||||
This program is distributed in the hope that it will be useful,
|
This program is distributed in the hope that it will be useful,
|
||||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
GNU Lesser General Public License for more details.
|
GNU Lesser General Public License for more details.
|
||||||
|
|
||||||
You should have received a copy of the GNU Lesser General Public License
|
You should have received a copy of the GNU Lesser General Public License
|
||||||
along with this program. If not, see <http://www.gnu.org/licenses/>.
|
along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#ifndef pidigest_sha1_h
|
#ifndef pidigest_sha1_h
|
||||||
|
|||||||
@@ -1,20 +1,20 @@
|
|||||||
/*
|
/*
|
||||||
PIP - Platform Independent Primitives
|
PIP - Platform Independent Primitives
|
||||||
Digest algorithms
|
Digest algorithms
|
||||||
Ivan Pelipenko peri4ko@yandex.ru
|
Ivan Pelipenko peri4ko@yandex.ru
|
||||||
|
|
||||||
This program is free software: you can redistribute it and/or modify
|
This program is free software: you can redistribute it and/or modify
|
||||||
it under the terms of the GNU Lesser General Public License as published by
|
it under the terms of the GNU Lesser General Public License as published by
|
||||||
the Free Software Foundation, either version 3 of the License, or
|
the Free Software Foundation, either version 3 of the License, or
|
||||||
(at your option) any later version.
|
(at your option) any later version.
|
||||||
|
|
||||||
This program is distributed in the hope that it will be useful,
|
This program is distributed in the hope that it will be useful,
|
||||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
GNU Lesser General Public License for more details.
|
GNU Lesser General Public License for more details.
|
||||||
|
|
||||||
You should have received a copy of the GNU Lesser General Public License
|
You should have received a copy of the GNU Lesser General Public License
|
||||||
along with this program. If not, see <http://www.gnu.org/licenses/>.
|
along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#include "pidigest_sha2_p.h"
|
#include "pidigest_sha2_p.h"
|
||||||
@@ -25,37 +25,37 @@ const uint32_t SHA2::initial_256[8] =
|
|||||||
{0x6A09E667u, 0xBB67AE85u, 0x3C6EF372u, 0xA54FF53Au, 0x510E527Fu, 0x9B05688Cu, 0x1F83D9ABu, 0x5BE0CD19u};
|
{0x6A09E667u, 0xBB67AE85u, 0x3C6EF372u, 0xA54FF53Au, 0x510E527Fu, 0x9B05688Cu, 0x1F83D9ABu, 0x5BE0CD19u};
|
||||||
|
|
||||||
const uint64_t SHA2::initial_384[8] = {0xCBBB9D5DC1059ED8U,
|
const uint64_t SHA2::initial_384[8] = {0xCBBB9D5DC1059ED8U,
|
||||||
0x629A292A367CD507U,
|
0x629A292A367CD507U,
|
||||||
0x9159015A3070DD17U,
|
0x9159015A3070DD17U,
|
||||||
0x152FECD8F70E5939U,
|
0x152FECD8F70E5939U,
|
||||||
0x67332667FFC00B31U,
|
0x67332667FFC00B31U,
|
||||||
0x8EB44A8768581511U,
|
0x8EB44A8768581511U,
|
||||||
0xDB0C2E0D64F98FA7U,
|
0xDB0C2E0D64F98FA7U,
|
||||||
0x47B5481DBEFA4FA4U};
|
0x47B5481DBEFA4FA4U};
|
||||||
const uint64_t SHA2::initial_512[8] = {0X6A09E667F3BCC908U,
|
const uint64_t SHA2::initial_512[8] = {0X6A09E667F3BCC908U,
|
||||||
0XBB67AE8584CAA73BU,
|
0XBB67AE8584CAA73BU,
|
||||||
0X3C6EF372FE94F82BU,
|
0X3C6EF372FE94F82BU,
|
||||||
0XA54FF53A5F1D36F1U,
|
0XA54FF53A5F1D36F1U,
|
||||||
0X510E527FADE682D1U,
|
0X510E527FADE682D1U,
|
||||||
0X9B05688C2B3E6C1FU,
|
0X9B05688C2B3E6C1FU,
|
||||||
0X1F83D9ABFB41BD6BU,
|
0X1F83D9ABFB41BD6BU,
|
||||||
0X5BE0CD19137E2179U};
|
0X5BE0CD19137E2179U};
|
||||||
const uint64_t SHA2::initial_512_256[8] = {0x22312194FC2BF72CU,
|
const uint64_t SHA2::initial_512_256[8] = {0x22312194FC2BF72CU,
|
||||||
0x9F555FA3C84C64C2U,
|
0x9F555FA3C84C64C2U,
|
||||||
0x2393B86B6F53B151U,
|
0x2393B86B6F53B151U,
|
||||||
0x963877195940EABDU,
|
0x963877195940EABDU,
|
||||||
0x96283EE2A88EFFE3U,
|
0x96283EE2A88EFFE3U,
|
||||||
0xBE5E1E2553863992U,
|
0xBE5E1E2553863992U,
|
||||||
0x2B0199FC2C85B8AAU,
|
0x2B0199FC2C85B8AAU,
|
||||||
0x0EB72DDC81C52CA2U};
|
0x0EB72DDC81C52CA2U};
|
||||||
const uint64_t SHA2::initial_512_224[8] = {0x8C3D37C819544DA2U,
|
const uint64_t SHA2::initial_512_224[8] = {0x8C3D37C819544DA2U,
|
||||||
0x73E1996689DCD4D6U,
|
0x73E1996689DCD4D6U,
|
||||||
0x1DFAB7AE32FF9C82U,
|
0x1DFAB7AE32FF9C82U,
|
||||||
0x679DD514582F9FCFU,
|
0x679DD514582F9FCFU,
|
||||||
0x0F6D2B697BD44DA8U,
|
0x0F6D2B697BD44DA8U,
|
||||||
0x77E36F7304C48942U,
|
0x77E36F7304C48942U,
|
||||||
0x3F9D85A86A1D36C8U,
|
0x3F9D85A86A1D36C8U,
|
||||||
0x1112E6AD91D692A1U};
|
0x1112E6AD91D692A1U};
|
||||||
|
|
||||||
template<typename T>
|
template<typename T>
|
||||||
inline T rotate_u(T v, int bits) {
|
inline T rotate_u(T v, int bits) {
|
||||||
|
|||||||
@@ -1,20 +1,20 @@
|
|||||||
/*
|
/*
|
||||||
PIP - Platform Independent Primitives
|
PIP - Platform Independent Primitives
|
||||||
Digest algorithms
|
Digest algorithms
|
||||||
Ivan Pelipenko peri4ko@yandex.ru
|
Ivan Pelipenko peri4ko@yandex.ru
|
||||||
|
|
||||||
This program is free software: you can redistribute it and/or modify
|
This program is free software: you can redistribute it and/or modify
|
||||||
it under the terms of the GNU Lesser General Public License as published by
|
it under the terms of the GNU Lesser General Public License as published by
|
||||||
the Free Software Foundation, either version 3 of the License, or
|
the Free Software Foundation, either version 3 of the License, or
|
||||||
(at your option) any later version.
|
(at your option) any later version.
|
||||||
|
|
||||||
This program is distributed in the hope that it will be useful,
|
This program is distributed in the hope that it will be useful,
|
||||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
GNU Lesser General Public License for more details.
|
GNU Lesser General Public License for more details.
|
||||||
|
|
||||||
You should have received a copy of the GNU Lesser General Public License
|
You should have received a copy of the GNU Lesser General Public License
|
||||||
along with this program. If not, see <http://www.gnu.org/licenses/>.
|
along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#ifndef pidigest_sha2_h
|
#ifndef pidigest_sha2_h
|
||||||
|
|||||||
@@ -1,20 +1,20 @@
|
|||||||
/*
|
/*
|
||||||
PIP - Platform Independent Primitives
|
PIP - Platform Independent Primitives
|
||||||
Digest algorithms
|
Digest algorithms
|
||||||
Ivan Pelipenko peri4ko@yandex.ru
|
Ivan Pelipenko peri4ko@yandex.ru
|
||||||
|
|
||||||
This program is free software: you can redistribute it and/or modify
|
This program is free software: you can redistribute it and/or modify
|
||||||
it under the terms of the GNU Lesser General Public License as published by
|
it under the terms of the GNU Lesser General Public License as published by
|
||||||
the Free Software Foundation, either version 3 of the License, or
|
the Free Software Foundation, either version 3 of the License, or
|
||||||
(at your option) any later version.
|
(at your option) any later version.
|
||||||
|
|
||||||
This program is distributed in the hope that it will be useful,
|
This program is distributed in the hope that it will be useful,
|
||||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
GNU Lesser General Public License for more details.
|
GNU Lesser General Public License for more details.
|
||||||
|
|
||||||
You should have received a copy of the GNU Lesser General Public License
|
You should have received a copy of the GNU Lesser General Public License
|
||||||
along with this program. If not, see <http://www.gnu.org/licenses/>.
|
along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#include "pidigest_siphash_p.h"
|
#include "pidigest_siphash_p.h"
|
||||||
|
|||||||
@@ -1,20 +1,20 @@
|
|||||||
/*
|
/*
|
||||||
PIP - Platform Independent Primitives
|
PIP - Platform Independent Primitives
|
||||||
Digest algorithms
|
Digest algorithms
|
||||||
Ivan Pelipenko peri4ko@yandex.ru
|
Ivan Pelipenko peri4ko@yandex.ru
|
||||||
|
|
||||||
This program is free software: you can redistribute it and/or modify
|
This program is free software: you can redistribute it and/or modify
|
||||||
it under the terms of the GNU Lesser General Public License as published by
|
it under the terms of the GNU Lesser General Public License as published by
|
||||||
the Free Software Foundation, either version 3 of the License, or
|
the Free Software Foundation, either version 3 of the License, or
|
||||||
(at your option) any later version.
|
(at your option) any later version.
|
||||||
|
|
||||||
This program is distributed in the hope that it will be useful,
|
This program is distributed in the hope that it will be useful,
|
||||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
GNU Lesser General Public License for more details.
|
GNU Lesser General Public License for more details.
|
||||||
|
|
||||||
You should have received a copy of the GNU Lesser General Public License
|
You should have received a copy of the GNU Lesser General Public License
|
||||||
along with this program. If not, see <http://www.gnu.org/licenses/>.
|
along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#ifndef pidigest_siphash_h
|
#ifndef pidigest_siphash_h
|
||||||
|
|||||||
@@ -289,7 +289,7 @@ void PIGeoPosition::convertCartesianToGeodetic(const PIMathVectorT3d & xyz, PIMa
|
|||||||
p = sqrt(xyz[0] * xyz[0] + xyz[1] * xyz[1]);
|
p = sqrt(xyz[0] * xyz[0] + xyz[1] * xyz[1]);
|
||||||
if (p < PIGeoPosition::position_tolerance / 5) { // pole or origin
|
if (p < PIGeoPosition::position_tolerance / 5) { // pole or origin
|
||||||
llh[0] = (xyz[2] > 0.0 ? 90.0 : -90.0);
|
llh[0] = (xyz[2] > 0.0 ? 90.0 : -90.0);
|
||||||
llh[1] = 0.0; // lon undefined, really
|
llh[1] = 0.0; // lon undefined, really
|
||||||
llh[2] = piAbsd(xyz[2]) - ell.a * sqrt(1.0 - ell.eccSquared());
|
llh[2] = piAbsd(xyz[2]) - ell.a * sqrt(1.0 - ell.eccSquared());
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -4,22 +4,22 @@
|
|||||||
//! \~english Public HTTP client request API
|
//! \~english Public HTTP client request API
|
||||||
//! \~russian Публичный API HTTP-клиента для выполнения запросов
|
//! \~russian Публичный API HTTP-клиента для выполнения запросов
|
||||||
/*
|
/*
|
||||||
PIP - Platform Independent Primitives
|
PIP - Platform Independent Primitives
|
||||||
Public HTTP client request API
|
Public HTTP client request API
|
||||||
Ivan Pelipenko peri4ko@yandex.ru
|
Ivan Pelipenko peri4ko@yandex.ru
|
||||||
|
|
||||||
This program is free software: you can redistribute it and/or modify
|
This program is free software: you can redistribute it and/or modify
|
||||||
it under the terms of the GNU Lesser General Public License as published by
|
it under the terms of the GNU Lesser General Public License as published by
|
||||||
the Free Software Foundation, either version 3 of the License, or
|
the Free Software Foundation, either version 3 of the License, or
|
||||||
(at your option) any later version.
|
(at your option) any later version.
|
||||||
|
|
||||||
This program is distributed in the hope that it will be useful,
|
This program is distributed in the hope that it will be useful,
|
||||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
GNU Lesser General Public License for more details.
|
GNU Lesser General Public License for more details.
|
||||||
|
|
||||||
You should have received a copy of the GNU Lesser General Public License
|
You should have received a copy of the GNU Lesser General Public License
|
||||||
along with this program. If not, see <http://www.gnu.org/licenses/>.
|
along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#ifndef pihttpclient_h
|
#ifndef pihttpclient_h
|
||||||
|
|||||||
@@ -8,22 +8,22 @@
|
|||||||
//! \~russian Предоставляет классы перечислений для HTTP методов и кодов состояния, а также пространство имён с константами имён HTTP
|
//! \~russian Предоставляет классы перечислений для HTTP методов и кодов состояния, а также пространство имён с константами имён HTTP
|
||||||
//! заголовков.
|
//! заголовков.
|
||||||
/*
|
/*
|
||||||
PIP - Platform Independent Primitives
|
PIP - Platform Independent Primitives
|
||||||
HTTP constants and enumerations
|
HTTP constants and enumerations
|
||||||
Ivan Pelipenko peri4ko@yandex.ru
|
Ivan Pelipenko peri4ko@yandex.ru
|
||||||
|
|
||||||
This program is free software: you can redistribute it and/or modify
|
This program is free software: you can redistribute it and/or modify
|
||||||
it under the terms of the GNU Lesser General Public License as published by
|
it under the terms of the GNU Lesser General Public License as published by
|
||||||
the Free Software Foundation, either version 3 of the License, or
|
the Free Software Foundation, either version 3 of the License, or
|
||||||
(at your option) any later version.
|
(at your option) any later version.
|
||||||
|
|
||||||
This program is distributed in the hope that it will be useful,
|
This program is distributed in the hope that it will be useful,
|
||||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
GNU Lesser General Public License for more details.
|
GNU Lesser General Public License for more details.
|
||||||
|
|
||||||
You should have received a copy of the GNU Lesser General Public License
|
You should have received a copy of the GNU Lesser General Public License
|
||||||
along with this program. If not, see <http://www.gnu.org/licenses/>.
|
along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#ifndef pihttpconstants_h
|
#ifndef pihttpconstants_h
|
||||||
|
|||||||
@@ -4,22 +4,22 @@
|
|||||||
//! \~english Shared HTTP message container types
|
//! \~english Shared HTTP message container types
|
||||||
//! \~russian Общие типы контейнеров HTTP-сообщений
|
//! \~russian Общие типы контейнеров HTTP-сообщений
|
||||||
/*
|
/*
|
||||||
PIP - Platform Independent Primitives
|
PIP - Platform Independent Primitives
|
||||||
Shared HTTP message container types
|
Shared HTTP message container types
|
||||||
Ivan Pelipenko peri4ko@yandex.ru
|
Ivan Pelipenko peri4ko@yandex.ru
|
||||||
|
|
||||||
This program is free software: you can redistribute it and/or modify
|
This program is free software: you can redistribute it and/or modify
|
||||||
it under the terms of the GNU Lesser General Public License as published by
|
it under the terms of the GNU Lesser General Public License as published by
|
||||||
the Free Software Foundation, either version 3 of the License, or
|
the Free Software Foundation, either version 3 of the License, or
|
||||||
(at your option) any later version.
|
(at your option) any later version.
|
||||||
|
|
||||||
This program is distributed in the hope that it will be useful,
|
This program is distributed in the hope that it will be useful,
|
||||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
GNU Lesser General Public License for more details.
|
GNU Lesser General Public License for more details.
|
||||||
|
|
||||||
You should have received a copy of the GNU Lesser General Public License
|
You should have received a copy of the GNU Lesser General Public License
|
||||||
along with this program. If not, see <http://www.gnu.org/licenses/>.
|
along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#ifndef pihttptypes_h
|
#ifndef pihttptypes_h
|
||||||
|
|||||||
@@ -4,22 +4,22 @@
|
|||||||
//! \~english Shared HTTP message container types
|
//! \~english Shared HTTP message container types
|
||||||
//! \~russian Общие типы контейнеров HTTP-сообщений
|
//! \~russian Общие типы контейнеров HTTP-сообщений
|
||||||
/*
|
/*
|
||||||
PIP - Platform Independent Primitives
|
PIP - Platform Independent Primitives
|
||||||
Shared HTTP message container types
|
Shared HTTP message container types
|
||||||
Ivan Pelipenko peri4ko@yandex.ru
|
Ivan Pelipenko peri4ko@yandex.ru
|
||||||
|
|
||||||
This program is free software: you can redistribute it and/or modify
|
This program is free software: you can redistribute it and/or modify
|
||||||
it under the terms of the GNU Lesser General Public License as published by
|
it under the terms of the GNU Lesser General Public License as published by
|
||||||
the Free Software Foundation, either version 3 of the License, or
|
the Free Software Foundation, either version 3 of the License, or
|
||||||
(at your option) any later version.
|
(at your option) any later version.
|
||||||
|
|
||||||
This program is distributed in the hope that it will be useful,
|
This program is distributed in the hope that it will be useful,
|
||||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
GNU Lesser General Public License for more details.
|
GNU Lesser General Public License for more details.
|
||||||
|
|
||||||
You should have received a copy of the GNU Lesser General Public License
|
You should have received a copy of the GNU Lesser General Public License
|
||||||
along with this program. If not, see <http://www.gnu.org/licenses/>.
|
along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#ifndef piserverendpoint_p_h
|
#ifndef piserverendpoint_p_h
|
||||||
|
|||||||
@@ -4,22 +4,22 @@
|
|||||||
//! \~english Base HTTP server API built on top of libmicrohttpd
|
//! \~english Base HTTP server API built on top of libmicrohttpd
|
||||||
//! \~russian Базовый API HTTP-сервера, построенный поверх libmicrohttpd
|
//! \~russian Базовый API HTTP-сервера, построенный поверх libmicrohttpd
|
||||||
/*
|
/*
|
||||||
PIP - Platform Independent Primitives
|
PIP - Platform Independent Primitives
|
||||||
Base HTTP server API built on top of libmicrohttpd
|
Base HTTP server API built on top of libmicrohttpd
|
||||||
Ivan Pelipenko peri4ko@yandex.ru
|
Ivan Pelipenko peri4ko@yandex.ru
|
||||||
|
|
||||||
This program is free software: you can redistribute it and/or modify
|
This program is free software: you can redistribute it and/or modify
|
||||||
it under the terms of the GNU Lesser General Public License as published by
|
it under the terms of the GNU Lesser General Public License as published by
|
||||||
the Free Software Foundation, either version 3 of the License, or
|
the Free Software Foundation, either version 3 of the License, or
|
||||||
(at your option) any later version.
|
(at your option) any later version.
|
||||||
|
|
||||||
This program is distributed in the hope that it will be useful,
|
This program is distributed in the hope that it will be useful,
|
||||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
GNU Lesser General Public License for more details.
|
GNU Lesser General Public License for more details.
|
||||||
|
|
||||||
You should have received a copy of the GNU Lesser General Public License
|
You should have received a copy of the GNU Lesser General Public License
|
||||||
along with this program. If not, see <http://www.gnu.org/licenses/>.
|
along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#ifndef MICROHTTPD_SERVER_P_H
|
#ifndef MICROHTTPD_SERVER_P_H
|
||||||
@@ -51,18 +51,18 @@ public:
|
|||||||
//! \~russian Параметры конфигурации сервера, принимаемые методом \a setOption().
|
//! \~russian Параметры конфигурации сервера, принимаемые методом \a setOption().
|
||||||
enum class Option {
|
enum class Option {
|
||||||
ConnectionLimit /** \~english Maximum number of simultaneously accepted connections. \~russian Максимальное число одновременно
|
ConnectionLimit /** \~english Maximum number of simultaneously accepted connections. \~russian Максимальное число одновременно
|
||||||
принимаемых соединений. */
|
принимаемых соединений. */
|
||||||
,
|
,
|
||||||
ConnectionTimeout /** \~english Per-connection timeout value. \~russian Значение таймаута для отдельного соединения. */,
|
ConnectionTimeout /** \~english Per-connection timeout value. \~russian Значение таймаута для отдельного соединения. */,
|
||||||
HTTPSEnabled /** \~english Enables TLS mode for the daemon. \~russian Включает режим TLS для демона. */,
|
HTTPSEnabled /** \~english Enables TLS mode for the daemon. \~russian Включает режим TLS для демона. */,
|
||||||
HTTPSMemKey /** \~english Private key stored in memory as \c PIByteArray. \~russian Приватный ключ, хранящийся в памяти в виде \c
|
HTTPSMemKey /** \~english Private key stored in memory as \c PIByteArray. \~russian Приватный ключ, хранящийся в памяти в виде \c
|
||||||
PIByteArray. */
|
PIByteArray. */
|
||||||
,
|
,
|
||||||
HTTPSMemCert /** \~english Certificate stored in memory as \c PIByteArray. \~russian Сертификат, хранящийся в памяти в виде \c
|
HTTPSMemCert /** \~english Certificate stored in memory as \c PIByteArray. \~russian Сертификат, хранящийся в памяти в виде \c
|
||||||
PIByteArray. */
|
PIByteArray. */
|
||||||
,
|
,
|
||||||
HTTPSKeyPassword /** \~english Password for the in-memory private key as \c PIByteArray. \~russian Пароль для приватного ключа в
|
HTTPSKeyPassword /** \~english Password for the in-memory private key as \c PIByteArray. \~russian Пароль для приватного ключа в
|
||||||
памяти в виде \c PIByteArray. */
|
памяти в виде \c PIByteArray. */
|
||||||
};
|
};
|
||||||
|
|
||||||
//! \~english Sets a server option. The expected variant payload depends on the selected \a Option.
|
//! \~english Sets a server option. The expected variant payload depends on the selected \a Option.
|
||||||
|
|||||||
@@ -4,22 +4,22 @@
|
|||||||
//! \~english High-level HTTP server with path-based routing and handler registration
|
//! \~english High-level HTTP server with path-based routing and handler registration
|
||||||
//! \~russian Высокоуровневый HTTP сервер с маршрутизацией по путям и регистрацией обработчиков
|
//! \~russian Высокоуровневый HTTP сервер с маршрутизацией по путям и регистрацией обработчиков
|
||||||
/*
|
/*
|
||||||
PIP - Platform Independent Primitives
|
PIP - Platform Independent Primitives
|
||||||
High-level HTTP server implementation
|
High-level HTTP server implementation
|
||||||
Ivan Pelipenko peri4ko@yandex.ru
|
Ivan Pelipenko peri4ko@yandex.ru
|
||||||
|
|
||||||
This program is free software: you can redistribute it and/or modify
|
This program is free software: you can redistribute it and/or modify
|
||||||
it under the terms of the GNU Lesser General Public License as published by
|
it under the terms of the GNU Lesser General Public License as published by
|
||||||
the Free Software Foundation, either version 3 of the License, or
|
the Free Software Foundation, either version 3 of the License, or
|
||||||
(at your option) any later version.
|
(at your option) any later version.
|
||||||
|
|
||||||
This program is distributed in the hope that it will be useful,
|
This program is distributed in the hope that it will be useful,
|
||||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
GNU Lesser General Public License for more details.
|
GNU Lesser General Public License for more details.
|
||||||
|
|
||||||
You should have received a copy of the GNU Lesser General Public License
|
You should have received a copy of the GNU Lesser General Public License
|
||||||
along with this program. If not, see <http://www.gnu.org/licenses/>.
|
along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#ifndef PIHTTPSERVER_H
|
#ifndef PIHTTPSERVER_H
|
||||||
|
|||||||
@@ -82,15 +82,15 @@ class PIIntrospectionServer;
|
|||||||
|
|
||||||
#else
|
#else
|
||||||
|
|
||||||
#ifdef PIP_INTROSPECTION
|
# ifdef PIP_INTROSPECTION
|
||||||
# define __PIINTROSPECTION_SINGLETON_H__(T) static PIIntrospection##T##Interface * instance();
|
# define __PIINTROSPECTION_SINGLETON_H__(T) static PIIntrospection##T##Interface * instance();
|
||||||
|
|
||||||
# define __PIINTROSPECTION_SINGLETON_CPP__(T) \
|
# define __PIINTROSPECTION_SINGLETON_CPP__(T) \
|
||||||
PIIntrospection##T##Interface * PIIntrospection##T##Interface::instance() { \
|
PIIntrospection##T##Interface * PIIntrospection##T##Interface::instance() { \
|
||||||
static PIIntrospection##T##Interface ret; \
|
static PIIntrospection##T##Interface ret; \
|
||||||
return &ret; \
|
return &ret; \
|
||||||
}
|
}
|
||||||
#endif // PIP_INTROSPECTION
|
# endif // PIP_INTROSPECTION
|
||||||
|
|
||||||
#endif // DOXYGEN
|
#endif // DOXYGEN
|
||||||
#endif // PIINTROSPECTION_BASE_H
|
#endif // PIINTROSPECTION_BASE_H
|
||||||
|
|||||||
@@ -24,8 +24,8 @@
|
|||||||
|
|
||||||
#ifdef PIP_INTROSPECTION
|
#ifdef PIP_INTROSPECTION
|
||||||
|
|
||||||
#include "pimap.h"
|
# include "pimap.h"
|
||||||
#include "pithread.h"
|
# include "pithread.h"
|
||||||
|
|
||||||
|
|
||||||
class PIP_EXPORT PIIntrospectionThreads {
|
class PIP_EXPORT PIIntrospectionThreads {
|
||||||
|
|||||||
@@ -17,35 +17,35 @@
|
|||||||
along with this program. If not, see <http://www.gnu.org/licenses/>.
|
along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||||
*/
|
*/
|
||||||
#ifdef PIP_HAS_FILESYSTEM
|
#ifdef PIP_HAS_FILESYSTEM
|
||||||
#include "pidir.h"
|
# include "pidir.h"
|
||||||
|
|
||||||
#include "piincludes_p.h"
|
# include "piincludes_p.h"
|
||||||
|
|
||||||
|
|
||||||
const PIChar PIDir::separator = '/';
|
const PIChar PIDir::separator = '/';
|
||||||
#ifdef QNX
|
# ifdef QNX
|
||||||
# define _stat_struct_ struct stat
|
# define _stat_struct_ struct stat
|
||||||
# define _stat_call_ stat
|
# define _stat_call_ stat
|
||||||
# define _stat_link_ lstat
|
# define _stat_link_ lstat
|
||||||
#else
|
|
||||||
# define _stat_struct_ struct stat64
|
|
||||||
# define _stat_call_ stat64
|
|
||||||
# define _stat_link_ lstat64
|
|
||||||
#endif
|
|
||||||
#ifndef WINDOWS
|
|
||||||
# ifdef ANDROID
|
|
||||||
# include <dirent.h>
|
|
||||||
# else
|
# else
|
||||||
# ifdef FREERTOS
|
# define _stat_struct_ struct stat64
|
||||||
|
# define _stat_call_ stat64
|
||||||
|
# define _stat_link_ lstat64
|
||||||
|
# endif
|
||||||
|
# ifndef WINDOWS
|
||||||
|
# ifdef ANDROID
|
||||||
|
# include <dirent.h>
|
||||||
|
# else
|
||||||
|
# ifdef FREERTOS
|
||||||
extern "C" {
|
extern "C" {
|
||||||
# include <sys/dirent.h>
|
# include <sys/dirent.h>
|
||||||
}
|
}
|
||||||
# else
|
# else
|
||||||
# include <sys/dir.h>
|
# include <sys/dir.h>
|
||||||
|
# endif
|
||||||
# endif
|
# endif
|
||||||
|
# include <sys/stat.h>
|
||||||
# endif
|
# endif
|
||||||
# include <sys/stat.h>
|
|
||||||
#endif
|
|
||||||
|
|
||||||
|
|
||||||
//! \class PIDir pidir.h
|
//! \class PIDir pidir.h
|
||||||
@@ -80,9 +80,9 @@ bool PIDir::operator==(const PIDir & d) const {
|
|||||||
bool PIDir::isAbsolute() const {
|
bool PIDir::isAbsolute() const {
|
||||||
if (path_.isEmpty()) return false;
|
if (path_.isEmpty()) return false;
|
||||||
if (path_[0] == separator) return true;
|
if (path_[0] == separator) return true;
|
||||||
#ifdef WINDOWS
|
# ifdef WINDOWS
|
||||||
return (path_.mid(1, 1) == ":");
|
return (path_.mid(1, 1) == ":");
|
||||||
#endif
|
# endif
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -96,28 +96,28 @@ PIString PIDir::name() const {
|
|||||||
|
|
||||||
|
|
||||||
PIString PIDir::path() const {
|
PIString PIDir::path() const {
|
||||||
#ifdef WINDOWS
|
# ifdef WINDOWS
|
||||||
if (path_.startsWith(separator)) {
|
if (path_.startsWith(separator)) {
|
||||||
if (path_.length() == 1)
|
if (path_.length() == 1)
|
||||||
return separator;
|
return separator;
|
||||||
else
|
else
|
||||||
return path_.mid(1);
|
return path_.mid(1);
|
||||||
} else
|
} else
|
||||||
#endif
|
# endif
|
||||||
return path_;
|
return path_;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
PIString PIDir::absolutePath() const {
|
PIString PIDir::absolutePath() const {
|
||||||
if (isAbsolute()) {
|
if (isAbsolute()) {
|
||||||
#ifdef WINDOWS
|
# ifdef WINDOWS
|
||||||
if (path_.startsWith(separator)) {
|
if (path_.startsWith(separator)) {
|
||||||
if (path_.length() == 1)
|
if (path_.length() == 1)
|
||||||
return separator;
|
return separator;
|
||||||
else
|
else
|
||||||
return path_.mid(1);
|
return path_.mid(1);
|
||||||
} else
|
} else
|
||||||
#endif
|
# endif
|
||||||
return path_;
|
return path_;
|
||||||
}
|
}
|
||||||
return PIDir(PIDir::current().path() + separator + path_).path();
|
return PIDir(PIDir::current().path() + separator + path_).path();
|
||||||
@@ -205,11 +205,11 @@ PIString PIDir::absolute(const PIString & path) const {
|
|||||||
|
|
||||||
PIDir & PIDir::setDir(const PIString & path) {
|
PIDir & PIDir::setDir(const PIString & path) {
|
||||||
path_ = path;
|
path_ = path;
|
||||||
#ifdef WINDOWS
|
# ifdef WINDOWS
|
||||||
path_.replaceAll("\\", separator);
|
path_.replaceAll("\\", separator);
|
||||||
if (path_.length() > 2)
|
if (path_.length() > 2)
|
||||||
if (path_.mid(1, 2).contains(":")) path_.prepend(separator);
|
if (path_.mid(1, 2).contains(":")) path_.prepend(separator);
|
||||||
#endif
|
# endif
|
||||||
cleanPath();
|
cleanPath();
|
||||||
return *this;
|
return *this;
|
||||||
}
|
}
|
||||||
@@ -226,9 +226,9 @@ PIDir & PIDir::cd(const PIString & path) {
|
|||||||
bool PIDir::make(bool withParents) {
|
bool PIDir::make(bool withParents) {
|
||||||
PIDir d = cleanedPath();
|
PIDir d = cleanedPath();
|
||||||
// PIString tp;
|
// PIString tp;
|
||||||
#ifndef WINDOWS
|
# ifndef WINDOWS
|
||||||
bool is_abs = isAbsolute();
|
bool is_abs = isAbsolute();
|
||||||
#endif
|
# endif
|
||||||
if (withParents) {
|
if (withParents) {
|
||||||
PIStringList l = d.path().split(separator);
|
PIStringList l = d.path().split(separator);
|
||||||
// piCout << l;
|
// piCout << l;
|
||||||
@@ -237,9 +237,9 @@ bool PIDir::make(bool withParents) {
|
|||||||
PIString cdp;
|
PIString cdp;
|
||||||
for (const auto & i: l) {
|
for (const auto & i: l) {
|
||||||
if (!cdp.isEmpty()
|
if (!cdp.isEmpty()
|
||||||
#ifndef WINDOWS
|
# ifndef WINDOWS
|
||||||
|| is_abs
|
|| is_abs
|
||||||
#endif
|
# endif
|
||||||
)
|
)
|
||||||
cdp += separator;
|
cdp += separator;
|
||||||
cdp += i;
|
cdp += i;
|
||||||
@@ -278,11 +278,11 @@ bool PIDir::rename(const PIString & new_name) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
#ifdef WINDOWS
|
# ifdef WINDOWS
|
||||||
bool sort_compare(const PIFile::FileInfo & v0, const PIFile::FileInfo & v1) {
|
bool sort_compare(const PIFile::FileInfo & v0, const PIFile::FileInfo & v1) {
|
||||||
return strcoll(v0.path.data(), v1.path.data()) < 0;
|
return strcoll(v0.path.data(), v1.path.data()) < 0;
|
||||||
}
|
}
|
||||||
#endif
|
# endif
|
||||||
|
|
||||||
|
|
||||||
//! \~\details
|
//! \~\details
|
||||||
@@ -309,7 +309,7 @@ PIVector<PIFile::FileInfo> PIDir::entries(const PIRegularExpression & regexp) {
|
|||||||
else if (!dp.endsWith(separator))
|
else if (!dp.endsWith(separator))
|
||||||
dp += separator;
|
dp += separator;
|
||||||
// piCout << "start entries from" << p;
|
// piCout << "start entries from" << p;
|
||||||
#ifdef WINDOWS
|
# ifdef WINDOWS
|
||||||
PIFile::FileInfo fi;
|
PIFile::FileInfo fi;
|
||||||
if (dp == separator) {
|
if (dp == separator) {
|
||||||
char letters[1024];
|
char letters[1024];
|
||||||
@@ -359,8 +359,8 @@ PIVector<PIFile::FileInfo> PIDir::entries(const PIRegularExpression & regexp) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
#else
|
# else
|
||||||
# if defined(QNX) || defined(FREERTOS)
|
# if defined(QNX) || defined(FREERTOS)
|
||||||
struct dirent * de = 0;
|
struct dirent * de = 0;
|
||||||
DIR * dir = 0;
|
DIR * dir = 0;
|
||||||
dir = opendir(p.data());
|
dir = opendir(p.data());
|
||||||
@@ -372,24 +372,24 @@ PIVector<PIFile::FileInfo> PIDir::entries(const PIRegularExpression & regexp) {
|
|||||||
}
|
}
|
||||||
closedir(dir);
|
closedir(dir);
|
||||||
}
|
}
|
||||||
# else
|
# else
|
||||||
dirent ** list = nullptr;
|
dirent ** list = nullptr;
|
||||||
int cnt = scandir(p.data(),
|
int cnt = scandir(p.data(),
|
||||||
&list,
|
&list,
|
||||||
0,
|
0,
|
||||||
# if defined(MAC_OS) || defined(ANDROID) || defined(BLACKBERRY)
|
# if defined(MAC_OS) || defined(ANDROID) || defined(BLACKBERRY)
|
||||||
alphasort);
|
alphasort);
|
||||||
# else
|
# else
|
||||||
versionsort);
|
versionsort);
|
||||||
# endif
|
# endif
|
||||||
if (cnt < 0) return ret;
|
if (cnt < 0) return ret;
|
||||||
for (int i = 0; i < cnt; ++i) {
|
for (int i = 0; i < cnt; ++i) {
|
||||||
ret << PIFile::fileInfo(dp + PIString(list[i]->d_name));
|
ret << PIFile::fileInfo(dp + PIString(list[i]->d_name));
|
||||||
free(list[i]);
|
free(list[i]);
|
||||||
}
|
}
|
||||||
free(list);
|
free(list);
|
||||||
|
# endif
|
||||||
# endif
|
# endif
|
||||||
#endif
|
|
||||||
// piCout << "end entries from" << p;
|
// piCout << "end entries from" << p;
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
@@ -442,45 +442,45 @@ PIVector<PIFile::FileInfo> PIDir::allEntries(const PIRegularExpression & regexp)
|
|||||||
|
|
||||||
|
|
||||||
bool PIDir::isExists(const PIString & path) {
|
bool PIDir::isExists(const PIString & path) {
|
||||||
#ifdef WINDOWS
|
# ifdef WINDOWS
|
||||||
DWORD ret = GetFileAttributes((LPCTSTR)(path.data()));
|
DWORD ret = GetFileAttributes((LPCTSTR)(path.data()));
|
||||||
return (ret != 0xFFFFFFFF) && (ret & FILE_ATTRIBUTE_DIRECTORY);
|
return (ret != 0xFFFFFFFF) && (ret & FILE_ATTRIBUTE_DIRECTORY);
|
||||||
#else
|
# else
|
||||||
DIR * dir_ = opendir(path.data());
|
DIR * dir_ = opendir(path.data());
|
||||||
if (dir_ == 0) return false;
|
if (dir_ == 0) return false;
|
||||||
closedir(dir_);
|
closedir(dir_);
|
||||||
#endif
|
# endif
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
PIDir PIDir::current() {
|
PIDir PIDir::current() {
|
||||||
#ifndef ESP_PLATFORM
|
# ifndef ESP_PLATFORM
|
||||||
char rc[1024];
|
char rc[1024];
|
||||||
#endif
|
# endif
|
||||||
#ifdef WINDOWS
|
# ifdef WINDOWS
|
||||||
piZeroMemory(rc, 1024);
|
piZeroMemory(rc, 1024);
|
||||||
if (GetCurrentDirectory(1024, (LPTSTR)rc) == 0) return PIString();
|
if (GetCurrentDirectory(1024, (LPTSTR)rc) == 0) return PIString();
|
||||||
PIString ret(rc);
|
PIString ret(rc);
|
||||||
ret.replaceAll("\\", PIDir::separator);
|
ret.replaceAll("\\", PIDir::separator);
|
||||||
ret.prepend(separator);
|
ret.prepend(separator);
|
||||||
return PIDir(ret);
|
return PIDir(ret);
|
||||||
#else
|
# else
|
||||||
# ifndef ESP_PLATFORM
|
# ifndef ESP_PLATFORM
|
||||||
if (getcwd(rc, 1024) == 0) return PIString();
|
if (getcwd(rc, 1024) == 0) return PIString();
|
||||||
return PIDir(rc);
|
return PIDir(rc);
|
||||||
# else
|
# else
|
||||||
return PIDir("/spiffs");
|
return PIDir("/spiffs");
|
||||||
|
# endif
|
||||||
# endif
|
# endif
|
||||||
#endif
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
PIDir PIDir::home() {
|
PIDir PIDir::home() {
|
||||||
#ifndef ESP_PLATFORM
|
# ifndef ESP_PLATFORM
|
||||||
char * rc = nullptr;
|
char * rc = nullptr;
|
||||||
#endif
|
# endif
|
||||||
#ifdef WINDOWS
|
# ifdef WINDOWS
|
||||||
rc = new char[1024];
|
rc = new char[1024];
|
||||||
piZeroMemory(rc, 1024);
|
piZeroMemory(rc, 1024);
|
||||||
if (ExpandEnvironmentStrings((LPCTSTR) "%HOMEPATH%", (LPTSTR)rc, 1024) == 0) {
|
if (ExpandEnvironmentStrings((LPCTSTR) "%HOMEPATH%", (LPTSTR)rc, 1024) == 0) {
|
||||||
@@ -498,21 +498,21 @@ PIDir PIDir::home() {
|
|||||||
delete[] rc;
|
delete[] rc;
|
||||||
// s.prepend(separator);
|
// s.prepend(separator);
|
||||||
return PIDir(hd + hp);
|
return PIDir(hd + hp);
|
||||||
#else
|
# else
|
||||||
# ifndef ESP_PLATFORM
|
# ifndef ESP_PLATFORM
|
||||||
rc = getenv("HOME");
|
rc = getenv("HOME");
|
||||||
if (!rc) return PIDir();
|
if (!rc) return PIDir();
|
||||||
return PIDir(rc);
|
return PIDir(rc);
|
||||||
# else
|
# else
|
||||||
return PIDir();
|
return PIDir();
|
||||||
|
# endif
|
||||||
# endif
|
# endif
|
||||||
#endif
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
PIDir PIDir::temporary() {
|
PIDir PIDir::temporary() {
|
||||||
char * rc = nullptr;
|
char * rc = nullptr;
|
||||||
#ifdef WINDOWS
|
# ifdef WINDOWS
|
||||||
rc = new char[1024];
|
rc = new char[1024];
|
||||||
piZeroMemory(rc, 1024);
|
piZeroMemory(rc, 1024);
|
||||||
int ret = GetTempPath(1024, (LPTSTR)rc);
|
int ret = GetTempPath(1024, (LPTSTR)rc);
|
||||||
@@ -525,13 +525,13 @@ PIDir PIDir::temporary() {
|
|||||||
delete[] rc;
|
delete[] rc;
|
||||||
s.prepend(separator);
|
s.prepend(separator);
|
||||||
return PIDir(s);
|
return PIDir(s);
|
||||||
#else
|
# else
|
||||||
char template_rc[] = "/tmp/pidir_tmp_XXXXXX";
|
char template_rc[] = "/tmp/pidir_tmp_XXXXXX";
|
||||||
rc = mkdtemp(template_rc);
|
rc = mkdtemp(template_rc);
|
||||||
if (!rc) return PIDir();
|
if (!rc) return PIDir();
|
||||||
PIString s(rc);
|
PIString s(rc);
|
||||||
return PIDir(s.left(s.findLast(PIDir::separator)));
|
return PIDir(s.left(s.findLast(PIDir::separator)));
|
||||||
#endif
|
# endif
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@@ -548,33 +548,33 @@ bool PIDir::make(const PIString & path, bool withParents) {
|
|||||||
|
|
||||||
|
|
||||||
bool PIDir::setCurrent(const PIString & path) {
|
bool PIDir::setCurrent(const PIString & path) {
|
||||||
#ifdef WINDOWS
|
# ifdef WINDOWS
|
||||||
if (SetCurrentDirectory((LPCTSTR)(path.data())) != 0) return true;
|
if (SetCurrentDirectory((LPCTSTR)(path.data())) != 0) return true;
|
||||||
#else
|
# else
|
||||||
if (chdir(path.data()) == 0) return true;
|
if (chdir(path.data()) == 0) return true;
|
||||||
#endif
|
# endif
|
||||||
printf("[PIDir] setCurrent(\"%s\") error: %s\n", path.data(), errorString().data());
|
printf("[PIDir] setCurrent(\"%s\") error: %s\n", path.data(), errorString().data());
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
bool PIDir::makeDir(const PIString & path) {
|
bool PIDir::makeDir(const PIString & path) {
|
||||||
#ifdef WINDOWS
|
# ifdef WINDOWS
|
||||||
if (CreateDirectory((LPCTSTR)(path.data()), NULL) != 0) return true;
|
if (CreateDirectory((LPCTSTR)(path.data()), NULL) != 0) return true;
|
||||||
#else
|
# else
|
||||||
if (mkdir(path.data(), 16877) == 0) return true;
|
if (mkdir(path.data(), 16877) == 0) return true;
|
||||||
#endif
|
# endif
|
||||||
printf("[PIDir] makeDir(\"%s\") error: %s\n", path.data(), errorString().data());
|
printf("[PIDir] makeDir(\"%s\") error: %s\n", path.data(), errorString().data());
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
bool PIDir::removeDir(const PIString & path) {
|
bool PIDir::removeDir(const PIString & path) {
|
||||||
#ifdef WINDOWS
|
# ifdef WINDOWS
|
||||||
if (RemoveDirectory((LPCTSTR)(path.data())) != 0) return true;
|
if (RemoveDirectory((LPCTSTR)(path.data())) != 0) return true;
|
||||||
#else
|
# else
|
||||||
if (rmdir(path.data()) == 0) return true;
|
if (rmdir(path.data()) == 0) return true;
|
||||||
#endif
|
# endif
|
||||||
printf("[PIDir] removeDir(\"%s\") error: %s\n", path.data(), errorString().data());
|
printf("[PIDir] removeDir(\"%s\") error: %s\n", path.data(), errorString().data());
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -339,8 +339,8 @@ public:
|
|||||||
|
|
||||||
//! \ioparams
|
//! \ioparams
|
||||||
//! \{
|
//! \{
|
||||||
#ifdef DOXYGEN
|
# ifdef DOXYGEN
|
||||||
#endif
|
# endif
|
||||||
//! \}
|
//! \}
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
|
|||||||
@@ -126,8 +126,7 @@ bool PISPI::openDevice() {
|
|||||||
PRIVATE->fd = -1;
|
PRIVATE->fd = -1;
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
piCoutObj << "SPI open" << path() << "speed:" << spi_speed / 1000 << "KHz"
|
piCoutObj << "SPI open" << path() << "speed:" << spi_speed / 1000 << "KHz" << "mode" << spi_mode << "bits" << spi_bits;
|
||||||
<< "mode" << spi_mode << "bits" << spi_bits;
|
|
||||||
PRIVATE->spi_ioc_tr.delay_usecs = 0;
|
PRIVATE->spi_ioc_tr.delay_usecs = 0;
|
||||||
PRIVATE->spi_ioc_tr.speed_hz = 0;
|
PRIVATE->spi_ioc_tr.speed_hz = 0;
|
||||||
PRIVATE->spi_ioc_tr.bits_per_word = spi_bits;
|
PRIVATE->spi_ioc_tr.bits_per_word = spi_bits;
|
||||||
|
|||||||
@@ -50,7 +50,7 @@ public:
|
|||||||
//! \~english SPI mode flags.
|
//! \~english SPI mode flags.
|
||||||
//! \~russian Флаги режима SPI.
|
//! \~russian Флаги режима SPI.
|
||||||
enum Parameters {
|
enum Parameters {
|
||||||
ClockInverse = 0x1 /*! \~english Invert clock polarity \~russian Инвертировать полярность тактового сигнала */,
|
ClockInverse = 0x1 /*! \~english Invert clock polarity \~russian Инвертировать полярность тактового сигнала */,
|
||||||
ClockPhaseShift = 0x2 /*! \~english Shift sampling phase \~russian Сдвинуть фазу выборки */,
|
ClockPhaseShift = 0x2 /*! \~english Shift sampling phase \~russian Сдвинуть фазу выборки */,
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|||||||
@@ -26,8 +26,8 @@
|
|||||||
#define PIETHUTILBASE_H
|
#define PIETHUTILBASE_H
|
||||||
#ifdef PIP_HAS_SOCKET
|
#ifdef PIP_HAS_SOCKET
|
||||||
|
|
||||||
#include "pibytearray.h"
|
# include "pibytearray.h"
|
||||||
#include "pip_io_utils_export.h"
|
# include "pip_io_utils_export.h"
|
||||||
|
|
||||||
//! \~\ingroup IO-Utils
|
//! \~\ingroup IO-Utils
|
||||||
//! \~\brief
|
//! \~\brief
|
||||||
|
|||||||
@@ -26,10 +26,10 @@
|
|||||||
#define pipackedtcp_H
|
#define pipackedtcp_H
|
||||||
#ifdef PIP_HAS_SOCKET
|
#ifdef PIP_HAS_SOCKET
|
||||||
|
|
||||||
#include "piiodevice.h"
|
# include "piiodevice.h"
|
||||||
#include "pinetworkaddress.h"
|
# include "pinetworkaddress.h"
|
||||||
#include "pip_io_utils_export.h"
|
# include "pip_io_utils_export.h"
|
||||||
#include "pistreampacker.h"
|
# include "pistreampacker.h"
|
||||||
|
|
||||||
class PIEthernet;
|
class PIEthernet;
|
||||||
|
|
||||||
|
|||||||
@@ -65,17 +65,17 @@ public:
|
|||||||
enum SplitMode {
|
enum SplitMode {
|
||||||
None /** \~english Accept every read chunk as a packet \~russian Считать каждый прочитанный блок отдельным пакетом */,
|
None /** \~english Accept every read chunk as a packet \~russian Считать каждый прочитанный блок отдельным пакетом */,
|
||||||
Header /** \~english Search for \a header() and use configured payload size or callback result \~russian Искать \a header() и
|
Header /** \~english Search for \a header() and use configured payload size or callback result \~russian Искать \a header() и
|
||||||
использовать настроенный размер полезной нагрузки или результат callback */
|
использовать настроенный размер полезной нагрузки или результат callback */
|
||||||
,
|
,
|
||||||
Footer /** \~english Use fixed payload size and validate trailing \a footer() \~russian Использовать фиксированный размер полезной
|
Footer /** \~english Use fixed payload size and validate trailing \a footer() \~russian Использовать фиксированный размер полезной
|
||||||
нагрузки и проверять завершающий \a footer() */
|
нагрузки и проверять завершающий \a footer() */
|
||||||
,
|
,
|
||||||
HeaderAndFooter /** \~english Search for packets bounded by \a header() and \a footer() \~russian Искать пакеты, ограниченные \a
|
HeaderAndFooter /** \~english Search for packets bounded by \a header() and \a footer() \~russian Искать пакеты, ограниченные \a
|
||||||
header() и \a footer() */
|
header() и \a footer() */
|
||||||
,
|
,
|
||||||
Size /** \~english Treat \a payloadSize() as full packet size \~russian Использовать \a payloadSize() как полный размер пакета */,
|
Size /** \~english Treat \a payloadSize() as full packet size \~russian Использовать \a payloadSize() как полный размер пакета */,
|
||||||
Timeout /** \~english Collect bytes until \a timeout() expires after the first read \~russian Накопить байты до истечения \a
|
Timeout /** \~english Collect bytes until \a timeout() expires after the first read \~russian Накопить байты до истечения \a
|
||||||
timeout() после первого чтения */
|
timeout() после первого чтения */
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -26,9 +26,9 @@
|
|||||||
#define PISTREAMPACKER_H
|
#define PISTREAMPACKER_H
|
||||||
#ifdef PIP_HAS_SOCKET
|
#ifdef PIP_HAS_SOCKET
|
||||||
|
|
||||||
#include "piethutilbase.h"
|
# include "piethutilbase.h"
|
||||||
#include "piobject.h"
|
# include "piobject.h"
|
||||||
#include "pip_io_utils_export.h"
|
# include "pip_io_utils_export.h"
|
||||||
|
|
||||||
|
|
||||||
class PIIODevice;
|
class PIIODevice;
|
||||||
|
|||||||
@@ -16,7 +16,7 @@
|
|||||||
*/
|
*/
|
||||||
/*
|
/*
|
||||||
PIP - Platform Independent Primitives
|
PIP - Platform Independent Primitives
|
||||||
Bytes C++11 literals for bytes
|
Bytes C++11 literals for bytes
|
||||||
Ivan Pelipenko peri4ko@yandex.ru
|
Ivan Pelipenko peri4ko@yandex.ru
|
||||||
|
|
||||||
This program is free software: you can redistribute it and/or modify
|
This program is free software: you can redistribute it and/or modify
|
||||||
|
|||||||
@@ -6,7 +6,7 @@
|
|||||||
*/
|
*/
|
||||||
/*
|
/*
|
||||||
PIP - Platform Independent Primitives
|
PIP - Platform Independent Primitives
|
||||||
PISystemTime C++11 literals
|
PISystemTime C++11 literals
|
||||||
Ivan Pelipenko peri4ko@yandex.ru
|
Ivan Pelipenko peri4ko@yandex.ru
|
||||||
|
|
||||||
This program is free software: you can redistribute it and/or modify
|
This program is free software: you can redistribute it and/or modify
|
||||||
|
|||||||
+11
-11
@@ -225,17 +225,17 @@ typedef PIFFT_float PIFFTf;
|
|||||||
|
|
||||||
# ifndef CC_VC
|
# ifndef CC_VC
|
||||||
|
|
||||||
# define _PIFFTW_H(type) \
|
# define _PIFFTW_H(type) \
|
||||||
class PIP_FFTW_EXPORT _PIFFTW_P_##type##_ { \
|
class PIP_FFTW_EXPORT _PIFFTW_P_##type##_ { \
|
||||||
public: \
|
public: \
|
||||||
_PIFFTW_P_##type##_(); \
|
_PIFFTW_P_##type##_(); \
|
||||||
~_PIFFTW_P_##type##_(); \
|
~_PIFFTW_P_##type##_(); \
|
||||||
const PIVector<complex<type>> & calcFFT(const PIVector<complex<type>> & in); \
|
const PIVector<complex<type>> & calcFFT(const PIVector<complex<type>> & in); \
|
||||||
const PIVector<complex<type>> & calcFFTR(const PIVector<type> & in); \
|
const PIVector<complex<type>> & calcFFTR(const PIVector<type> & in); \
|
||||||
const PIVector<complex<type>> & calcFFTI(const PIVector<complex<type>> & in); \
|
const PIVector<complex<type>> & calcFFTI(const PIVector<complex<type>> & in); \
|
||||||
void preparePlan(int size, int op); \
|
void preparePlan(int size, int op); \
|
||||||
void * impl; \
|
void * impl; \
|
||||||
};
|
};
|
||||||
_PIFFTW_H(float)
|
_PIFFTW_H(float)
|
||||||
_PIFFTW_H(double)
|
_PIFFTW_H(double)
|
||||||
_PIFFTW_H(ldouble)
|
_PIFFTW_H(ldouble)
|
||||||
|
|||||||
@@ -32,9 +32,9 @@
|
|||||||
|
|
||||||
/// Matrix templated
|
/// Matrix templated
|
||||||
|
|
||||||
#define PIMM_FOR \
|
#define PIMM_FOR \
|
||||||
for (uint r = 0; r < Rows; ++r) \
|
for (uint r = 0; r < Rows; ++r) \
|
||||||
for (uint c = 0; c < Cols; ++c)
|
for (uint c = 0; c < Cols; ++c)
|
||||||
#define PIMM_FOR_C for (uint i = 0; i < Cols; ++i)
|
#define PIMM_FOR_C for (uint i = 0; i < Cols; ++i)
|
||||||
#define PIMM_FOR_R for (uint i = 0; i < Rows; ++i)
|
#define PIMM_FOR_R for (uint i = 0; i < Rows; ++i)
|
||||||
|
|
||||||
@@ -912,9 +912,9 @@ class PIMathMatrix;
|
|||||||
|
|
||||||
/// Matrix
|
/// Matrix
|
||||||
|
|
||||||
#define PIMM_FOR \
|
#define PIMM_FOR \
|
||||||
for (uint r = 0; r < _V2D::rows_; ++r) \
|
for (uint r = 0; r < _V2D::rows_; ++r) \
|
||||||
for (uint c = 0; c < _V2D::cols_; ++c)
|
for (uint c = 0; c < _V2D::cols_; ++c)
|
||||||
#define PIMM_FOR_A for (uint i = 0; i < _V2D::mat.size(); ++i)
|
#define PIMM_FOR_A for (uint i = 0; i < _V2D::mat.size(); ++i)
|
||||||
#define PIMM_FOR_C for (uint i = 0; i < _V2D::cols_; ++i)
|
#define PIMM_FOR_C for (uint i = 0; i < _V2D::cols_; ++i)
|
||||||
#define PIMM_FOR_R for (uint i = 0; i < _V2D::rows_; ++i)
|
#define PIMM_FOR_R for (uint i = 0; i < _V2D::rows_; ++i)
|
||||||
|
|||||||
@@ -57,10 +57,10 @@ public:
|
|||||||
//! \~english Integration method selector.
|
//! \~english Integration method selector.
|
||||||
//! \~russian Выбор метода интегрирования.
|
//! \~russian Выбор метода интегрирования.
|
||||||
enum Method {
|
enum Method {
|
||||||
Global = -1 /** \~english Use the global default method \~russian Использовать глобальный метод по умолчанию */,
|
Global = -1 /** \~english Use the global default method \~russian Использовать глобальный метод по умолчанию */,
|
||||||
Eyler_1 = 01 /** \~english First-order Euler method \~russian Метод Эйлера первого порядка */,
|
Eyler_1 = 01 /** \~english First-order Euler method \~russian Метод Эйлера первого порядка */,
|
||||||
Eyler_2 = 02 /** \~english Second-order Euler method \~russian Метод Эйлера второго порядка */,
|
Eyler_2 = 02 /** \~english Second-order Euler method \~russian Метод Эйлера второго порядка */,
|
||||||
EylerKoshi = 03 /** \~english Euler-Cauchy method identifier \~russian Идентификатор метода Эйлера-Коши */,
|
EylerKoshi = 03 /** \~english Euler-Cauchy method identifier \~russian Идентификатор метода Эйлера-Коши */,
|
||||||
RungeKutta_4 = 14 /** \~english Fourth-order Runge-Kutta method \~russian Метод Рунге-Кутты четвертого порядка */,
|
RungeKutta_4 = 14 /** \~english Fourth-order Runge-Kutta method \~russian Метод Рунге-Кутты четвертого порядка */,
|
||||||
AdamsBashfortMoulton_2 =
|
AdamsBashfortMoulton_2 =
|
||||||
22 /** \~english Second-order Adams-Bashforth-Moulton method \~russian Метод Адамса-Башфорта-Моултона второго порядка */,
|
22 /** \~english Second-order Adams-Bashforth-Moulton method \~russian Метод Адамса-Башфорта-Моултона второго порядка */,
|
||||||
|
|||||||
@@ -5,7 +5,7 @@
|
|||||||
//! \~russian Вычисление математической статистики у массива чисел
|
//! \~russian Вычисление математической статистики у массива чисел
|
||||||
/*
|
/*
|
||||||
PIP - Platform Independent Primitives
|
PIP - Platform Independent Primitives
|
||||||
Calculating math statistic of values array
|
Calculating math statistic of values array
|
||||||
Andrey Bychkov work.a.b@yandex.ru
|
Andrey Bychkov work.a.b@yandex.ru
|
||||||
|
|
||||||
This program is free software: you can redistribute it and/or modify
|
This program is free software: you can redistribute it and/or modify
|
||||||
|
|||||||
@@ -4,22 +4,22 @@
|
|||||||
//! \~english
|
//! \~english
|
||||||
//! \~russian
|
//! \~russian
|
||||||
/*
|
/*
|
||||||
PIP - Platform Independent Primitives
|
PIP - Platform Independent Primitives
|
||||||
MQTT Client
|
MQTT Client
|
||||||
Ivan Pelipenko peri4ko@yandex.ru
|
Ivan Pelipenko peri4ko@yandex.ru
|
||||||
|
|
||||||
This program is free software: you can redistribute it and/or modify
|
This program is free software: you can redistribute it and/or modify
|
||||||
it under the terms of the GNU Lesser General Public License as published by
|
it under the terms of the GNU Lesser General Public License as published by
|
||||||
the Free Software Foundation, either version 3 of the License, or
|
the Free Software Foundation, either version 3 of the License, or
|
||||||
(at your option) any later version.
|
(at your option) any later version.
|
||||||
|
|
||||||
This program is distributed in the hope that it will be useful,
|
This program is distributed in the hope that it will be useful,
|
||||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
GNU Lesser General Public License for more details.
|
GNU Lesser General Public License for more details.
|
||||||
|
|
||||||
You should have received a copy of the GNU Lesser General Public License
|
You should have received a copy of the GNU Lesser General Public License
|
||||||
along with this program. If not, see <http://www.gnu.org/licenses/>.
|
along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#ifndef pimqttclient_h
|
#ifndef pimqttclient_h
|
||||||
|
|||||||
@@ -5,7 +5,7 @@
|
|||||||
//! \~russian Классы-обертки для OpenCL
|
//! \~russian Классы-обертки для OpenCL
|
||||||
/*
|
/*
|
||||||
PIP - Platform Independent Primitives
|
PIP - Platform Independent Primitives
|
||||||
OpenCL wrapper classes
|
OpenCL wrapper classes
|
||||||
Ivan Pelipenko peri4ko@yandex.ru
|
Ivan Pelipenko peri4ko@yandex.ru
|
||||||
|
|
||||||
This program is free software: you can redistribute it and/or modify
|
This program is free software: you can redistribute it and/or modify
|
||||||
|
|||||||
@@ -56,17 +56,17 @@
|
|||||||
|
|
||||||
#else
|
#else
|
||||||
|
|
||||||
# define BINARY_STREAM_FRIEND(T) \
|
# define BINARY_STREAM_FRIEND(T) \
|
||||||
template<typename P> \
|
template<typename P> \
|
||||||
friend PIBinaryStream<P> & operator<<(PIBinaryStream<P> & s, const T & v); \
|
friend PIBinaryStream<P> & operator<<(PIBinaryStream<P> & s, const T & v); \
|
||||||
template<typename P> \
|
template<typename P> \
|
||||||
friend PIBinaryStream<P> & operator>>(PIBinaryStream<P> & s, T & v);
|
friend PIBinaryStream<P> & operator>>(PIBinaryStream<P> & s, T & v);
|
||||||
# define BINARY_STREAM_WRITE(T) \
|
# define BINARY_STREAM_WRITE(T) \
|
||||||
template<typename P> \
|
template<typename P> \
|
||||||
inline PIBinaryStream<P> & operator<<(PIBinaryStream<P> & s, const T & v)
|
inline PIBinaryStream<P> & operator<<(PIBinaryStream<P> & s, const T & v)
|
||||||
# define BINARY_STREAM_READ(T) \
|
# define BINARY_STREAM_READ(T) \
|
||||||
template<typename P> \
|
template<typename P> \
|
||||||
inline PIBinaryStream<P> & operator>>(PIBinaryStream<P> & s, T & v)
|
inline PIBinaryStream<P> & operator>>(PIBinaryStream<P> & s, T & v)
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
|||||||
@@ -10,7 +10,7 @@
|
|||||||
//! Этот файл предоставляет шаблонные функции для сериализации и десериализации различных типов в формат PIJSON и из него.
|
//! Этот файл предоставляет шаблонные функции для сериализации и десериализации различных типов в формат PIJSON и из него.
|
||||||
/*
|
/*
|
||||||
PIP - Platform Independent Primitives
|
PIP - Platform Independent Primitives
|
||||||
Generic JSON serialization helpers
|
Generic JSON serialization helpers
|
||||||
Ivan Pelipenko peri4ko@yandex.ru
|
Ivan Pelipenko peri4ko@yandex.ru
|
||||||
|
|
||||||
This program is free software: you can redistribute it and/or modify
|
This program is free software: you can redistribute it and/or modify
|
||||||
@@ -63,7 +63,7 @@ template<typename T,
|
|||||||
typename std::enable_if<!std::is_arithmetic<T>::value, int>::type = 0>
|
typename std::enable_if<!std::is_arithmetic<T>::value, int>::type = 0>
|
||||||
inline PIJSON piSerializeJSON(const T & v) {
|
inline PIJSON piSerializeJSON(const T & v) {
|
||||||
static_assert(std::is_enum<T>::value || std::is_arithmetic<T>::value,
|
static_assert(std::is_enum<T>::value || std::is_arithmetic<T>::value,
|
||||||
"[piSerializeJSON] Error: using undeclared piSerializeJSON() for complex type!");
|
"[piSerializeJSON] Error: using undeclared piSerializeJSON() for complex type!");
|
||||||
return {};
|
return {};
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -329,7 +329,7 @@ template<typename T,
|
|||||||
typename std::enable_if<!std::is_arithmetic<T>::value, int>::type = 0>
|
typename std::enable_if<!std::is_arithmetic<T>::value, int>::type = 0>
|
||||||
inline void piDeserializeJSON(T & v, const PIJSON & js) {
|
inline void piDeserializeJSON(T & v, const PIJSON & js) {
|
||||||
static_assert(std::is_enum<T>::value || std::is_arithmetic<T>::value,
|
static_assert(std::is_enum<T>::value || std::is_arithmetic<T>::value,
|
||||||
"[piDeserializeJSON] Error: using undeclared piDeserializeJSON() for complex type!");
|
"[piDeserializeJSON] Error: using undeclared piDeserializeJSON() for complex type!");
|
||||||
v = {};
|
v = {};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -39,14 +39,14 @@ namespace PIValueTreeConversions {
|
|||||||
//! \~english Conversion options.
|
//! \~english Conversion options.
|
||||||
//! \~russian Параметры преобразования.
|
//! \~russian Параметры преобразования.
|
||||||
enum Option {
|
enum Option {
|
||||||
WithAttributes = 0x1 /** \~english Include node attributes \~russian Включать атрибуты узлов */,
|
WithAttributes = 0x1 /** \~english Include node attributes \~russian Включать атрибуты узлов */,
|
||||||
WithComment = 0x2 /** \~english Include node comments \~russian Включать комментарии узлов */,
|
WithComment = 0x2 /** \~english Include node comments \~russian Включать комментарии узлов */,
|
||||||
WithType = 0x4 /** \~english Include textual value type information \~russian Включать текстовую информацию о типе значения */,
|
WithType = 0x4 /** \~english Include textual value type information \~russian Включать текстовую информацию о типе значения */,
|
||||||
WithAll = 0xFFF /** \~english Enable all content flags \~russian Включать все флаги содержимого */,
|
WithAll = 0xFFF /** \~english Enable all content flags \~russian Включать все флаги содержимого */,
|
||||||
IncludeRoot = 0x1000 /** \~english Serialize the passed root node itself instead of only its children \~russian Сериализовать сам
|
IncludeRoot = 0x1000 /** \~english Serialize the passed root node itself instead of only its children \~russian Сериализовать сам
|
||||||
переданный корневой узел, а не только его дочерние элементы */
|
переданный корневой узел, а не только его дочерние элементы */
|
||||||
,
|
,
|
||||||
Default = WithAll /** \~english Default conversion options \~russian Параметры преобразования по умолчанию */
|
Default = WithAll /** \~english Default conversion options \~russian Параметры преобразования по умолчанию */
|
||||||
};
|
};
|
||||||
|
|
||||||
//! \~english Bit mask of %PIValueTree conversion options.
|
//! \~english Bit mask of %PIValueTree conversion options.
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
/*
|
/*
|
||||||
PIP - Platform Independent Primitives
|
PIP - Platform Independent Primitives
|
||||||
State machine
|
State machine
|
||||||
Ivan Pelipenko peri4ko@yandex.ru, Andrey Bychkov work.a.b@yandex.ru
|
Ivan Pelipenko peri4ko@yandex.ru, Andrey Bychkov work.a.b@yandex.ru
|
||||||
|
|
||||||
This program is free software: you can redistribute it and/or modify
|
This program is free software: you can redistribute it and/or modify
|
||||||
|
|||||||
@@ -12,8 +12,8 @@
|
|||||||
//! PIStateBase, PITransitionBase
|
//! PIStateBase, PITransitionBase
|
||||||
/*
|
/*
|
||||||
PIP - Platform Independent Primitives
|
PIP - Platform Independent Primitives
|
||||||
State machine
|
State machine
|
||||||
Ivan Pelipenko peri4ko@yandex.ru
|
Ivan Pelipenko peri4ko@yandex.ru
|
||||||
|
|
||||||
This program is free software: you can redistribute it and/or modify
|
This program is free software: you can redistribute it and/or modify
|
||||||
it under the terms of the GNU Lesser General Public License as published by
|
it under the terms of the GNU Lesser General Public License as published by
|
||||||
|
|||||||
@@ -1,20 +1,20 @@
|
|||||||
/*
|
/*
|
||||||
PIP - Platform Independent Primitives
|
PIP - Platform Independent Primitives
|
||||||
State machine
|
State machine
|
||||||
Ivan Pelipenko peri4ko@yandex.ru, Andrey Bychkov work.a.b@yandex.ru
|
Ivan Pelipenko peri4ko@yandex.ru, Andrey Bychkov work.a.b@yandex.ru
|
||||||
|
|
||||||
This program is free software: you can redistribute it and/or modify
|
This program is free software: you can redistribute it and/or modify
|
||||||
it under the terms of the GNU Lesser General Public License as published by
|
it under the terms of the GNU Lesser General Public License as published by
|
||||||
the Free Software Foundation, either version 3 of the License, or
|
the Free Software Foundation, either version 3 of the License, or
|
||||||
(at your option) any later version.
|
(at your option) any later version.
|
||||||
|
|
||||||
This program is distributed in the hope that it will be useful,
|
This program is distributed in the hope that it will be useful,
|
||||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
GNU Lesser General Public License for more details.
|
GNU Lesser General Public License for more details.
|
||||||
|
|
||||||
You should have received a copy of the GNU Lesser General Public License
|
You should have received a copy of the GNU Lesser General Public License
|
||||||
along with this program. If not, see <http://www.gnu.org/licenses/>.
|
along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#include "pistatemachine_state.h"
|
#include "pistatemachine_state.h"
|
||||||
|
|||||||
@@ -4,22 +4,22 @@
|
|||||||
//! \~english Declares module entry includes for the state machine API
|
//! \~english Declares module entry includes for the state machine API
|
||||||
//! \~russian Объявляет основной include модуля API машины состояний
|
//! \~russian Объявляет основной include модуля API машины состояний
|
||||||
/*
|
/*
|
||||||
PIP - Platform Independent Primitives
|
PIP - Platform Independent Primitives
|
||||||
Module includes
|
Module includes
|
||||||
Ivan Pelipenko peri4ko@yandex.ru
|
Ivan Pelipenko peri4ko@yandex.ru
|
||||||
|
|
||||||
This program is free software: you can redistribute it and/or modify
|
This program is free software: you can redistribute it and/or modify
|
||||||
it under the terms of the GNU Lesser General Public License as published by
|
it under the terms of the GNU Lesser General Public License as published by
|
||||||
the Free Software Foundation, either version 3 of the License, or
|
the Free Software Foundation, either version 3 of the License, or
|
||||||
(at your option) any later version.
|
(at your option) any later version.
|
||||||
|
|
||||||
This program is distributed in the hope that it will be useful,
|
This program is distributed in the hope that it will be useful,
|
||||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
GNU Lesser General Public License for more details.
|
GNU Lesser General Public License for more details.
|
||||||
|
|
||||||
You should have received a copy of the GNU Lesser General Public License
|
You should have received a copy of the GNU Lesser General Public License
|
||||||
along with this program. If not, see <http://www.gnu.org/licenses/>.
|
along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||||
*/
|
*/
|
||||||
//! \defgroup StateMachine StateMachine
|
//! \defgroup StateMachine StateMachine
|
||||||
//! \~\brief
|
//! \~\brief
|
||||||
|
|||||||
@@ -201,7 +201,7 @@ void * PILibrary::resolve(const char * symbol) {
|
|||||||
# ifdef WINDOWS
|
# ifdef WINDOWS
|
||||||
ret = (void *)GetProcAddress(PRIVATE->hLib, symbol);
|
ret = (void *)GetProcAddress(PRIVATE->hLib, symbol);
|
||||||
# else
|
# else
|
||||||
ret = dlsym(PRIVATE->hLib, symbol);
|
ret = dlsym(PRIVATE->hLib, symbol);
|
||||||
# endif
|
# endif
|
||||||
getLastError();
|
getLastError();
|
||||||
return ret;
|
return ret;
|
||||||
@@ -214,7 +214,7 @@ bool PILibrary::loadInternal() {
|
|||||||
# ifdef WINDOWS
|
# ifdef WINDOWS
|
||||||
PRIVATE->hLib = LoadLibraryA(libpath.data());
|
PRIVATE->hLib = LoadLibraryA(libpath.data());
|
||||||
# else
|
# else
|
||||||
PRIVATE->hLib = dlopen(libpath.data(), RTLD_LAZY);
|
PRIVATE->hLib = dlopen(libpath.data(), RTLD_LAZY);
|
||||||
# endif
|
# endif
|
||||||
getLastError();
|
getLastError();
|
||||||
return PRIVATE->hLib;
|
return PRIVATE->hLib;
|
||||||
|
|||||||
+21
-19
@@ -96,28 +96,30 @@
|
|||||||
# define __PIP_PLUGIN_STATIC_MERGE_FUNC__ pip_merge_static
|
# define __PIP_PLUGIN_STATIC_MERGE_FUNC__ pip_merge_static
|
||||||
# define __PIP_PLUGIN_LOADER_VERSION__ 2
|
# define __PIP_PLUGIN_LOADER_VERSION__ 2
|
||||||
|
|
||||||
# define PIP_PLUGIN_SET_USER_VERSION(v) \
|
# define PIP_PLUGIN_SET_USER_VERSION(v) \
|
||||||
STATIC_INITIALIZER_BEGIN \
|
STATIC_INITIALIZER_BEGIN \
|
||||||
PIPluginInfo * pi = PIPluginInfoStorage::instance()->currentInfo(); \
|
PIPluginInfo * pi = PIPluginInfoStorage::instance()->currentInfo(); \
|
||||||
if (pi) pi->setUserVersion(v); \
|
if (pi) pi->setUserVersion(v); \
|
||||||
STATIC_INITIALIZER_END
|
STATIC_INITIALIZER_END
|
||||||
|
|
||||||
# define PIP_PLUGIN_ADD_STATIC_SECTION(type, ptr) \
|
# define PIP_PLUGIN_ADD_STATIC_SECTION(type, ptr) \
|
||||||
STATIC_INITIALIZER_BEGIN \
|
STATIC_INITIALIZER_BEGIN \
|
||||||
PIPluginInfo * pi = PIPluginInfoStorage::instance()->currentInfo(); \
|
PIPluginInfo * pi = PIPluginInfoStorage::instance()->currentInfo(); \
|
||||||
if (pi) pi->setStaticSection(type, ptr); \
|
if (pi) pi->setStaticSection(type, ptr); \
|
||||||
STATIC_INITIALIZER_END
|
STATIC_INITIALIZER_END
|
||||||
|
|
||||||
# define PIP_PLUGIN \
|
# define PIP_PLUGIN \
|
||||||
extern "C" { \
|
extern "C" { \
|
||||||
PIP_PLUGIN_EXPORT int __PIP_PLUGIN_LOADER_VERSION_FUNC__() { return __PIP_PLUGIN_LOADER_VERSION__; } \
|
PIP_PLUGIN_EXPORT int __PIP_PLUGIN_LOADER_VERSION_FUNC__() { \
|
||||||
}
|
return __PIP_PLUGIN_LOADER_VERSION__; \
|
||||||
|
} \
|
||||||
|
}
|
||||||
|
|
||||||
# define PIP_PLUGIN_STATIC_SECTION_MERGE \
|
# define PIP_PLUGIN_STATIC_SECTION_MERGE \
|
||||||
extern "C" { \
|
extern "C" { \
|
||||||
PIP_PLUGIN_EXPORT void __PIP_PLUGIN_STATIC_MERGE_FUNC__(int type, void * from, void * to); \
|
PIP_PLUGIN_EXPORT void __PIP_PLUGIN_STATIC_MERGE_FUNC__(int type, void * from, void * to); \
|
||||||
} \
|
} \
|
||||||
void __PIP_PLUGIN_STATIC_MERGE_FUNC__(int type, void * from, void * to)
|
void __PIP_PLUGIN_STATIC_MERGE_FUNC__(int type, void * from, void * to)
|
||||||
|
|
||||||
|
|
||||||
# endif
|
# endif
|
||||||
|
|||||||
@@ -38,23 +38,23 @@ public:
|
|||||||
//! \~english Supported process signals.
|
//! \~english Supported process signals.
|
||||||
//! \~russian Поддерживаемые сигналы процесса.
|
//! \~russian Поддерживаемые сигналы процесса.
|
||||||
enum Signal {
|
enum Signal {
|
||||||
Interrupt = 0x01 /** \~english Interrupt from keyboard \~russian Прерывание с клавиатуры */,
|
Interrupt = 0x01 /** \~english Interrupt from keyboard \~russian Прерывание с клавиатуры */,
|
||||||
Illegal = 0x02 /** \~english Illegal instruction \~russian Недопустимая инструкция */,
|
Illegal = 0x02 /** \~english Illegal instruction \~russian Недопустимая инструкция */,
|
||||||
Abort = 0x04 /** \~english Abort signal \~russian Сигнал аварийного завершения */,
|
Abort = 0x04 /** \~english Abort signal \~russian Сигнал аварийного завершения */,
|
||||||
FPE = 0x08 /** \~english Floating-point exception \~russian Исключение с плавающей точкой */,
|
FPE = 0x08 /** \~english Floating-point exception \~russian Исключение с плавающей точкой */,
|
||||||
SegFault = 0x10 /** \~english Invalid memory reference \~russian Недопустимое обращение к памяти */,
|
SegFault = 0x10 /** \~english Invalid memory reference \~russian Недопустимое обращение к памяти */,
|
||||||
Termination = 0x20 /** \~english Termination request \~russian Запрос на завершение */,
|
Termination = 0x20 /** \~english Termination request \~russian Запрос на завершение */,
|
||||||
Hangup = 0x40 /** \~english Hangup on controlling terminal \~russian Разрыв управляющего терминала */,
|
Hangup = 0x40 /** \~english Hangup on controlling terminal \~russian Разрыв управляющего терминала */,
|
||||||
Quit = 0x80 /** \~english Quit from keyboard \~russian Завершение с клавиатуры */,
|
Quit = 0x80 /** \~english Quit from keyboard \~russian Завершение с клавиатуры */,
|
||||||
Kill = 0x100 /** \~english Forced termination \~russian Принудительное завершение */,
|
Kill = 0x100 /** \~english Forced termination \~russian Принудительное завершение */,
|
||||||
BrokenPipe = 0x200 /** \~english Write to a pipe without readers \~russian Запись в канал без читателей */,
|
BrokenPipe = 0x200 /** \~english Write to a pipe without readers \~russian Запись в канал без читателей */,
|
||||||
Timer = 0x400 /** \~english Alarm timer signal \~russian Сигнал таймера alarm */,
|
Timer = 0x400 /** \~english Alarm timer signal \~russian Сигнал таймера alarm */,
|
||||||
UserDefined1 = 0x800 /** \~english User-defined signal 1 \~russian Пользовательский сигнал 1 */,
|
UserDefined1 = 0x800 /** \~english User-defined signal 1 \~russian Пользовательский сигнал 1 */,
|
||||||
UserDefined2 = 0x1000 /** \~english User-defined signal 2 \~russian Пользовательский сигнал 2 */,
|
UserDefined2 = 0x1000 /** \~english User-defined signal 2 \~russian Пользовательский сигнал 2 */,
|
||||||
ChildStopped = 0x2000 /** \~english Child process changed state \~russian Дочерний процесс изменил состояние */,
|
ChildStopped = 0x2000 /** \~english Child process changed state \~russian Дочерний процесс изменил состояние */,
|
||||||
Continue = 0x4000 /** \~english Continue a stopped process \~russian Продолжение остановленного процесса */,
|
Continue = 0x4000 /** \~english Continue a stopped process \~russian Продолжение остановленного процесса */,
|
||||||
StopProcess = 0x8000 /** \~english Stop process execution \~russian Остановить выполнение процесса */,
|
StopProcess = 0x8000 /** \~english Stop process execution \~russian Остановить выполнение процесса */,
|
||||||
StopTTY = 0x10000 /** \~english Stop from terminal \~russian Остановка с терминала */,
|
StopTTY = 0x10000 /** \~english Stop from terminal \~russian Остановка с терминала */,
|
||||||
StopTTYInput =
|
StopTTYInput =
|
||||||
0x20000 /** \~english Background process requested terminal input \~russian Фоновый процесс запросил ввод с терминала */,
|
0x20000 /** \~english Background process requested terminal input \~russian Фоновый процесс запросил ввод с терминала */,
|
||||||
StopTTYOutput =
|
StopTTYOutput =
|
||||||
|
|||||||
@@ -97,12 +97,12 @@ PRIVATE_DEFINITION_START(PIRegularExpression)
|
|||||||
|
|
||||||
void match(Matcher & ret) {
|
void match(Matcher & ret) {
|
||||||
const int rc = pcre2_match(compiled,
|
const int rc = pcre2_match(compiled,
|
||||||
(PCRE2_SPTR)ret.subjectPtr(),
|
(PCRE2_SPTR)ret.subjectPtr(),
|
||||||
ret.subject->size(),
|
ret.subject->size(),
|
||||||
ret.start_offset,
|
ret.start_offset,
|
||||||
PCRE2_NO_UTF_CHECK,
|
PCRE2_NO_UTF_CHECK,
|
||||||
match_data,
|
match_data,
|
||||||
nullptr);
|
nullptr);
|
||||||
ret.has_match = ret.is_error = false;
|
ret.has_match = ret.is_error = false;
|
||||||
ret.groups.clear();
|
ret.groups.clear();
|
||||||
if (rc == PCRE2_ERROR_NOMATCH) return;
|
if (rc == PCRE2_ERROR_NOMATCH) return;
|
||||||
@@ -323,11 +323,11 @@ void PIRegularExpression::convertFrom(const PIString & pattern, uint type, Optio
|
|||||||
PCRE2_UCHAR * out = nullptr;
|
PCRE2_UCHAR * out = nullptr;
|
||||||
PCRE2_SIZE out_size = 0;
|
PCRE2_SIZE out_size = 0;
|
||||||
const int rc = pcre2_pattern_convert((PCRE2_SPTR)cptr,
|
const int rc = pcre2_pattern_convert((PCRE2_SPTR)cptr,
|
||||||
pattern.size_s(),
|
pattern.size_s(),
|
||||||
type | PCRE2_CONVERT_UTF | PCRE2_CONVERT_NO_UTF_CHECK,
|
type | PCRE2_CONVERT_UTF | PCRE2_CONVERT_NO_UTF_CHECK,
|
||||||
&out,
|
&out,
|
||||||
&out_size,
|
&out_size,
|
||||||
nullptr);
|
nullptr);
|
||||||
if (rc != 0) {
|
if (rc != 0) {
|
||||||
piCout << "PIRegularExpression::convertFrom error" << rc;
|
piCout << "PIRegularExpression::convertFrom error" << rc;
|
||||||
} else {
|
} else {
|
||||||
|
|||||||
@@ -38,7 +38,7 @@ public:
|
|||||||
enum Option {
|
enum Option {
|
||||||
None = 0x0 /*!< \~english No extra options \~russian Без дополнительных опций */,
|
None = 0x0 /*!< \~english No extra options \~russian Без дополнительных опций */,
|
||||||
CaseInsensitive = 0x01 /*!< \~english Ignore character case \~russian Игнорировать регистр символов */,
|
CaseInsensitive = 0x01 /*!< \~english Ignore character case \~russian Игнорировать регистр символов */,
|
||||||
Singleline = 0x02 /*!< \~english Let \c . match a newline \~russian Разрешить \c . совпадать с переводом строки */,
|
Singleline = 0x02 /*!< \~english Let \c . match a newline \~russian Разрешить \c . совпадать с переводом строки */,
|
||||||
Multiline =
|
Multiline =
|
||||||
0x04 /*!< \~english Let \c ^ and \c $ work on line boundaries \~russian Разрешить \c ^ и \c $ работать на границах строк */,
|
0x04 /*!< \~english Let \c ^ and \c $ work on line boundaries \~russian Разрешить \c ^ и \c $ работать на границах строк */,
|
||||||
InvertedGreediness =
|
InvertedGreediness =
|
||||||
|
|||||||
@@ -5,7 +5,7 @@
|
|||||||
//! \~russian Шаблон блокирующей очереди
|
//! \~russian Шаблон блокирующей очереди
|
||||||
/*
|
/*
|
||||||
PIP - Platform Independent Primitives
|
PIP - Platform Independent Primitives
|
||||||
Blocking queue template
|
Blocking queue template
|
||||||
Stephan Fomenko
|
Stephan Fomenko
|
||||||
|
|
||||||
This program is free software: you can redistribute it and/or modify
|
This program is free software: you can redistribute it and/or modify
|
||||||
|
|||||||
@@ -24,124 +24,124 @@
|
|||||||
#endif
|
#endif
|
||||||
|
|
||||||
#ifdef PIP_HAS_THREADS
|
#ifdef PIP_HAS_THREADS
|
||||||
#include "piconditionvar.h"
|
# include "piconditionvar.h"
|
||||||
#include "piincludes_p.h"
|
# include "piincludes_p.h"
|
||||||
#ifdef WINDOWS
|
# ifdef WINDOWS
|
||||||
# include <synchapi.h>
|
# include <synchapi.h>
|
||||||
# include <winbase.h>
|
# include <winbase.h>
|
||||||
# include <windef.h>
|
# include <windef.h>
|
||||||
#endif
|
# endif
|
||||||
#ifdef FREERTOS
|
# ifdef FREERTOS
|
||||||
# include <event_groups.h>
|
# include <event_groups.h>
|
||||||
#endif
|
# endif
|
||||||
|
|
||||||
|
|
||||||
PRIVATE_DEFINITION_START(PIConditionVariable)
|
PRIVATE_DEFINITION_START(PIConditionVariable)
|
||||||
#if defined(WINDOWS)
|
# if defined(WINDOWS)
|
||||||
CONDITION_VARIABLE
|
CONDITION_VARIABLE
|
||||||
#elif defined(FREERTOS)
|
# elif defined(FREERTOS)
|
||||||
EventGroupHandle_t
|
EventGroupHandle_t
|
||||||
#else
|
# else
|
||||||
pthread_cond_t
|
pthread_cond_t
|
||||||
#endif
|
# endif
|
||||||
nativeHandle;
|
nativeHandle;
|
||||||
PRIVATE_DEFINITION_END(PIConditionVariable)
|
PRIVATE_DEFINITION_END(PIConditionVariable)
|
||||||
|
|
||||||
|
|
||||||
PIConditionVariable::PIConditionVariable() {
|
PIConditionVariable::PIConditionVariable() {
|
||||||
#if defined(WINDOWS)
|
# if defined(WINDOWS)
|
||||||
InitializeConditionVariable(&PRIVATE->nativeHandle);
|
InitializeConditionVariable(&PRIVATE->nativeHandle);
|
||||||
#elif defined(FREERTOS)
|
# elif defined(FREERTOS)
|
||||||
PRIVATE->nativeHandle = xEventGroupCreate();
|
PRIVATE->nativeHandle = xEventGroupCreate();
|
||||||
#else
|
# else
|
||||||
pthread_condattr_t condattr;
|
pthread_condattr_t condattr;
|
||||||
pthread_condattr_init(&condattr);
|
pthread_condattr_init(&condattr);
|
||||||
# if !defined(MAC_OS)
|
# if !defined(MAC_OS)
|
||||||
pthread_condattr_setclock(&condattr, CLOCK_MONOTONIC);
|
pthread_condattr_setclock(&condattr, CLOCK_MONOTONIC);
|
||||||
# endif
|
# endif
|
||||||
piZeroMemory(PRIVATE->nativeHandle);
|
piZeroMemory(PRIVATE->nativeHandle);
|
||||||
pthread_cond_init(&PRIVATE->nativeHandle, &condattr);
|
pthread_cond_init(&PRIVATE->nativeHandle, &condattr);
|
||||||
#endif
|
# endif
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
PIConditionVariable::~PIConditionVariable() {
|
PIConditionVariable::~PIConditionVariable() {
|
||||||
#if defined(WINDOWS)
|
# if defined(WINDOWS)
|
||||||
#elif defined(FREERTOS)
|
# elif defined(FREERTOS)
|
||||||
vEventGroupDelete(PRIVATE->nativeHandle);
|
vEventGroupDelete(PRIVATE->nativeHandle);
|
||||||
#else
|
# else
|
||||||
pthread_cond_destroy(&PRIVATE->nativeHandle);
|
pthread_cond_destroy(&PRIVATE->nativeHandle);
|
||||||
#endif
|
# endif
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void PIConditionVariable::wait(PIMutex & lk) {
|
void PIConditionVariable::wait(PIMutex & lk) {
|
||||||
#if defined(WINDOWS)
|
# if defined(WINDOWS)
|
||||||
SleepConditionVariableCS(&PRIVATE->nativeHandle, (PCRITICAL_SECTION)lk.handle(), INFINITE);
|
SleepConditionVariableCS(&PRIVATE->nativeHandle, (PCRITICAL_SECTION)lk.handle(), INFINITE);
|
||||||
#elif defined(FREERTOS)
|
# elif defined(FREERTOS)
|
||||||
xEventGroupClearBits(PRIVATE->nativeHandle, 1);
|
xEventGroupClearBits(PRIVATE->nativeHandle, 1);
|
||||||
xEventGroupWaitBits(PRIVATE->nativeHandle, 1, pdTRUE, pdTRUE, portMAX_DELAY);
|
xEventGroupWaitBits(PRIVATE->nativeHandle, 1, pdTRUE, pdTRUE, portMAX_DELAY);
|
||||||
#else
|
# else
|
||||||
pthread_cond_wait(&PRIVATE->nativeHandle, (pthread_mutex_t *)lk.handle());
|
pthread_cond_wait(&PRIVATE->nativeHandle, (pthread_mutex_t *)lk.handle());
|
||||||
#endif
|
# endif
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void PIConditionVariable::wait(PIMutex & lk, std::function<bool()> condition) {
|
void PIConditionVariable::wait(PIMutex & lk, std::function<bool()> condition) {
|
||||||
while (true) {
|
while (true) {
|
||||||
if (condition()) break;
|
if (condition()) break;
|
||||||
#if defined(WINDOWS)
|
# if defined(WINDOWS)
|
||||||
SleepConditionVariableCS(&PRIVATE->nativeHandle, (PCRITICAL_SECTION)lk.handle(), INFINITE);
|
SleepConditionVariableCS(&PRIVATE->nativeHandle, (PCRITICAL_SECTION)lk.handle(), INFINITE);
|
||||||
#elif defined(FREERTOS)
|
# elif defined(FREERTOS)
|
||||||
xEventGroupClearBits(PRIVATE->nativeHandle, 1);
|
xEventGroupClearBits(PRIVATE->nativeHandle, 1);
|
||||||
xEventGroupWaitBits(PRIVATE->nativeHandle, 1, pdTRUE, pdTRUE, portMAX_DELAY);
|
xEventGroupWaitBits(PRIVATE->nativeHandle, 1, pdTRUE, pdTRUE, portMAX_DELAY);
|
||||||
#else
|
# else
|
||||||
pthread_cond_wait(&PRIVATE->nativeHandle, (pthread_mutex_t *)lk.handle());
|
pthread_cond_wait(&PRIVATE->nativeHandle, (pthread_mutex_t *)lk.handle());
|
||||||
#endif
|
# endif
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
bool PIConditionVariable::waitFor(PIMutex & lk, PISystemTime timeout) {
|
bool PIConditionVariable::waitFor(PIMutex & lk, PISystemTime timeout) {
|
||||||
bool isNotTimeout;
|
bool isNotTimeout;
|
||||||
#if defined(WINDOWS)
|
# if defined(WINDOWS)
|
||||||
isNotTimeout = SleepConditionVariableCS(&PRIVATE->nativeHandle, (PCRITICAL_SECTION)lk.handle(), timeout.toMilliseconds()) != 0;
|
isNotTimeout = SleepConditionVariableCS(&PRIVATE->nativeHandle, (PCRITICAL_SECTION)lk.handle(), timeout.toMilliseconds()) != 0;
|
||||||
#elif defined(FREERTOS)
|
# elif defined(FREERTOS)
|
||||||
xEventGroupClearBits(PRIVATE->nativeHandle, 1);
|
xEventGroupClearBits(PRIVATE->nativeHandle, 1);
|
||||||
EventBits_t uxBits;
|
EventBits_t uxBits;
|
||||||
uxBits = xEventGroupWaitBits(PRIVATE->nativeHandle, 1, pdTRUE, pdTRUE, timeout.toMilliseconds() / portTICK_PERIOD_MS);
|
uxBits = xEventGroupWaitBits(PRIVATE->nativeHandle, 1, pdTRUE, pdTRUE, timeout.toMilliseconds() / portTICK_PERIOD_MS);
|
||||||
isNotTimeout = (uxBits & 1) != 0;
|
isNotTimeout = (uxBits & 1) != 0;
|
||||||
#else
|
# else
|
||||||
PISystemTime st = PISystemTime::current(true) + timeout;
|
PISystemTime st = PISystemTime::current(true) + timeout;
|
||||||
timespec expire_ts;
|
timespec expire_ts;
|
||||||
st.toTimespec(&expire_ts);
|
st.toTimespec(&expire_ts);
|
||||||
isNotTimeout = pthread_cond_timedwait(&PRIVATE->nativeHandle, (pthread_mutex_t *)lk.handle(), &expire_ts) == 0;
|
isNotTimeout = pthread_cond_timedwait(&PRIVATE->nativeHandle, (pthread_mutex_t *)lk.handle(), &expire_ts) == 0;
|
||||||
#endif
|
# endif
|
||||||
return isNotTimeout;
|
return isNotTimeout;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
bool PIConditionVariable::waitFor(PIMutex & lk, PISystemTime timeout, std::function<bool()> condition) {
|
bool PIConditionVariable::waitFor(PIMutex & lk, PISystemTime timeout, std::function<bool()> condition) {
|
||||||
#if defined(WINDOWS) || defined(FREERTOS)
|
# if defined(WINDOWS) || defined(FREERTOS)
|
||||||
PITimeMeasurer measurer;
|
PITimeMeasurer measurer;
|
||||||
#else
|
# else
|
||||||
PISystemTime st = PISystemTime::current(true) + timeout;
|
PISystemTime st = PISystemTime::current(true) + timeout;
|
||||||
timespec expire_ts;
|
timespec expire_ts;
|
||||||
st.toTimespec(&expire_ts);
|
st.toTimespec(&expire_ts);
|
||||||
#endif
|
# endif
|
||||||
#ifdef FREERTOS
|
# ifdef FREERTOS
|
||||||
xEventGroupClearBits(PRIVATE->nativeHandle, 1);
|
xEventGroupClearBits(PRIVATE->nativeHandle, 1);
|
||||||
#endif
|
# endif
|
||||||
while (true) {
|
while (true) {
|
||||||
if (condition()) break;
|
if (condition()) break;
|
||||||
bool isTimeout;
|
bool isTimeout;
|
||||||
#if defined(WINDOWS)
|
# if defined(WINDOWS)
|
||||||
{
|
{
|
||||||
int remain = (int)(timeout.toMilliseconds() - (int)measurer.elapsed_m());
|
int remain = (int)(timeout.toMilliseconds() - (int)measurer.elapsed_m());
|
||||||
if (remain <= 0) return false;
|
if (remain <= 0) return false;
|
||||||
isTimeout = SleepConditionVariableCS(&PRIVATE->nativeHandle, (PCRITICAL_SECTION)lk.handle(), remain) == 0;
|
isTimeout = SleepConditionVariableCS(&PRIVATE->nativeHandle, (PCRITICAL_SECTION)lk.handle(), remain) == 0;
|
||||||
}
|
}
|
||||||
#elif defined(FREERTOS)
|
# elif defined(FREERTOS)
|
||||||
{
|
{
|
||||||
int remain = (int)(timeout.toMilliseconds() - (int)measurer.elapsed_m());
|
int remain = (int)(timeout.toMilliseconds() - (int)measurer.elapsed_m());
|
||||||
if (remain <= 0) return false;
|
if (remain <= 0) return false;
|
||||||
@@ -149,9 +149,9 @@ bool PIConditionVariable::waitFor(PIMutex & lk, PISystemTime timeout, std::funct
|
|||||||
uxBits = xEventGroupWaitBits(PRIVATE->nativeHandle, 1, pdTRUE, pdTRUE, remain / portTICK_PERIOD_MS);
|
uxBits = xEventGroupWaitBits(PRIVATE->nativeHandle, 1, pdTRUE, pdTRUE, remain / portTICK_PERIOD_MS);
|
||||||
isTimeout = (uxBits & 1) == 0;
|
isTimeout = (uxBits & 1) == 0;
|
||||||
}
|
}
|
||||||
#else
|
# else
|
||||||
isTimeout = pthread_cond_timedwait(&PRIVATE->nativeHandle, (pthread_mutex_t *)lk.handle(), &expire_ts) != 0;
|
isTimeout = pthread_cond_timedwait(&PRIVATE->nativeHandle, (pthread_mutex_t *)lk.handle(), &expire_ts) != 0;
|
||||||
#endif
|
# endif
|
||||||
if (isTimeout) return false;
|
if (isTimeout) return false;
|
||||||
}
|
}
|
||||||
return true;
|
return true;
|
||||||
@@ -159,23 +159,23 @@ bool PIConditionVariable::waitFor(PIMutex & lk, PISystemTime timeout, std::funct
|
|||||||
|
|
||||||
|
|
||||||
void PIConditionVariable::notifyOne() {
|
void PIConditionVariable::notifyOne() {
|
||||||
#if defined(WINDOWS)
|
# if defined(WINDOWS)
|
||||||
WakeConditionVariable(&PRIVATE->nativeHandle);
|
WakeConditionVariable(&PRIVATE->nativeHandle);
|
||||||
#elif defined(FREERTOS)
|
# elif defined(FREERTOS)
|
||||||
xEventGroupSetBits(PRIVATE->nativeHandle, 1);
|
xEventGroupSetBits(PRIVATE->nativeHandle, 1);
|
||||||
#else
|
# else
|
||||||
pthread_cond_signal(&PRIVATE->nativeHandle);
|
pthread_cond_signal(&PRIVATE->nativeHandle);
|
||||||
#endif
|
# endif
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void PIConditionVariable::notifyAll() {
|
void PIConditionVariable::notifyAll() {
|
||||||
#if defined(WINDOWS)
|
# if defined(WINDOWS)
|
||||||
WakeAllConditionVariable(&PRIVATE->nativeHandle);
|
WakeAllConditionVariable(&PRIVATE->nativeHandle);
|
||||||
#elif defined(FREERTOS)
|
# elif defined(FREERTOS)
|
||||||
xEventGroupSetBits(PRIVATE->nativeHandle, 1);
|
xEventGroupSetBits(PRIVATE->nativeHandle, 1);
|
||||||
#else
|
# else
|
||||||
pthread_cond_broadcast(&PRIVATE->nativeHandle);
|
pthread_cond_broadcast(&PRIVATE->nativeHandle);
|
||||||
#endif
|
# endif
|
||||||
}
|
}
|
||||||
#endif // PIP_HAS_THREADS
|
#endif // PIP_HAS_THREADS
|
||||||
|
|||||||
@@ -108,26 +108,26 @@
|
|||||||
|
|
||||||
|
|
||||||
#ifdef PIP_HAS_THREADS
|
#ifdef PIP_HAS_THREADS
|
||||||
#include "pimutex.h"
|
# include "pimutex.h"
|
||||||
|
|
||||||
#include "piincludes_p.h"
|
# include "piincludes_p.h"
|
||||||
#if defined(WINDOWS)
|
# if defined(WINDOWS)
|
||||||
# include <synchapi.h>
|
# include <synchapi.h>
|
||||||
#elif defined(FREERTOS)
|
# elif defined(FREERTOS)
|
||||||
# include <semphr.h>
|
# include <semphr.h>
|
||||||
#else
|
# else
|
||||||
# include <pthread.h>
|
# include <pthread.h>
|
||||||
#endif
|
# endif
|
||||||
|
|
||||||
|
|
||||||
PRIVATE_DEFINITION_START(PIMutex)
|
PRIVATE_DEFINITION_START(PIMutex)
|
||||||
#if defined(WINDOWS)
|
# if defined(WINDOWS)
|
||||||
CRITICAL_SECTION
|
CRITICAL_SECTION
|
||||||
#elif defined(FREERTOS)
|
# elif defined(FREERTOS)
|
||||||
SemaphoreHandle_t
|
SemaphoreHandle_t
|
||||||
#else
|
# else
|
||||||
pthread_mutex_t
|
pthread_mutex_t
|
||||||
#endif
|
# endif
|
||||||
mutex;
|
mutex;
|
||||||
PRIVATE_DEFINITION_END(PIMutex)
|
PRIVATE_DEFINITION_END(PIMutex)
|
||||||
|
|
||||||
@@ -150,13 +150,13 @@ PIMutex::~PIMutex() {
|
|||||||
//! Если мьютекс свободен, то блокирует его и возвращает управление немедленно.
|
//! Если мьютекс свободен, то блокирует его и возвращает управление немедленно.
|
||||||
//! Если мьютекс заблокирован, то ожидает разблокировки, затем блокирует и возвращает управление
|
//! Если мьютекс заблокирован, то ожидает разблокировки, затем блокирует и возвращает управление
|
||||||
void PIMutex::lock() {
|
void PIMutex::lock() {
|
||||||
#if defined(WINDOWS)
|
# if defined(WINDOWS)
|
||||||
EnterCriticalSection(&(PRIVATE->mutex));
|
EnterCriticalSection(&(PRIVATE->mutex));
|
||||||
#elif defined(FREERTOS)
|
# elif defined(FREERTOS)
|
||||||
xSemaphoreTake(PRIVATE->mutex, portMAX_DELAY);
|
xSemaphoreTake(PRIVATE->mutex, portMAX_DELAY);
|
||||||
#else
|
# else
|
||||||
pthread_mutex_lock(&(PRIVATE->mutex));
|
pthread_mutex_lock(&(PRIVATE->mutex));
|
||||||
#endif
|
# endif
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@@ -166,13 +166,13 @@ void PIMutex::lock() {
|
|||||||
//! \~russian
|
//! \~russian
|
||||||
//! В любом случае возвращает управление немедленно
|
//! В любом случае возвращает управление немедленно
|
||||||
void PIMutex::unlock() {
|
void PIMutex::unlock() {
|
||||||
#if defined(WINDOWS)
|
# if defined(WINDOWS)
|
||||||
LeaveCriticalSection(&(PRIVATE->mutex));
|
LeaveCriticalSection(&(PRIVATE->mutex));
|
||||||
#elif defined(FREERTOS)
|
# elif defined(FREERTOS)
|
||||||
xSemaphoreGive(PRIVATE->mutex);
|
xSemaphoreGive(PRIVATE->mutex);
|
||||||
#else
|
# else
|
||||||
pthread_mutex_unlock(&(PRIVATE->mutex));
|
pthread_mutex_unlock(&(PRIVATE->mutex));
|
||||||
#endif
|
# endif
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@@ -183,32 +183,32 @@ void PIMutex::unlock() {
|
|||||||
//! \~russian
|
//! \~russian
|
||||||
bool PIMutex::tryLock() {
|
bool PIMutex::tryLock() {
|
||||||
bool ret =
|
bool ret =
|
||||||
#if defined(WINDOWS)
|
# if defined(WINDOWS)
|
||||||
(TryEnterCriticalSection(&(PRIVATE->mutex)) != 0);
|
(TryEnterCriticalSection(&(PRIVATE->mutex)) != 0);
|
||||||
#elif defined(FREERTOS)
|
# elif defined(FREERTOS)
|
||||||
xSemaphoreTake(PRIVATE->mutex, 0);
|
xSemaphoreTake(PRIVATE->mutex, 0);
|
||||||
#else
|
# else
|
||||||
(pthread_mutex_trylock(&(PRIVATE->mutex)) == 0);
|
(pthread_mutex_trylock(&(PRIVATE->mutex)) == 0);
|
||||||
#endif
|
# endif
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void * PIMutex::handle() {
|
void * PIMutex::handle() {
|
||||||
#ifdef FREERTOS
|
# ifdef FREERTOS
|
||||||
return PRIVATE->mutex;
|
return PRIVATE->mutex;
|
||||||
#else
|
# else
|
||||||
return (void *)&(PRIVATE->mutex);
|
return (void *)&(PRIVATE->mutex);
|
||||||
#endif
|
# endif
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void PIMutex::init() {
|
void PIMutex::init() {
|
||||||
#if defined(WINDOWS)
|
# if defined(WINDOWS)
|
||||||
InitializeCriticalSection(&(PRIVATE->mutex));
|
InitializeCriticalSection(&(PRIVATE->mutex));
|
||||||
#elif defined(FREERTOS)
|
# elif defined(FREERTOS)
|
||||||
PRIVATE->mutex = xSemaphoreCreateMutex();
|
PRIVATE->mutex = xSemaphoreCreateMutex();
|
||||||
#else
|
# else
|
||||||
pthread_mutexattr_t attr;
|
pthread_mutexattr_t attr;
|
||||||
piZeroMemory(attr);
|
piZeroMemory(attr);
|
||||||
pthread_mutexattr_init(&attr);
|
pthread_mutexattr_init(&attr);
|
||||||
@@ -216,17 +216,17 @@ void PIMutex::init() {
|
|||||||
piZeroMemory(PRIVATE->mutex);
|
piZeroMemory(PRIVATE->mutex);
|
||||||
pthread_mutex_init(&(PRIVATE->mutex), &attr);
|
pthread_mutex_init(&(PRIVATE->mutex), &attr);
|
||||||
pthread_mutexattr_destroy(&attr);
|
pthread_mutexattr_destroy(&attr);
|
||||||
#endif
|
# endif
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void PIMutex::destroy() {
|
void PIMutex::destroy() {
|
||||||
#if defined(WINDOWS)
|
# if defined(WINDOWS)
|
||||||
DeleteCriticalSection(&(PRIVATE->mutex));
|
DeleteCriticalSection(&(PRIVATE->mutex));
|
||||||
#elif defined(FREERTOS)
|
# elif defined(FREERTOS)
|
||||||
vSemaphoreDelete(PRIVATE->mutex);
|
vSemaphoreDelete(PRIVATE->mutex);
|
||||||
#else
|
# else
|
||||||
pthread_mutex_destroy(&(PRIVATE->mutex));
|
pthread_mutex_destroy(&(PRIVATE->mutex));
|
||||||
#endif
|
# endif
|
||||||
}
|
}
|
||||||
#endif // PIP_HAS_THREADS
|
#endif // PIP_HAS_THREADS
|
||||||
|
|||||||
@@ -1,7 +1,7 @@
|
|||||||
/*
|
/*
|
||||||
PIP - Platform Independent Primitives
|
PIP - Platform Independent Primitives
|
||||||
PISemaphore, PISemaphoreLocker
|
PISemaphore, PISemaphoreLocker
|
||||||
Ivan Pelipenko peri4ko@yandex.ru
|
Ivan Pelipenko peri4ko@yandex.ru
|
||||||
|
|
||||||
This program is free software: you can redistribute it and/or modify
|
This program is free software: you can redistribute it and/or modify
|
||||||
it under the terms of the GNU Lesser General Public License as published by
|
it under the terms of the GNU Lesser General Public License as published by
|
||||||
|
|||||||
@@ -18,11 +18,11 @@
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
#ifdef PIP_HAS_THREADS
|
#ifdef PIP_HAS_THREADS
|
||||||
#include "pitimer.h"
|
# include "pitimer.h"
|
||||||
|
|
||||||
#include "piconditionvar.h"
|
# include "piconditionvar.h"
|
||||||
#include "piliterals_time.h"
|
# include "piliterals_time.h"
|
||||||
#include "pithread.h"
|
# include "pithread.h"
|
||||||
|
|
||||||
|
|
||||||
//! \addtogroup Thread
|
//! \addtogroup Thread
|
||||||
|
|||||||
@@ -329,8 +329,7 @@ PISystemTime PITimeMeasurer::elapsedAndReset() {
|
|||||||
|
|
||||||
PISystemTime PISystemTime::Frequency::toSystemTime() const {
|
PISystemTime PISystemTime::Frequency::toSystemTime() const {
|
||||||
if (value_hz <= 0.) {
|
if (value_hz <= 0.) {
|
||||||
piCout << "[PISystemTime::Frequency]"
|
piCout << "[PISystemTime::Frequency]" << "toSystemTime() Warning: invalid hertz: %1"_tr("PISystemTime").arg(value_hz);
|
||||||
<< "toSystemTime() Warning: invalid hertz: %1"_tr("PISystemTime").arg(value_hz);
|
|
||||||
return PISystemTime();
|
return PISystemTime();
|
||||||
}
|
}
|
||||||
return PISystemTime::fromSeconds(1. / value_hz);
|
return PISystemTime::fromSeconds(1. / value_hz);
|
||||||
@@ -339,8 +338,7 @@ PISystemTime PISystemTime::Frequency::toSystemTime() const {
|
|||||||
|
|
||||||
PISystemTime::Frequency PISystemTime::Frequency::fromSystemTime(const PISystemTime & st) {
|
PISystemTime::Frequency PISystemTime::Frequency::fromSystemTime(const PISystemTime & st) {
|
||||||
if (st == PISystemTime()) {
|
if (st == PISystemTime()) {
|
||||||
piCout << "[PISystemTime::Frequency]"
|
piCout << "[PISystemTime::Frequency]" << "fromSystemTime() Warning: null frequency"_tr("PISystemTime");
|
||||||
<< "fromSystemTime() Warning: null frequency"_tr("PISystemTime");
|
|
||||||
return Frequency();
|
return Frequency();
|
||||||
}
|
}
|
||||||
return Frequency(1. / st.toSeconds());
|
return Frequency(1. / st.toSeconds());
|
||||||
|
|||||||
+66
-61
@@ -101,21 +101,21 @@ struct __PIVariantTypeInfo__ {
|
|||||||
typedef const T & ConstReferenceType;
|
typedef const T & ConstReferenceType;
|
||||||
};
|
};
|
||||||
|
|
||||||
# define __TYPEINFO_SINGLE(PT, T) \
|
# define __TYPEINFO_SINGLE(PT, T) \
|
||||||
template<> \
|
template<> \
|
||||||
struct __PIVariantTypeInfo__<T> { \
|
struct __PIVariantTypeInfo__<T> { \
|
||||||
typedef PT PureType; \
|
typedef PT PureType; \
|
||||||
typedef const PT ConstPureType; \
|
typedef const PT ConstPureType; \
|
||||||
typedef PT * PointerType; \
|
typedef PT * PointerType; \
|
||||||
typedef const PT * ConstPointerType; \
|
typedef const PT * ConstPointerType; \
|
||||||
typedef PT & ReferenceType; \
|
typedef PT & ReferenceType; \
|
||||||
typedef const PT & ConstReferenceType; \
|
typedef const PT & ConstReferenceType; \
|
||||||
};
|
};
|
||||||
|
|
||||||
# define REGISTER_VARIANT_TYPEINFO(T) \
|
# define REGISTER_VARIANT_TYPEINFO(T) \
|
||||||
__TYPEINFO_SINGLE(T, T &) \
|
__TYPEINFO_SINGLE(T, T &) \
|
||||||
__TYPEINFO_SINGLE(T, const T) \
|
__TYPEINFO_SINGLE(T, const T) \
|
||||||
__TYPEINFO_SINGLE(T, const T &)
|
__TYPEINFO_SINGLE(T, const T &)
|
||||||
|
|
||||||
|
|
||||||
class PIP_EXPORT __PIVariantInfoStorage__ {
|
class PIP_EXPORT __PIVariantInfoStorage__ {
|
||||||
@@ -124,67 +124,72 @@ public:
|
|||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
# define REGISTER_VARIANT(classname) \
|
# define REGISTER_VARIANT(classname) \
|
||||||
template<> \
|
template<> \
|
||||||
inline PIString __PIVariantFunctions__<classname>::typeNameHelper() { \
|
inline PIString __PIVariantFunctions__<classname>::typeNameHelper() { \
|
||||||
static PIString tn = PIStringAscii(#classname); \
|
static PIString tn = PIStringAscii(#classname); \
|
||||||
return tn; \
|
return tn; \
|
||||||
} \
|
} \
|
||||||
template<> \
|
template<> \
|
||||||
inline uint __PIVariantFunctions__<classname>::typeIDHelper() { \
|
inline uint __PIVariantFunctions__<classname>::typeIDHelper() { \
|
||||||
static uint ret = PIStringAscii(#classname).hash(); \
|
static uint ret = PIStringAscii(#classname).hash(); \
|
||||||
return ret; \
|
return ret; \
|
||||||
} \
|
} \
|
||||||
REGISTER_VARIANT_TYPEINFO(classname) \
|
REGISTER_VARIANT_TYPEINFO(classname) \
|
||||||
STATIC_INITIALIZER_BEGIN \
|
STATIC_INITIALIZER_BEGIN \
|
||||||
uint type_id = __PIVariantFunctions__<classname>::typeIDHelper(); \
|
uint type_id = __PIVariantFunctions__<classname>::typeIDHelper(); \
|
||||||
PIString type_name = __PIVariantFunctions__<classname>::typeNameHelper(); \
|
PIString type_name = __PIVariantFunctions__<classname>::typeNameHelper(); \
|
||||||
if (__PIVariantInfoStorage__::get().contains(type_id)) return; \
|
if (__PIVariantInfoStorage__::get().contains(type_id)) return; \
|
||||||
PIByteArray empty; \
|
PIByteArray empty; \
|
||||||
empty << classname(); \
|
empty << classname(); \
|
||||||
__PIVariantInfoStorage__::get()[type_id] = new __PIVariantInfo__(type_name, empty); \
|
__PIVariantInfoStorage__::get()[type_id] = new __PIVariantInfo__(type_name, empty); \
|
||||||
STATIC_INITIALIZER_END
|
STATIC_INITIALIZER_END
|
||||||
|
|
||||||
|
|
||||||
# define REGISTER_VARIANT_CAST_H(classname_from, classname_to) \
|
# define REGISTER_VARIANT_CAST_H(classname_from, classname_to) \
|
||||||
template<> \
|
template<> \
|
||||||
template<> \
|
template<> \
|
||||||
inline classname_to __PIVariantFunctions__<classname_from>::castVariant<classname_to>(const classname_from & v);
|
inline classname_to __PIVariantFunctions__<classname_from>::castVariant<classname_to>(const classname_from & v);
|
||||||
|
|
||||||
# define REGISTER_VARIANT_CAST_CPP(classname_from, classname_to) \
|
# define REGISTER_VARIANT_CAST_CPP(classname_from, classname_to) \
|
||||||
template<> \
|
template<> \
|
||||||
template<> \
|
template<> \
|
||||||
inline PIByteArray __PIVariantFunctions__<classname_from>::castHelper<classname_to>(PIByteArray v) { \
|
inline PIByteArray __PIVariantFunctions__<classname_from>::castHelper<classname_to>(PIByteArray v) { \
|
||||||
classname_from f; \
|
classname_from f; \
|
||||||
v >> f; \
|
v >> f; \
|
||||||
classname_to t = __PIVariantFunctions__<classname_from>::castVariant<classname_to>(f); \
|
classname_to t = __PIVariantFunctions__<classname_from>::castVariant<classname_to>(f); \
|
||||||
PIByteArray ret; \
|
PIByteArray ret; \
|
||||||
ret << t; \
|
ret << t; \
|
||||||
return ret; \
|
return ret; \
|
||||||
} \
|
|
||||||
STATIC_INITIALIZER_BEGIN \
|
|
||||||
__PIVariantInfo__ * vi(__PIVariantInfoStorage__::get().value(__PIVariantFunctions__<classname_from>::typeIDHelper(), nullptr)); \
|
|
||||||
if (!vi) { \
|
|
||||||
piCout << "Warning! Using REGISTER_VARIANT_CAST(" #classname_from ", " #classname_to ") before REGISTER_VARIANT(" #classname_from \
|
|
||||||
"), ignore."; \
|
|
||||||
return; \
|
|
||||||
} \
|
} \
|
||||||
vi->cast[__PIVariantFunctions__<classname_to>::typeIDHelper()] = __PIVariantFunctions__<classname_from>::castHelper<classname_to>; \
|
STATIC_INITIALIZER_BEGIN \
|
||||||
STATIC_INITIALIZER_END \
|
__PIVariantInfo__ * vi(__PIVariantInfoStorage__::get().value(__PIVariantFunctions__<classname_from>::typeIDHelper(), nullptr)); \
|
||||||
template<> \
|
if (!vi) { \
|
||||||
template<> \
|
piCout << "Warning! Using REGISTER_VARIANT_CAST(" #classname_from ", " #classname_to \
|
||||||
classname_to __PIVariantFunctions__<classname_from>::castVariant<classname_to>(const classname_from & v)
|
") before REGISTER_VARIANT(" #classname_from "), ignore."; \
|
||||||
|
return; \
|
||||||
|
} \
|
||||||
|
vi->cast[__PIVariantFunctions__<classname_to>::typeIDHelper()] = \
|
||||||
|
__PIVariantFunctions__<classname_from>::castHelper<classname_to>; \
|
||||||
|
STATIC_INITIALIZER_END \
|
||||||
|
template<> \
|
||||||
|
template<> \
|
||||||
|
classname_to __PIVariantFunctions__<classname_from>::castVariant<classname_to>(const classname_from & v)
|
||||||
|
|
||||||
# define REGISTER_VARIANT_CAST(classname_from, classname_to) \
|
# define REGISTER_VARIANT_CAST(classname_from, classname_to) \
|
||||||
REGISTER_VARIANT_CAST_H(classname_from, classname_to) \
|
REGISTER_VARIANT_CAST_H(classname_from, classname_to) \
|
||||||
REGISTER_VARIANT_CAST_CPP(classname_from, classname_to)
|
REGISTER_VARIANT_CAST_CPP(classname_from, classname_to)
|
||||||
|
|
||||||
|
|
||||||
# define REGISTER_VARIANT_CAST_SIMPLE(classname_from, classname_to) \
|
# define REGISTER_VARIANT_CAST_SIMPLE(classname_from, classname_to) \
|
||||||
REGISTER_VARIANT_CAST(classname_from, classname_to) { return classname_to(v); }
|
REGISTER_VARIANT_CAST(classname_from, classname_to) { \
|
||||||
|
return classname_to(v); \
|
||||||
|
}
|
||||||
# define REGISTER_VARIANT_CAST_SIMPLE_H(classname_from, classname_to) REGISTER_VARIANT_CAST_H(classname_from, classname_to)
|
# define REGISTER_VARIANT_CAST_SIMPLE_H(classname_from, classname_to) REGISTER_VARIANT_CAST_H(classname_from, classname_to)
|
||||||
# define REGISTER_VARIANT_CAST_SIMPLE_CPP(classname_from, classname_to) \
|
# define REGISTER_VARIANT_CAST_SIMPLE_CPP(classname_from, classname_to) \
|
||||||
REGISTER_VARIANT_CAST_CPP(classname_from, classname_to) { return classname_to(v); }
|
REGISTER_VARIANT_CAST_CPP(classname_from, classname_to) { \
|
||||||
|
return classname_to(v); \
|
||||||
|
}
|
||||||
|
|
||||||
#else
|
#else
|
||||||
|
|
||||||
|
|||||||
@@ -81,9 +81,11 @@
|
|||||||
bool supportPrefixesNon3(int type) const override; \
|
bool supportPrefixesNon3(int type) const override; \
|
||||||
bool supportPrefixesGreater(int type) const override; \
|
bool supportPrefixesGreater(int type) const override; \
|
||||||
bool supportPrefixesSmaller(int type) const override; \
|
bool supportPrefixesSmaller(int type) const override; \
|
||||||
\
|
\
|
||||||
public: \
|
public: \
|
||||||
PIString className() const override { return piTr(#Name, "PIUnits"); } \
|
PIString className() const override { \
|
||||||
|
return piTr(#Name, "PIUnits"); \
|
||||||
|
} \
|
||||||
uint classID() const override { \
|
uint classID() const override { \
|
||||||
static uint ret = PIStringAscii(#Name).hash(); \
|
static uint ret = PIStringAscii(#Name).hash(); \
|
||||||
return ret; \
|
return ret; \
|
||||||
|
|||||||
@@ -42,9 +42,9 @@ DECLARE_UNIT_CLASS_BEGIN(Angle, 0x200)
|
|||||||
//! \~english Supported angle unit type identifiers.
|
//! \~english Supported angle unit type identifiers.
|
||||||
//! \~russian Поддерживаемые идентификаторы типов единиц угла.
|
//! \~russian Поддерживаемые идентификаторы типов единиц угла.
|
||||||
enum {
|
enum {
|
||||||
Degree = typeStart /** \~english Degree \~russian Градус */,
|
Degree = typeStart /** \~english Degree \~russian Градус */,
|
||||||
Radian /** \~english Radian \~russian Радиан */,
|
Radian /** \~english Radian \~russian Радиан */,
|
||||||
_LastType
|
_LastType
|
||||||
};
|
};
|
||||||
DECLARE_UNIT_CLASS_END(Angle)
|
DECLARE_UNIT_CLASS_END(Angle)
|
||||||
|
|
||||||
|
|||||||
@@ -42,16 +42,16 @@ DECLARE_UNIT_CLASS_BEGIN(Distance, 0x600)
|
|||||||
//! \~english Supported distance unit type identifiers.
|
//! \~english Supported distance unit type identifiers.
|
||||||
//! \~russian Поддерживаемые идентификаторы типов единиц расстояния.
|
//! \~russian Поддерживаемые идентификаторы типов единиц расстояния.
|
||||||
enum {
|
enum {
|
||||||
Meter = typeStart /** \~english Meter \~russian Метр */,
|
Meter = typeStart /** \~english Meter \~russian Метр */,
|
||||||
Inch /** \~english Inch \~russian Дюйм */,
|
Inch /** \~english Inch \~russian Дюйм */,
|
||||||
Mil /** \~english Mil or thou \~russian Мил или thou */,
|
Mil /** \~english Mil or thou \~russian Мил или thou */,
|
||||||
Foot /** \~english Foot \~russian Фут */,
|
Foot /** \~english Foot \~russian Фут */,
|
||||||
Yard /** \~english Yard \~russian Ярд */,
|
Yard /** \~english Yard \~russian Ярд */,
|
||||||
|
|
||||||
Angstrom /** \~english Angstrom \~russian Ангстрем */,
|
Angstrom /** \~english Angstrom \~russian Ангстрем */,
|
||||||
AstronomicalUnit /** \~english Astronomical unit \~russian Астрономическая единица */,
|
AstronomicalUnit /** \~english Astronomical unit \~russian Астрономическая единица */,
|
||||||
|
|
||||||
_LastType
|
_LastType
|
||||||
};
|
};
|
||||||
DECLARE_UNIT_CLASS_END(Distance)
|
DECLARE_UNIT_CLASS_END(Distance)
|
||||||
|
|
||||||
|
|||||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user