12345678910111213141516171819202122232425262728293031323334353637383940414243 |
- #include "stdafx.h"
- #include"SyncHelper.h"
- long long HostServer::SyncHelper::parseTime(const char * c)
- {
- long long ttt0 = (((long long)(c[0]))<<32) & (0x000000FF00000000);
- long long ttt1 = (((long long)(c[1]))<<24) & (0x00000000FF000000);
- long long ttt2 = (((long long)(c[2]))<<16) & (0x0000000000FF0000);
- long long ttt3 = (((long long)(c[3]))<<8) & (0x000000000000FF00);
- long long all = ttt0 + ttt1 + ttt2 + ttt3 + ((long long)(c[4]&(0xFF)));
- return all;
- }
- unsigned long long HostServer::SyncHelper::parseId(unsigned int id, unsigned char antNum)
- {
- return (id << 8) + antNum;
- }
- unsigned long long HostServer::SyncHelper::parseFromFstream(ifstream &f, int size)
- {
- unsigned long long x(0);
- for(int i(0); i < size; i++)
- {
- int t;
- f >> hex >> t;
- x = (x << 8) + t;
- }
- return x;
- }
- unsigned long long HostServer::SyncHelper::parseTimeFromFstream(ifstream &f)
- {
- char* t = new char[5];
- for (int i = 0; i < 5; i++)
- {
- int tmp;
- f >> hex >> tmp;
- t[i] = tmp;
- }
- auto time = SyncHelper::parseTime(t);
- delete[] t;
- return time;
- }
|