tdlight/td/telegram/MediaArea.hpp
2023-08-01 15:17:50 +03:00

55 lines
1.2 KiB
C++

//
// 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;
BEGIN_STORE_FLAGS();
END_STORE_FLAGS();
store(type_, storer);
store(coordinates_, storer);
switch (type_) {
case Type::Location:
store(location_, storer);
break;
case Type::Venue:
store(venue_, storer);
break;
default:
UNREACHABLE();
}
}
template <class ParserT>
void MediaArea::parse(ParserT &parser) {
using td::parse;
BEGIN_PARSE_FLAGS();
END_PARSE_FLAGS();
parse(type_, parser);
parse(coordinates_, parser);
switch (type_) {
case Type::Location:
parse(location_, parser);
break;
case Type::Venue:
parse(venue_, parser);
break;
default:
parser.set_error("Load invalid area type");
}
}
} // namespace td