#include <string>
#include <utility>
#include <iostream>
class CredentialsInfo {
std::string _login, _password;
public:
CredentialsInfo() {}
CredentialsInfo(const std::string& login, const std::string& password)
: _login(login)
, _password(password)
{ }
public:
std::string Login() const {
return _login;
}
std::string Password() const {
return _password;
}
void SetLogin(const std::string& newLogin) {
_login = newLogin;
}
void SetPassword(const std::string& newPassword) {
_password = newPassword;
}
friend std::ostream& operator<<(std::ostream&, const CredentialsInfo&);
};
std::ostream& operator<<(std::ostream& out, const CredentialsInfo& info) {
return out << info._login << "; " << info._password;
}
template <class DataClass>
class Queue {
public:
typedef DataClass value_type;
private:
struct QueueNode {
value_type Value;
QueueNode* Next;
QueueNode(value_type&& value)
: Value(std::move(value))
, Next(nullptr)
{ }
};
QueueNode *_head, *_tail;
public:
Queue()
: _head(nullptr)
, _tail(nullptr)
{ }
~Queue() {
while(_head) {
auto tmp = _head;
_head = _head->Next;
delete tmp;
}
}
public:
template <class Data>
void Add(Data&& data) {
auto* newNode = new QueueNode(std::forward<Data>(data));
if (_head) {
_tail->Next = newNode;
_tail = newNode;
} else {
_head = _tail = newNode;
}
}
template<class... Args>
void Add(Args&&... args) {
Add(value_type(std::forward<Args>(args)...));
}
void Show(std::ostream& out) const {
auto it = _head;
while (it) {
out << it->Value << '\n';
it = it->Next;
}
out.flush();
}
};
typedef Queue<CredentialsInfo> CredentialsQueue;
int main(int, char**) {
CredentialsQueue queue;
queue.Add("s", "ss");
queue.Add("1", "op");
queue.Add("1", "p");
queue.Show(std::cout);
return 0;
}
bool IsValvesOpen = Valve1.IsOpen && Valve2.IsOpen && Valve3.IsOpen;
if (IsValvesOpen && Sensor.Value > 10.0) {
Motor.Cmd = true;
}
if (!IsVelvesOpen || Sensor.Value < 5.0) {
Motor.Cmd = false;
}
Motor.Cmd = (Valve1.IsOpen && Valve2.IsOpen && Valve3.IsOpen) && (Sensor.Value > 10 || (Motor.Cmd && Sensor.Value >= 5))
/tmp$ cat test.awk
{
P=$3
PS=sprintf("%.2f", P)
for (i = 1; i <= NF; ++i) {
if (i != 1) printf FS
if (i != 3) { printf $i } else { printf PS }
}
printf "\n"
}
/tmp$ cat test.txt | awk -f test.awk -F,
09/28/2009,09:10:37,35.60,35.29,35.75,150
09/28/2009,09:30:06,35.48,35.34,35.64,14900
09/28/2009,09:30:06,35.49,35.37,35.61,100
09/28/2009,09:30:10,35.40,35.4,35.57,100
09/28/2009,09:30:10,35.48,35.43,35.53,200
09/28/2009,09:30:11,35.46,35.44,35.56,200
09/28/2009,09:30:14,35.57,35.49,35.57,100
std::uint64_t length = GetMessageLength(); // ну тут наверное разбирешся
length = host_to_bigendian(length); // смотри для своей платформы как перевести в big endian
const char* lengthBytes = static_cast<const char*>(&length); // в памяти все и так как нужно уже лежит
send(socket, lengthBytes, sizeof(length));
#include "MyClasses.h"
class MyClass;
namespace my { class MyClass; }
my::MyClass myClass;