diff --git a/tdactor/td/actor/PromiseFuture.h b/tdactor/td/actor/PromiseFuture.h index 873a8518..a8527d7d 100644 --- a/tdactor/td/actor/PromiseFuture.h +++ b/tdactor/td/actor/PromiseFuture.h @@ -259,12 +259,12 @@ class CancellablePromise : public PromiseT { template class LambdaPromise : public PromiseInterface { - enum OnFail { None, Ok, Fail }; + enum class OnFail { None, Ok, Fail }; public: void set_value(ValueT &&value) override { ok_(std::move(value)); - on_fail_ = None; + on_fail_ = OnFail::None; } void set_error(Status &&error) override { do_error(std::move(error)); @@ -279,13 +279,15 @@ class LambdaPromise : public PromiseInterface { template LambdaPromise(FromOkT &&ok, FromFailT &&fail, bool use_ok_as_fail) - : ok_(std::forward(ok)), fail_(std::forward(fail)), on_fail_(use_ok_as_fail ? Ok : Fail) { + : ok_(std::forward(ok)) + , fail_(std::forward(fail)) + , on_fail_(use_ok_as_fail ? OnFail::Ok : OnFail::Fail) { } private: FunctionOkT ok_; FunctionFailT fail_; - OnFail on_fail_ = None; + OnFail on_fail_ = OnFail::None; template > std::enable_if_t::value> do_error_impl(FuncT &func, Status &&status) { @@ -299,16 +301,16 @@ class LambdaPromise : public PromiseInterface { void do_error(Status &&error) { switch (on_fail_) { - case None: + case OnFail::None: break; - case Ok: + case OnFail::Ok: do_error_impl(ok_, std::move(error)); break; - case Fail: + case OnFail::Fail: fail_(std::move(error)); break; } - on_fail_ = None; + on_fail_ = OnFail::None; } }; diff --git a/tddb/td/db/DbKey.h b/tddb/td/db/DbKey.h index e7a55cbf..f000dd88 100644 --- a/tddb/td/db/DbKey.h +++ b/tddb/td/db/DbKey.h @@ -12,42 +12,49 @@ namespace td { class DbKey { - public: - enum Type { Empty, RawKey, Password }; + enum class Type { Empty, RawKey, Password }; Type type() const { return type_; } + + public: bool is_empty() const { - return type_ == Empty; + return type_ == Type::Empty; } + bool is_raw_key() const { - return type_ == RawKey; + return type_ == Type::RawKey; } + bool is_password() const { - return type_ == Password; + return type_ == Type::Password; } + CSlice data() const { return data_; } + static DbKey raw_key(string raw_key) { DbKey res; - res.type_ = RawKey; + res.type_ = Type::RawKey; res.data_ = std::move(raw_key); return res; } + static DbKey password(string password) { DbKey res; - res.type_ = Password; + res.type_ = Type::Password; res.data_ = std::move(password); return res; } + static DbKey empty() { return DbKey(); } private: - Type type_{Empty}; + Type type_{Type::Empty}; string data_; }; diff --git a/tddb/td/db/SqliteStatement.cpp b/tddb/td/db/SqliteStatement.cpp index fd21752a..0547a6c5 100644 --- a/tddb/td/db/SqliteStatement.cpp +++ b/tddb/td/db/SqliteStatement.cpp @@ -169,11 +169,11 @@ SqliteStatement::Datatype SqliteStatement::view_datatype(int id) { void SqliteStatement::reset() { sqlite3_reset(stmt_.get()); - state_ = Start; + state_ = State::Start; } Status SqliteStatement::step() { - if (state_ == Finish) { + if (state_ == State::Finish) { return Status::Error("One has to reset statement"); } VLOG(sqlite) << "Start step " << tag("query", sqlite3_sql(stmt_.get())) << tag("statement", stmt_.get()) @@ -182,14 +182,14 @@ Status SqliteStatement::step() { VLOG(sqlite) << "Finish step " << tag("query", sqlite3_sql(stmt_.get())) << tag("statement", stmt_.get()) << tag("database", db_.get()); if (rc == SQLITE_ROW) { - state_ = GotRow; + state_ = State::GotRow; return Status::OK(); } + + state_ = State::Finish; if (rc == SQLITE_DONE) { - state_ = Finish; return Status::OK(); } - state_ = Finish; return last_error(); } diff --git a/tddb/td/db/SqliteStatement.h b/tddb/td/db/SqliteStatement.h index f25cda67..ed95bd88 100644 --- a/tddb/td/db/SqliteStatement.h +++ b/tddb/td/db/SqliteStatement.h @@ -44,10 +44,10 @@ class SqliteStatement { Result explain(); bool can_step() const { - return state_ != Finish; + return state_ != State::Finish; } bool has_row() const { - return state_ == GotRow; + return state_ == State::GotRow; } bool empty() const { return !stmt_; @@ -72,7 +72,8 @@ class SqliteStatement { void operator()(sqlite3_stmt *stmt); }; - enum { Start, GotRow, Finish } state_ = Start; + enum class State { Start, GotRow, Finish }; + State state_ = State::Start; std::unique_ptr stmt_; std::shared_ptr db_; diff --git a/tddb/td/db/binlog/Binlog.cpp b/tddb/td/db/binlog/Binlog.cpp index c717fbb3..69d6bc41 100644 --- a/tddb/td/db/binlog/Binlog.cpp +++ b/tddb/td/db/binlog/Binlog.cpp @@ -108,7 +108,7 @@ class BinlogReader { return offset_; } Result read_next(BinlogEvent *event) { - if (state_ == ReadLength) { + if (state_ == State::ReadLength) { if (input_->size() < 4) { return 4; } @@ -129,7 +129,7 @@ class BinlogReader { << expected_size_ << ' ' << tag("is_encrypted", is_encrypted_) << format::as_hex_dump<4>(Slice(input_->prepare_read().truncate(28)))); } - state_ = ReadEvent; + state_ = State::ReadEvent; } if (input_->size() < size_) { @@ -140,13 +140,14 @@ class BinlogReader { TRY_STATUS(event->init(input_->cut_head(size_).move_as_buffer_slice())); offset_ += size_; event->offset_ = offset_; - state_ = ReadLength; + state_ = State::ReadLength; return 0; } private: ChainBufferReader *input_; - enum { ReadLength, ReadEvent } state_ = ReadLength; + enum class State { ReadLength, ReadEvent }; + State state_ = State::ReadLength; size_t size_{0}; int64 offset_{0}; int64 expected_size_{0}; diff --git a/tdnet/td/net/HttpChunkedByteFlow.cpp b/tdnet/td/net/HttpChunkedByteFlow.cpp index a13d5df3..918fef0d 100644 --- a/tdnet/td/net/HttpChunkedByteFlow.cpp +++ b/tdnet/td/net/HttpChunkedByteFlow.cpp @@ -18,7 +18,7 @@ void HttpChunkedByteFlow::loop() { bool was_updated = false; size_t need_size; while (true) { - if (state_ == ReadChunkLength) { + if (state_ == State::ReadChunkLength) { bool ok = find_boundary(input_->clone(), "\r\n", len_); if (len_ > 10) { return finish(Status::Error(PSLICE() << "Too long length in chunked " @@ -35,7 +35,7 @@ void HttpChunkedByteFlow::loop() { return finish(Status::Error(PSLICE() << "Invalid chunk size " << tag("size", len_))); } save_len_ = len_; - state_ = ReadChunkContent; + state_ = State::ReadChunkContent; } auto size = input_->size(); @@ -67,7 +67,7 @@ void HttpChunkedByteFlow::loop() { if (save_len_ == 0) { return finish(Status::OK()); } - state_ = ReadChunkLength; + state_ = State::ReadChunkLength; len_ = 0; } } diff --git a/tdnet/td/net/HttpChunkedByteFlow.h b/tdnet/td/net/HttpChunkedByteFlow.h index aff6daa2..ba3c05d5 100644 --- a/tdnet/td/net/HttpChunkedByteFlow.h +++ b/tdnet/td/net/HttpChunkedByteFlow.h @@ -18,7 +18,8 @@ class HttpChunkedByteFlow final : public ByteFlowBase { static constexpr int MAX_CHUNK_SIZE = 15 << 20; // some reasonable limit static constexpr int MAX_SIZE = 150 << 20; // some reasonable limit static constexpr size_t MIN_UPDATE_SIZE = 1 << 14; - enum { ReadChunkLength, ReadChunkContent, OK } state_ = ReadChunkLength; + enum class State { ReadChunkLength, ReadChunkContent, OK }; + State state_ = State::ReadChunkLength; size_t len_ = 0; size_t save_len_ = 0; size_t total_size_ = 0; diff --git a/tdnet/td/net/HttpReader.cpp b/tdnet/td/net/HttpReader.cpp index 55202bd4..4857d1f8 100644 --- a/tdnet/td/net/HttpReader.cpp +++ b/tdnet/td/net/HttpReader.cpp @@ -50,7 +50,7 @@ static MutableSlice urldecode_inplace(MutableSlice str, bool decode_plus_sign_as void HttpReader::init(ChainBufferReader *input, size_t max_post_size, size_t max_files) { input_ = input; - state_ = ReadHeaders; + state_ = State::ReadHeaders; headers_read_length_ = 0; content_length_ = 0; query_ = nullptr; @@ -67,7 +67,7 @@ Result HttpReader::read_next(HttpQuery *query) { } size_t need_size = input_->size() + 1; while (true) { - if (state_ != ReadHeaders) { + if (state_ != State::ReadHeaders) { flow_source_.wakeup(); if (flow_sink_.is_ready() && flow_sink_.status().is_error()) { if (!temp_file_.empty()) { @@ -81,7 +81,7 @@ Result HttpReader::read_next(HttpQuery *query) { } } switch (state_) { - case ReadHeaders: { + case State::ReadHeaders: { auto result = split_header(); if (result.is_error() || result.ok() != 0) { return result; @@ -107,7 +107,7 @@ Result HttpReader::read_next(HttpQuery *query) { if (content_encoding_.empty()) { } else if (content_encoding_ == "gzip" || content_encoding_ == "deflate") { - gzip_flow_ = GzipByteFlow(Gzip::Decode); + gzip_flow_ = GzipByteFlow(Gzip::Mode::Decode); gzip_flow_.set_max_output_size(MAX_FILE_SIZE); *source >> gzip_flow_; source = &gzip_flow_; @@ -125,7 +125,7 @@ Result HttpReader::read_next(HttpQuery *query) { } if (content_type_lowercased_.find("multipart/form-data") != string::npos) { - state_ = ReadMultipartFormData; + state_ = State::ReadMultipartFormData; const char *p = std::strstr(content_type_lowercased_.c_str(), "boundary"); if (p == nullptr) { @@ -154,21 +154,21 @@ Result HttpReader::read_next(HttpQuery *query) { } boundary_ = "\r\n--" + boundary.str(); - form_data_parse_state_ = SkipPrologue; + form_data_parse_state_ = FormDataParseState::SkipPrologue; form_data_read_length_ = 0; form_data_skipped_length_ = 0; } else if (content_type_lowercased_.find("application/x-www-form-urlencoded") != string::npos || content_type_lowercased_.find("application/json") != string::npos) { - state_ = ReadArgs; + state_ = State::ReadArgs; } else { form_data_skipped_length_ = 0; - state_ = ReadContent; + state_ = State::ReadContent; } continue; } - case ReadContent: { + case State::ReadContent: { if (content_->size() > max_post_size_) { - state_ = ReadContentToFile; + state_ = State::ReadContentToFile; continue; } if (flow_sink_.is_ready()) { @@ -180,7 +180,7 @@ Result HttpReader::read_next(HttpQuery *query) { return need_size; } - case ReadContentToFile: { + case State::ReadContentToFile: { // save content to a file if (temp_file_.empty()) { auto file = open_temp_file("file"); @@ -201,7 +201,7 @@ Result HttpReader::read_next(HttpQuery *query) { return need_size; } - case ReadArgs: { + case State::ReadArgs: { auto size = content_->size(); if (size > MAX_TOTAL_PARAMETERS_LENGTH - total_parameters_length_) { return Status::Error(413, "Request Entity Too Large: too much parameters"); @@ -227,7 +227,7 @@ Result HttpReader::read_next(HttpQuery *query) { return need_size; } - case ReadMultipartFormData: { + case State::ReadMultipartFormData: { TRY_RESULT(result, parse_multipart_form_data()); if (result) { break; @@ -249,16 +249,16 @@ Result HttpReader::read_next(HttpQuery *query) { // returns false if need more data Result HttpReader::parse_multipart_form_data() { while (true) { - LOG(DEBUG) << "Parsing multipart form data in state " << form_data_parse_state_; + LOG(DEBUG) << "Parsing multipart form data in state " << static_cast(form_data_parse_state_); switch (form_data_parse_state_) { - case SkipPrologue: + case FormDataParseState::SkipPrologue: if (find_boundary(content_->clone(), {boundary_.c_str() + 2, boundary_.size() - 2}, form_data_read_length_)) { size_t to_skip = form_data_read_length_ + (boundary_.size() - 2); content_->advance(to_skip); form_data_skipped_length_ += to_skip; form_data_read_length_ = 0; - form_data_parse_state_ = ReadPartHeaders; + form_data_parse_state_ = FormDataParseState::ReadPartHeaders; continue; } @@ -266,7 +266,7 @@ Result HttpReader::parse_multipart_form_data() { form_data_skipped_length_ += form_data_read_length_; form_data_read_length_ = 0; return false; - case ReadPartHeaders: + case FormDataParseState::ReadPartHeaders: if (find_boundary(content_->clone(), "\r\n\r\n", form_data_read_length_)) { total_headers_length_ += form_data_read_length_; if (total_headers_length_ > MAX_TOTAL_HEADERS_LENGTH) { @@ -382,11 +382,11 @@ Result HttpReader::parse_multipart_form_data() { // don't need to save headers for files file_field_name_ = field_name_.str(); - form_data_parse_state_ = ReadFile; + form_data_parse_state_ = FormDataParseState::ReadFile; } else { // save headers for query parameters. They contain header names query_->container_.push_back(std::move(headers)); - form_data_parse_state_ = ReadPartValue; + form_data_parse_state_ = FormDataParseState::ReadPartValue; } continue; @@ -396,7 +396,7 @@ Result HttpReader::parse_multipart_form_data() { return Status::Error(431, "Request Header Fields Too Large: total headers size exceeded"); } return false; - case ReadPartValue: + case FormDataParseState::ReadPartValue: if (find_boundary(content_->clone(), boundary_, form_data_read_length_)) { if (total_parameters_length_ + form_data_read_length_ > MAX_TOTAL_PARAMETERS_LENGTH) { return Status::Error(413, "Request Entity Too Large: too much parameters in form data"); @@ -421,7 +421,7 @@ Result HttpReader::parse_multipart_form_data() { query_->args_.emplace_back(field_name_, value); } - form_data_parse_state_ = CheckForLastBoundary; + form_data_parse_state_ = FormDataParseState::CheckForLastBoundary; continue; } CHECK(content_->size() < form_data_read_length_ + boundary_.size()); @@ -430,7 +430,7 @@ Result HttpReader::parse_multipart_form_data() { return Status::Error(413, "Request Entity Too Large: too much parameters in form data"); } return false; - case ReadFile: { + case FormDataParseState::ReadFile: { if (find_boundary(content_->clone(), boundary_, form_data_read_length_)) { auto file_part = content_->cut_head(form_data_read_length_).move_as_buffer_slice(); content_->advance(boundary_.size()); @@ -442,7 +442,7 @@ Result HttpReader::parse_multipart_form_data() { query_->files_.emplace_back(file_field_name_, file_name_, field_content_type_, file_size_, temp_file_name_); close_temp_file(); - form_data_parse_state_ = CheckForLastBoundary; + form_data_parse_state_ = FormDataParseState::CheckForLastBoundary; continue; } @@ -455,7 +455,7 @@ Result HttpReader::parse_multipart_form_data() { TRY_STATUS(save_file_part(std::move(file_part))); return false; } - case CheckForLastBoundary: { + case FormDataParseState::CheckForLastBoundary: { if (content_->size() < 2) { // need more data return false; @@ -467,13 +467,13 @@ Result HttpReader::parse_multipart_form_data() { if (x[0] == '-' && x[1] == '-') { content_->advance(2); form_data_skipped_length_ += 2; - form_data_parse_state_ = SkipEpilogue; + form_data_parse_state_ = FormDataParseState::SkipEpilogue; } else { - form_data_parse_state_ = ReadPartHeaders; + form_data_parse_state_ = FormDataParseState::ReadPartHeaders; } continue; } - case SkipEpilogue: { + case FormDataParseState::SkipEpilogue: { size_t size = content_->size(); LOG(DEBUG) << "Skipping epilogue. Have " << size << " bytes"; content_->advance(size); diff --git a/tdnet/td/net/HttpReader.h b/tdnet/td/net/HttpReader.h index 7e1384d5..26fc5ec6 100644 --- a/tdnet/td/net/HttpReader.h +++ b/tdnet/td/net/HttpReader.h @@ -46,7 +46,8 @@ class HttpReader { size_t max_post_size_ = 0; size_t max_files_ = 0; - enum { ReadHeaders, ReadContent, ReadContentToFile, ReadArgs, ReadMultipartFormData } state_; + enum class State { ReadHeaders, ReadContent, ReadContentToFile, ReadArgs, ReadMultipartFormData }; + State state_ = State::ReadHeaders; size_t headers_read_length_ = 0; size_t content_length_ = 0; ChainBufferReader *input_ = nullptr; @@ -68,14 +69,15 @@ class HttpReader { string boundary_; size_t form_data_read_length_ = 0; size_t form_data_skipped_length_ = 0; - enum { + enum class FormDataParseState : int32 { SkipPrologue, ReadPartHeaders, ReadPartValue, ReadFile, CheckForLastBoundary, SkipEpilogue - } form_data_parse_state_; + }; + FormDataParseState form_data_parse_state_ = FormDataParseState::SkipPrologue; MutableSlice field_name_; string file_field_name_; string field_content_type_; diff --git a/tdutils/td/utils/Gzip.cpp b/tdutils/td/utils/Gzip.cpp index 6fc36e42..a5e6d492 100644 --- a/tdutils/td/utils/Gzip.cpp +++ b/tdutils/td/utils/Gzip.cpp @@ -33,9 +33,9 @@ class Gzip::Impl { }; Status Gzip::init_encode() { - CHECK(mode_ == Empty); + CHECK(mode_ == Mode::Empty); init_common(); - mode_ = Encode; + mode_ = Mode::Encode; int ret = deflateInit2(&impl_->stream_, 6, Z_DEFLATED, 15, MAX_MEM_LEVEL, Z_DEFAULT_STRATEGY); if (ret != Z_OK) { return Status::Error(PSLICE() << "zlib deflate init failed: " << ret); @@ -44,9 +44,9 @@ Status Gzip::init_encode() { } Status Gzip::init_decode() { - CHECK(mode_ == Empty); + CHECK(mode_ == Mode::Empty); init_common(); - mode_ = Decode; + mode_ = Mode::Decode; int ret = inflateInit2(&impl_->stream_, MAX_WBITS + 32); if (ret != Z_OK) { return Status::Error(PSLICE() << "zlib inflate init failed: " << ret); @@ -76,19 +76,19 @@ void Gzip::set_output(MutableSlice output) { Result Gzip::run() { while (true) { int ret; - if (mode_ == Decode) { + if (mode_ == Mode::Decode) { ret = inflate(&impl_->stream_, Z_NO_FLUSH); } else { ret = deflate(&impl_->stream_, close_input_flag_ ? Z_FINISH : Z_NO_FLUSH); } if (ret == Z_OK) { - return Running; + return State::Running; } if (ret == Z_STREAM_END) { // TODO(now): fail if input is not empty; clear(); - return Done; + return State::Done; } clear(); return Status::Error(PSLICE() << "zlib error " << ret); @@ -119,12 +119,12 @@ void Gzip::init_common() { } void Gzip::clear() { - if (mode_ == Decode) { + if (mode_ == Mode::Decode) { inflateEnd(&impl_->stream_); - } else if (mode_ == Encode) { + } else if (mode_ == Mode::Encode) { deflateEnd(&impl_->stream_); } - mode_ = Empty; + mode_ = Mode::Empty; } Gzip::Gzip() : impl_(make_unique()) { @@ -168,7 +168,7 @@ BufferSlice gzdecode(Slice s) { return BufferSlice(); } auto state = r_state.ok(); - if (state == Gzip::Done) { + if (state == Gzip::State::Done) { message.confirm_append(gzip.flush_output()); break; } @@ -197,7 +197,7 @@ BufferSlice gzencode(Slice s, double k) { return BufferSlice(); } auto state = r_state.ok(); - if (state != Gzip::Done) { + if (state != Gzip::State::Done) { return BufferSlice(); } message.confirm_append(gzip.flush_output()); diff --git a/tdutils/td/utils/Gzip.h b/tdutils/td/utils/Gzip.h index f937a86c..17cf6434 100644 --- a/tdutils/td/utils/Gzip.h +++ b/tdutils/td/utils/Gzip.h @@ -24,11 +24,11 @@ class Gzip { Gzip &operator=(Gzip &&other); ~Gzip(); - enum Mode { Empty, Encode, Decode }; + enum class Mode { Empty, Encode, Decode }; Status init(Mode mode) TD_WARN_UNUSED_RESULT { - if (mode == Encode) { + if (mode == Mode::Encode) { return init_encode(); - } else if (mode == Decode) { + } else if (mode == Mode::Decode) { return init_decode(); } clear(); @@ -79,7 +79,7 @@ class Gzip { return res; } - enum State { Running, Done }; + enum class State { Running, Done }; Result run() TD_WARN_UNUSED_RESULT; private: @@ -89,7 +89,7 @@ class Gzip { size_t input_size_ = 0; size_t output_size_ = 0; bool close_input_flag_ = false; - Mode mode_ = Empty; + Mode mode_ = Mode::Empty; void init_common(); void clear(); diff --git a/tdutils/td/utils/GzipByteFlow.cpp b/tdutils/td/utils/GzipByteFlow.cpp index a32ae117..b9651597 100644 --- a/tdutils/td/utils/GzipByteFlow.cpp +++ b/tdutils/td/utils/GzipByteFlow.cpp @@ -52,7 +52,7 @@ void GzipByteFlow::loop() { return finish(r_state.move_as_error()); } auto state = r_state.ok(); - if (state == Gzip::Done) { + if (state == Gzip::State::Done) { on_output_updated(); return consume_input(); } diff --git a/tdutils/td/utils/OptionsParser.cpp b/tdutils/td/utils/OptionsParser.cpp index b9138ad0..f8321635 100644 --- a/tdutils/td/utils/OptionsParser.cpp +++ b/tdutils/td/utils/OptionsParser.cpp @@ -44,9 +44,9 @@ Result OptionsParser::run(int argc, char *argv[]) { char buff[1024]; StringBuilder sb(MutableSlice{buff, sizeof(buff)}); for (auto &opt : options_) { - CHECK(opt.type != Option::OptionalArg); + CHECK(opt.type != Option::Type::OptionalArg); sb << opt.short_key; - if (opt.type == Option::Arg) { + if (opt.type == Option::Type::Arg) { sb << ":"; } } @@ -63,7 +63,7 @@ Result OptionsParser::run(int argc, char *argv[]) { option o; o.flag = nullptr; o.val = opt.short_key; - o.has_arg = opt.type == Option::Arg ? required_argument : no_argument; + o.has_arg = opt.type == Option::Type::Arg ? required_argument : no_argument; o.name = opt.long_key.c_str(); long_options.push_back(o); } @@ -84,7 +84,7 @@ Result OptionsParser::run(int argc, char *argv[]) { for (auto &opt : options_) { if (opt.short_key == opt_i) { Slice arg; - if (opt.type == Option::Arg) { + if (opt.type == Option::Type::Arg) { arg = Slice(optarg); } auto status = opt.arg_callback(arg); @@ -112,13 +112,13 @@ StringBuilder &operator<<(StringBuilder &sb, const OptionsParser &o) { if (!opt.long_key.empty()) { sb << "|--" << opt.long_key; } - if (opt.type == OptionsParser::Option::OptionalArg) { + if (opt.type == OptionsParser::Option::Type::OptionalArg) { sb << "["; } - if (opt.type != OptionsParser::Option::NoArg) { + if (opt.type != OptionsParser::Option::Type::NoArg) { sb << ""; } - if (opt.type == OptionsParser::Option::OptionalArg) { + if (opt.type == OptionsParser::Option::Type::OptionalArg) { sb << "]"; } sb << "\t" << opt.description; diff --git a/tdutils/td/utils/OptionsParser.h b/tdutils/td/utils/OptionsParser.h index fd76474f..1464379b 100644 --- a/tdutils/td/utils/OptionsParser.h +++ b/tdutils/td/utils/OptionsParser.h @@ -18,7 +18,7 @@ namespace td { class OptionsParser { class Option { public: - enum Type { NoArg, Arg, OptionalArg }; + enum class Type { NoArg, Arg, OptionalArg }; Type type; char short_key; std::string long_key; diff --git a/tdutils/td/utils/tests.cpp b/tdutils/td/utils/tests.cpp index 93f0aa5f..fdf762dc 100644 --- a/tdutils/td/utils/tests.cpp +++ b/tdutils/td/utils/tests.cpp @@ -38,7 +38,7 @@ class RegressionTesterImpl : public RegressionTester { } RegressionTesterImpl(string db_path, string db_cache_dir) : db_path_(db_path), db_cache_dir_(db_cache_dir) { - load_db(db_path); + load_db(db_path).ignore(); if (db_cache_dir_.empty()) { db_cache_dir_ = PathView(db_path).without_extension().str() + ".cache/"; } diff --git a/tdutils/test/gzip.cpp b/tdutils/test/gzip.cpp index 7edc2c49..10724bc7 100644 --- a/tdutils/test/gzip.cpp +++ b/tdutils/test/gzip.cpp @@ -42,8 +42,8 @@ TEST(Gzip, flow) { td::ChainBufferWriter input_writer; auto input = input_writer.extract_reader(); td::ByteFlowSource source(&input); - td::GzipByteFlow gzip_flow(td::Gzip::Encode); - gzip_flow = td::GzipByteFlow(td::Gzip::Encode); + td::GzipByteFlow gzip_flow(td::Gzip::Mode::Encode); + gzip_flow = td::GzipByteFlow(td::Gzip::Mode::Encode); td::ByteFlowSink sink; source >> gzip_flow >> sink; @@ -70,7 +70,7 @@ TEST(Gzip, flow_error) { auto input_writer = td::ChainBufferWriter(); auto input = input_writer.extract_reader(); td::ByteFlowSource source(&input); - td::GzipByteFlow gzip_flow(td::Gzip::Decode); + td::GzipByteFlow gzip_flow(td::Gzip::Mode::Decode); td::ByteFlowSink sink; source >> gzip_flow >> sink; @@ -92,10 +92,10 @@ TEST(Gzip, encode_decode_flow) { td::ChainBufferWriter input_writer; auto input = input_writer.extract_reader(); td::ByteFlowSource source(&input); - td::GzipByteFlow gzip_encode_flow(td::Gzip::Encode); - td::GzipByteFlow gzip_decode_flow(td::Gzip::Decode); - td::GzipByteFlow gzip_encode_flow2(td::Gzip::Encode); - td::GzipByteFlow gzip_decode_flow2(td::Gzip::Decode); + td::GzipByteFlow gzip_encode_flow(td::Gzip::Mode::Encode); + td::GzipByteFlow gzip_decode_flow(td::Gzip::Mode::Decode); + td::GzipByteFlow gzip_encode_flow2(td::Gzip::Mode::Encode); + td::GzipByteFlow gzip_decode_flow2(td::Gzip::Mode::Decode); td::ByteFlowSink sink; source >> gzip_encode_flow >> gzip_decode_flow >> gzip_encode_flow2 >> gzip_decode_flow2 >> sink; diff --git a/test/http.cpp b/test/http.cpp index f107828a..e9acf422 100644 --- a/test/http.cpp +++ b/test/http.cpp @@ -356,11 +356,11 @@ TEST(Http, gzip_chunked_flow) { auto str = rand_string('a', 'z', 1000000); auto parts = rand_split(make_chunked(gzencode(str).as_slice().str())); - td::ChainBufferWriter input_writer; + ChainBufferWriter input_writer; auto input = input_writer.extract_reader(); ByteFlowSource source(&input); HttpChunkedByteFlow chunked_flow; - GzipByteFlow gzip_flow(Gzip::Decode); + GzipByteFlow gzip_flow(Gzip::Mode::Decode); ByteFlowSink sink; source >> chunked_flow >> gzip_flow >> sink;