Skip to content

Commit f0d3e84

Browse files
committed
📌 Nodepp | Update | V1.4.2 📌
1 parent 361922a commit f0d3e84

30 files changed

Lines changed: 418 additions & 319 deletions

examples/35-WS-Client.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ void onMain() {
1111

1212
client.onConnect([=]( ws_t cli ){
1313

14-
console::log("connected", cli.get_peername() );
14+
console::log("connected" );
1515

1616
cli.onData([]( string_t data ){
1717
console::log( data );

examples/36-WS-Server.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ void onMain(){
2222

2323
server.onConnect([=]( ws_t cli ){
2424

25-
console::log("connected", cli.get_peername() );
25+
console::log("connected" );
2626

2727
cli.onData([=]( string_t data ){
2828
console::log( data );

examples/45-TCPClient.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ void onMain(){
1010

1111
client.onOpen([=]( socket_t cli ){
1212

13-
console::log("connected", cli.get_peername() );
13+
console::log("connected" );
1414

1515
cli.onData([=]( string_t data ){
1616
console::log( data );

examples/46-TCPServer.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ void onMain(){
1010

1111
server.onConnect([=]( socket_t cli ){
1212

13-
console::log("connected", cli.get_peername() );
13+
console::log("connected" );
1414

1515
cli.onData([=]( string_t data ){
1616
console::log( data );

examples/47-UDPClient.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ void onMain(){
1010

1111
client.onConnect([=]( socket_t cli ){
1212

13-
console::log("connected", cli.get_peername() );
13+
console::log("connected" );
1414

1515
cli.onData([=]( string_t data ){
1616
console::log( data );

examples/48-UDP.cpp

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,9 @@ void server(){
1313
console::log("connected" );
1414

1515
cli.onData([=]( string_t data ){
16+
auto tmp = cli.get_client_address();
17+
/*async logic or coroutines*/
18+
cli.set_client_address( tmp );
1619
cli.write( "<: received" );
1720
console::log( data );
1821
});

examples/48-UDPServer.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ void onMain(){
1010

1111
server.onConnect([=]( socket_t cli ){
1212

13-
console::log("connected", cli.get_peername() );
13+
console::log("connected" );
1414

1515
cli.onData([=]( string_t data ){
1616
console::log( data );

include/nodepp.h

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
#ifndef NODEPP_MAIN
2+
#define NODEPP_MAIN
3+
4+
/*────────────────────────────────────────────────────────────────────────────*/
5+
6+
#include "nodepp/nodepp.h"
7+
8+
/*────────────────────────────────────────────────────────────────────────────*/
9+
10+
#endif

include/nodepp/atomic.h

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,12 @@
1414

1515
/*────────────────────────────────────────────────────────────────────────────*/
1616

17+
#if !defined( NODEPP_THREAD_SUPPORTED )
18+
#error "This OS Does not support atomic.h"
19+
#endif
20+
21+
/*────────────────────────────────────────────────────────────────────────────*/
22+
1723
#if _KERNEL_ == NODEPP_KERNEL_WINDOWS
1824
#include "windows/atomic.h"
1925
#elif _KERNEL_ == NODEPP_KERNEL_POSIX

include/nodepp/expected.h

Lines changed: 15 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -12,19 +12,18 @@
1212
#ifndef NODEPP_EXPECTED
1313
#define NODEPP_EXPECTED
1414

15-
#include "any.h"
15+
/*────────────────────────────────────────────────────────────────────────────*/
1616

1717
namespace nodepp {
1818
template <typename T, typename E> struct expected_t {
1919
protected:
2020

21-
struct NODE { any_t data; bool has; }; ptr_t<NODE> obj;
21+
struct NODE { T data; E error; bool has; }; ptr_t<NODE> obj;
2222

2323
public:
2424

25-
expected_t( const T& val ) noexcept : obj( new NODE() ) { obj->has = true ; obj->data = val; }
26-
27-
expected_t( const E& err ) noexcept : obj( new NODE() ) { obj->has = false; obj->data = err; }
25+
expected_t( const T& val ) noexcept : obj( new NODE() ) { obj->has = true ; obj->data = val; }
26+
expected_t( const E& err ) noexcept : obj( new NODE() ) { obj->has = false; obj->error = err; }
2827

2928
/*─······································································─*/
3029

@@ -33,16 +32,20 @@ template <typename T, typename E> struct expected_t {
3332

3433
/*─······································································─*/
3534

36-
T value() const { if( !has_value() || !obj->data.has_value() ) {
37-
throw except_t("expected does not have a value");
38-
} return obj->data.template as<T>(); }
35+
T value() const { if( !has_value() ) {
36+
throw except_t("expected does not have a value");
37+
} return obj->data; }
3938

4039
/*─······································································─*/
4140

42-
E error() const { if( has_value() || !obj->data.has_value() ) {
43-
throw except_t("expected does not have a value");
44-
} return obj->data.template as<E>(); }
41+
E error() const { if( has_value() ) {
42+
throw except_t("expected does not have a value");
43+
} return obj->error; }
4544

4645
};}
4746

48-
#endif
47+
/*────────────────────────────────────────────────────────────────────────────*/
48+
49+
#endif
50+
51+
/*────────────────────────────────────────────────────────────────────────────*/

0 commit comments

Comments
 (0)