Move BufferSlice an Timestamp storer/parser to their headers.
GitOrigin-RevId: 9aa62396ea26c8f3b6758262e94986dbd57ac277
This commit is contained in:
parent
6855704b52
commit
6f33dec5bb
@ -91,4 +91,14 @@ class Timestamp {
|
||||
}
|
||||
};
|
||||
|
||||
template <class T>
|
||||
void parse(Timestamp ×tamp, T &parser) {
|
||||
timestamp = Timestamp::in(parser.fetch_double() - Clocks::system());
|
||||
}
|
||||
|
||||
template <class T>
|
||||
void store(const Timestamp ×tamp, T &storer) {
|
||||
storer.store_binary(timestamp.at() - Time::now() + Clocks::system());
|
||||
}
|
||||
|
||||
} // namespace td
|
||||
|
@ -223,6 +223,16 @@ class BufferSlice {
|
||||
size_t end_ = 0;
|
||||
};
|
||||
|
||||
template <class StorerT>
|
||||
void store(const BufferSlice &buffer_slice, StorerT &storer) {
|
||||
storer.store_string(buffer_slice);
|
||||
}
|
||||
|
||||
template <class ParserT>
|
||||
void parse(BufferSlice &buffer_slice, ParserT &parser) {
|
||||
buffer_slice = parser.template fetch_string<BufferSlice>();
|
||||
}
|
||||
|
||||
class BufferWriter {
|
||||
public:
|
||||
BufferWriter() = default;
|
||||
|
@ -6,14 +6,12 @@
|
||||
//
|
||||
#pragma once
|
||||
|
||||
#include "td/utils/buffer.h" // for BufferSlice
|
||||
#include "td/utils/common.h"
|
||||
#include "td/utils/logging.h"
|
||||
#include "td/utils/misc.h"
|
||||
#include "td/utils/Slice.h"
|
||||
#include "td/utils/StackAllocator.h"
|
||||
#include "td/utils/Status.h"
|
||||
#include "td/utils/Time.h"
|
||||
#include "td/utils/tl_parsers.h"
|
||||
#include "td/utils/tl_storers.h"
|
||||
|
||||
@ -112,15 +110,6 @@ void parse(string &x, ParserT &parser) {
|
||||
x = parser.template fetch_string<string>();
|
||||
}
|
||||
|
||||
template <class StorerT>
|
||||
void store(const BufferSlice &x, StorerT &storer) {
|
||||
storer.store_string(x);
|
||||
}
|
||||
template <class ParserT>
|
||||
void parse(BufferSlice &x, ParserT &parser) {
|
||||
x = parser.template fetch_string<BufferSlice>();
|
||||
}
|
||||
|
||||
template <class T, class StorerT>
|
||||
void store(const vector<T> &vec, StorerT &storer) {
|
||||
storer.store_binary(narrow_cast<int32>(vec.size()));
|
||||
@ -140,14 +129,6 @@ void parse(vector<T> &vec, ParserT &parser) {
|
||||
parse(val, parser);
|
||||
}
|
||||
}
|
||||
template <class T>
|
||||
void parse(Timestamp ×tamp, T &parser) {
|
||||
timestamp = Timestamp::in(static_cast<double>(parser.fetch_long()) / 1000000 - Clocks::system());
|
||||
}
|
||||
template <class T>
|
||||
void store(const Timestamp ×tamp, T &storer) {
|
||||
storer.store_long(static_cast<int64>((timestamp.at() - Time::now() + Clocks::system()) * 1000000));
|
||||
}
|
||||
|
||||
template <class Key, class Hash, class KeyEqual, class Allocator, class StorerT>
|
||||
void store(const std::unordered_set<Key, Hash, KeyEqual, Allocator> &s, StorerT &storer) {
|
||||
|
Loading…
Reference in New Issue
Block a user