Add LabeledPricePart.h.
This commit is contained in:
parent
2a4201f989
commit
72c1a1597d
@ -588,6 +588,7 @@ set(TDLIB_SOURCE
|
||||
td/telegram/InputGroupCallId.h
|
||||
td/telegram/InputMessageText.h
|
||||
td/telegram/JsonValue.h
|
||||
td/telegram/LabeledPricePart.h
|
||||
td/telegram/LanguagePackManager.h
|
||||
td/telegram/LinkManager.h
|
||||
td/telegram/Location.h
|
||||
|
47
td/telegram/LabeledPricePart.h
Normal file
47
td/telegram/LabeledPricePart.h
Normal file
@ -0,0 +1,47 @@
|
||||
//
|
||||
// Copyright Aliaksei Levin (levlam@telegram.org), Arseny Smirnov (arseny30@gmail.com) 2014-2022
|
||||
//
|
||||
// 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/utils/common.h"
|
||||
#include "td/utils/StringBuilder.h"
|
||||
|
||||
namespace td {
|
||||
|
||||
struct LabeledPricePart {
|
||||
string label;
|
||||
int64 amount = 0;
|
||||
|
||||
LabeledPricePart() = default;
|
||||
LabeledPricePart(string &&label, int64 amount) : label(std::move(label)), amount(amount) {
|
||||
}
|
||||
|
||||
template <class StorerT>
|
||||
void store(StorerT &storer) const {
|
||||
storer.store_string(label);
|
||||
storer.store_binary(amount);
|
||||
}
|
||||
|
||||
template <class ParserT>
|
||||
void parse(ParserT &parser) {
|
||||
label = parser.template fetch_string<string>();
|
||||
amount = parser.fetch_long();
|
||||
}
|
||||
};
|
||||
|
||||
inline bool operator==(const LabeledPricePart &lhs, const LabeledPricePart &rhs) {
|
||||
return lhs.label == rhs.label && lhs.amount == rhs.amount;
|
||||
}
|
||||
|
||||
inline bool operator!=(const LabeledPricePart &lhs, const LabeledPricePart &rhs) {
|
||||
return !(lhs == rhs);
|
||||
}
|
||||
|
||||
inline StringBuilder &operator<<(StringBuilder &string_builder, const LabeledPricePart &labeled_price_part) {
|
||||
return string_builder << '[' << labeled_price_part.label << ": " << labeled_price_part.amount << ']';
|
||||
}
|
||||
|
||||
} // namespace td
|
@ -707,18 +707,6 @@ class GetBankCardInfoQuery final : public Td::ResultHandler {
|
||||
}
|
||||
};
|
||||
|
||||
bool operator==(const LabeledPricePart &lhs, const LabeledPricePart &rhs) {
|
||||
return lhs.label == rhs.label && lhs.amount == rhs.amount;
|
||||
}
|
||||
|
||||
bool operator!=(const LabeledPricePart &lhs, const LabeledPricePart &rhs) {
|
||||
return !(lhs == rhs);
|
||||
}
|
||||
|
||||
StringBuilder &operator<<(StringBuilder &string_builder, const LabeledPricePart &labeled_price_part) {
|
||||
return string_builder << "[" << labeled_price_part.label << ": " << labeled_price_part.amount << "]";
|
||||
}
|
||||
|
||||
bool operator==(const Invoice &lhs, const Invoice &rhs) {
|
||||
return lhs.is_test == rhs.is_test && lhs.need_name == rhs.need_name &&
|
||||
lhs.need_phone_number == rhs.need_phone_number && lhs.need_email_address == rhs.need_email_address &&
|
||||
|
@ -9,6 +9,7 @@
|
||||
#include "td/telegram/DialogId.h"
|
||||
#include "td/telegram/files/FileId.h"
|
||||
#include "td/telegram/FullMessageId.h"
|
||||
#include "td/telegram/LabeledPricePart.h"
|
||||
#include "td/telegram/MessageExtendedMedia.h"
|
||||
#include "td/telegram/MessageId.h"
|
||||
#include "td/telegram/Photo.h"
|
||||
@ -25,15 +26,6 @@ namespace td {
|
||||
|
||||
class Td;
|
||||
|
||||
struct LabeledPricePart {
|
||||
string label;
|
||||
int64 amount = 0;
|
||||
|
||||
LabeledPricePart() = default;
|
||||
LabeledPricePart(string &&label, int64 amount) : label(std::move(label)), amount(amount) {
|
||||
}
|
||||
};
|
||||
|
||||
struct Invoice {
|
||||
string currency;
|
||||
vector<LabeledPricePart> price_parts;
|
||||
|
@ -16,18 +16,6 @@
|
||||
|
||||
namespace td {
|
||||
|
||||
template <class StorerT>
|
||||
void store(const LabeledPricePart &labeled_price_part, StorerT &storer) {
|
||||
store(labeled_price_part.label, storer);
|
||||
store(labeled_price_part.amount, storer);
|
||||
}
|
||||
|
||||
template <class ParserT>
|
||||
void parse(LabeledPricePart &labeled_price_part, ParserT &parser) {
|
||||
parse(labeled_price_part.label, parser);
|
||||
parse(labeled_price_part.amount, parser);
|
||||
}
|
||||
|
||||
template <class StorerT>
|
||||
void store(const Invoice &invoice, StorerT &storer) {
|
||||
bool has_tip = invoice.max_tip_amount != 0;
|
||||
|
Loading…
Reference in New Issue
Block a user