tdlight/td/telegram/MediaArea.hpp

67 lines
1.6 KiB
C++
Raw Normal View History

2023-08-01 14:17:50 +02:00
//
// Copyright Aliaksei Levin (levlam@telegram.org), Arseny Smirnov (arseny30@gmail.com) 2014-2023
//
// Distributed under the Boost Software License, Version 1.0. (See accompanying
// file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
//
#pragma once
#include "td/telegram/MediaArea.h"
#include "td/telegram/MediaAreaCoordinates.hpp"
#include "td/utils/tl_helpers.h"
namespace td {
template <class StorerT>
void MediaArea::store(StorerT &storer) const {
using td::store;
2023-08-01 17:11:30 +02:00
bool has_input_query_id = input_query_id_ != 0;
2023-08-01 14:17:50 +02:00
BEGIN_STORE_FLAGS();
2023-08-01 17:11:30 +02:00
STORE_FLAG(has_input_query_id);
2023-08-01 14:17:50 +02:00
END_STORE_FLAGS();
store(type_, storer);
store(coordinates_, storer);
switch (type_) {
case Type::Location:
store(location_, storer);
break;
case Type::Venue:
store(venue_, storer);
2023-08-01 17:11:30 +02:00
if (has_input_query_id) {
store(input_query_id_, storer);
store(input_result_id_, storer);
}
2023-08-01 14:17:50 +02:00
break;
default:
UNREACHABLE();
}
}
template <class ParserT>
void MediaArea::parse(ParserT &parser) {
using td::parse;
2023-08-01 17:11:30 +02:00
bool has_input_query_id;
2023-08-01 14:17:50 +02:00
BEGIN_PARSE_FLAGS();
2023-08-01 17:11:30 +02:00
PARSE_FLAG(has_input_query_id);
2023-08-01 14:17:50 +02:00
END_PARSE_FLAGS();
parse(type_, parser);
parse(coordinates_, parser);
switch (type_) {
case Type::Location:
parse(location_, parser);
break;
case Type::Venue:
parse(venue_, parser);
2023-08-01 17:11:30 +02:00
if (has_input_query_id) {
parse(input_query_id_, parser);
parse(input_result_id_, parser);
}
2023-08-01 14:17:50 +02:00
break;
default:
parser.set_error("Load invalid area type");
}
}
} // namespace td