diff --git a/.clang-tidy b/.clang-tidy index f003ce2..f9fdf11 100644 --- a/.clang-tidy +++ b/.clang-tidy @@ -3,4 +3,4 @@ CheckOptions: - { key: readability-identifier-naming.PrivateMemberSuffix, value: "_" } - { key: readability-identifier-naming.ProtectedMemberSuffix, value: "_" } - { key: readability-identifier-naming.ClassCase, value: "lower_case" } - - { key: readability-identifier-naming.StructCase, value: "CamelCase" } + - { key: readability-identifier-naming.StructCase, value: "lower_case" } diff --git a/SConstruct b/SConstruct index ab8ca40..0e0f4a7 100644 --- a/SConstruct +++ b/SConstruct @@ -73,17 +73,17 @@ env.Alias('test', env.test_program) # Clang format part env.Append(BUILDERS={'ClangFormat' : Builder(action = 'clang-format --style=file -i $SOURCE')}) -env.format_actions = [] +env.format_actions = []; def format_iter(env,files): for f in files: env.format_actions.append(env.AlwaysBuild(env.ClangFormat(target=f+"-clang-format",source=f))) pass env.Append(BUILDERS={'ClangTidy' : Builder(action = 'clang-tidy -extra-arg-before=-xc++ $SOURCE')}) -env.tidy_actions = [] +env.tidy_actions = []; def tidy_iter(env,files): string_of_files = ""; for f in files: - if(f != "/home/keldu/workspace/forstio/source/forstio/async.tmpl.h" and f != "/home/keldu/workspace/forstio/forstio/source/forstio/io_peer.tmpl.h" ): + if(f != "/home/keldu/workspace/forstio/forstio/source/forstio/async.tmpl.h" and f != "/home/keldu/workspace/forstio/forstio/source/forstio/io_peer.tmpl.h" ): env.tidy_actions.append(env.AlwaysBuild(env.ClangTidy(target=f+"-clang-tidy",source=f))); pass diff --git a/source/forstio/async.h b/source/forstio/async.h index 366b14e..699d971 100644 --- a/source/forstio/async.h +++ b/source/forstio/async.h @@ -310,13 +310,13 @@ template <> class conveyor_feeder { public: virtual ~conveyor_feeder() = default; - virtual void feed(Void &&value = Void{}) = 0; + virtual void feed(void_t &&value = void_t{}) = 0; virtual void fail(error &&error) = 0; virtual size_t space() const = 0; virtual size_t queued() const = 0; - virtual error swap(conveyor &&conveyor) noexcept = 0; + virtual error swap(conveyor &&conveyor) noexcept = 0; }; template struct conveyor_and_feeder { @@ -477,25 +477,25 @@ template struct fix_void_caller { } }; -template struct fix_void_caller { - template static Out apply(Func &func, Void &&in) { +template struct fix_void_caller { + template static Out apply(Func &func, void_t &&in) { (void)in; return func(); } }; -template struct fix_void_caller { - template static Void apply(Func &func, In &&in) { +template struct fix_void_caller { + template static void_t apply(Func &func, In &&in) { func(std::move(in)); - return Void{}; + return void_t{}; } }; -template <> struct fix_void_caller { - template static Void apply(Func &func, Void &&in) { +template <> struct fix_void_caller { + template static void_t apply(Func &func, void_t &&in) { (void)in; func(); - return Void{}; + return void_t{}; } }; @@ -789,7 +789,7 @@ public: // ConveyorNode void get_result(error_or_value &err_or_val) noexcept override { - err_or_val.as() = + err_or_val.as() = critical_error("In a sink node no result can be returned"); } diff --git a/source/forstio/common.h b/source/forstio/common.h index 3b4bd04..a06c238 100644 --- a/source/forstio/common.h +++ b/source/forstio/common.h @@ -60,14 +60,14 @@ template struct return_type_helper { template using return_type = typename return_type_helper::Type; -struct Void {}; +struct void_t {}; template struct void_fix { typedef T Type; }; -template <> struct void_fix { typedef Void Type; }; +template <> struct void_fix { typedef void_t Type; }; template using fix_void = typename void_fix::Type; template struct void_unfix { typedef T Type; }; -template <> struct void_unfix { typedef void Type; }; +template <> struct void_unfix { typedef void Type; }; template using unfix_void = typename void_unfix::Type; template constexpr bool always_false = false; diff --git a/source/forstio/error.h b/source/forstio/error.h index 63aacaf..ebe928c 100644 --- a/source/forstio/error.h +++ b/source/forstio/error.h @@ -106,7 +106,7 @@ template class error_or final : public error_or_value { private: std::variant> value_or_error_; - static_assert(!std::is_same_v, "Don't use internal private types"); + static_assert(!std::is_same_v, "Don't use internal private types"); public: error_or() = default; diff --git a/source/forstio/io_peer.h b/source/forstio/io_peer.h index cc349f6..0d55322 100644 --- a/source/forstio/io_peer.h +++ b/source/forstio/io_peer.h @@ -42,7 +42,7 @@ public: */ conveyor_feeder> &feeder(); - conveyor onReadDisconnected(); + conveyor on_read_disconnected(); private: /// @unimplemented diff --git a/source/forstio/io_peer.tmpl.h b/source/forstio/io_peer.tmpl.h index b697ae0..8af7753 100644 --- a/source/forstio/io_peer.tmpl.h +++ b/source/forstio/io_peer.tmpl.h @@ -2,109 +2,109 @@ namespace saw { template -StreamingIoPeer:: - StreamingIoPeer( - Own>> feed, - Own str) - : StreamingIoPeer{std::move(feed), std::move(str), {}, {}, {}} {} +streaming_io_peer:: + streaming_io_peer( + own>> feed, + own str) + : streaming_io_peer{std::move(feed), std::move(str), {}, {}, {}} {} template -StreamingIoPeer:: - StreamingIoPeer( - Own>> feed, - Own stream, Codec codec, BufferT in, BufferT out) +streaming_io_peer:: + streaming_io_peer( + own>> feed, + own stream, Codec codec, BufferT in, BufferT out) : incoming_feeder_{std::move(feed)}, io_stream_{std::move(stream)}, codec_{std::move(codec)}, in_buffer_{std::move(in)}, out_buffer_{std::move(out)}, - sink_read_{io_stream_->readDone() - .then([this](size_t bytes) -> ErrorOr { - in_buffer_.writeAdvance(bytes); + sink_read_{io_stream_->read_done() + .then([this](size_t bytes) -> error_or { + in_buffer_.write_advance(bytes); - if (in_buffer_.writeSegmentLength() == 0) { - return criticalError("Message too long"); + if (in_buffer_.write_segment_length() == 0) { + return critical_error("Message too long"); } io_stream_->read(&in_buffer_.write(), 1, - in_buffer_.writeSegmentLength()); + in_buffer_.write_segment_length()); while (true) { auto root = heapMessageRoot(); auto builder = root.build(); - Error error = + error err = codec_.template decode( builder, in_buffer_); - if (error.isCritical()) { - return error; + if (err.is_critical()) { + return err; } - if (!error.failed()) { + if (!err.failed()) { incoming_feeder_->feed(std::move(root)); } else { break; } } - return Void{}; + return void_t{}; }) - .sink([this](Error error) { - incoming_feeder_->fail(error.copyError()); + .sink([this](error err) { + incoming_feeder_->fail(err.copy_error()); - return error; + return err; })}, - sink_write_{io_stream_->writeDone() - .then([this](size_t bytes) -> ErrorOr { - out_buffer_.readAdvance(bytes); + sink_write_{io_stream_->write_done() + .then([this](size_t bytes) -> error_or { + out_buffer_.read_advance(bytes); if (out_buffer_.readCompositeLength() > 0) { io_stream_->write( &out_buffer_.read(), - out_buffer_.readSegmentLength()); + out_buffer_.read_segment_length()); } - return Void{}; + return void_t{}; }) .sink()} { - io_stream_->read(&in_buffer_.write(), 1, in_buffer_.writeSegmentLength()); + io_stream_->read(&in_buffer_.write(), 1, in_buffer_.write_segment_length()); } template -Error StreamingIoPeer::send(HeapMessageRoot msg) { - bool restart_write = out_buffer_.readSegmentLength() == 0; + bool restart_write = out_buffer_.read_segment_length() == 0; - Error error = + error err = codec_.template encode(msg.read(), out_buffer_); - if (error.failed()) { - return error; + if (err.failed()) { + return err; } if (restart_write) { - io_stream_->write(&out_buffer_.read(), out_buffer_.readSegmentLength()); + io_stream_->write(&out_buffer_.read(), out_buffer_.read_segment_length()); } - return noError(); + return no_error(); } template -Conveyor StreamingIoPeer::onReadDisconnected() { - return io_stream_->onReadDisconnected(); +conveyor streaming_io_peer::on_read_disconnected() { + return io_stream_->on_read_disconnected(); } template -std::pair>, - Conveyor>> -newStreamingIoPeer(Own stream) { - auto caf = newConveyorAndFeeder>(); + conveyor>> +newstreaming_io_peer(own stream) { + auto caf = newconveyorAndFeeder>(); - return {heap>(std::move(caf.feeder), std::move(stream)), std::move(caf.conveyor)}; diff --git a/source/forstio/tls/tls.cpp b/source/forstio/tls/tls.cpp index eb7423c..d8762ab 100644 --- a/source/forstio/tls/tls.cpp +++ b/source/forstio/tls/tls.cpp @@ -193,7 +193,7 @@ conveyor> TlsNetwork::connect(network_address& address) { hlp_ptr->setupTurn(); hlp_ptr->turn(); - return Void{}; + return void_t{}; }); helper->connection_sink = prim_conv.sink();