summaryrefslogtreecommitdiff
path: root/Rx/v2/examples
diff options
context:
space:
mode:
Diffstat (limited to 'Rx/v2/examples')
-rw-r--r--Rx/v2/examples/doxygen/amb.cpp2
-rw-r--r--Rx/v2/examples/doxygen/buffer.cpp2
-rw-r--r--Rx/v2/examples/doxygen/combine_latest.cpp2
-rw-r--r--Rx/v2/examples/doxygen/composite_exception.cpp4
-rw-r--r--Rx/v2/examples/doxygen/concat_map.cpp2
-rw-r--r--Rx/v2/examples/doxygen/create.cpp4
-rw-r--r--Rx/v2/examples/doxygen/error.cpp8
-rw-r--r--Rx/v2/examples/doxygen/finally.cpp4
-rw-r--r--Rx/v2/examples/doxygen/flat_map.cpp2
-rw-r--r--Rx/v2/examples/doxygen/from.cpp2
-rw-r--r--Rx/v2/examples/doxygen/group_by.cpp4
-rw-r--r--Rx/v2/examples/doxygen/main.cpp3
-rw-r--r--Rx/v2/examples/doxygen/main.hpp3
-rw-r--r--Rx/v2/examples/doxygen/merge.cpp2
-rw-r--r--Rx/v2/examples/doxygen/merge_delay_error.cpp22
-rw-r--r--Rx/v2/examples/doxygen/observe_on.cpp2
-rw-r--r--Rx/v2/examples/doxygen/pairwise.cpp2
-rw-r--r--Rx/v2/examples/doxygen/range.cpp2
-rw-r--r--Rx/v2/examples/doxygen/replay.cpp2
-rw-r--r--Rx/v2/examples/doxygen/skip_until.cpp2
-rw-r--r--Rx/v2/examples/doxygen/subscribe_on.cpp2
-rw-r--r--Rx/v2/examples/doxygen/take_until.cpp2
-rw-r--r--Rx/v2/examples/doxygen/with_latest_from.cpp2
-rw-r--r--Rx/v2/examples/doxygen/zip.cpp2
24 files changed, 47 insertions, 37 deletions
diff --git a/Rx/v2/examples/doxygen/amb.cpp b/Rx/v2/examples/doxygen/amb.cpp
index e7dfaa6..eab7f7e 100644
--- a/Rx/v2/examples/doxygen/amb.cpp
+++ b/Rx/v2/examples/doxygen/amb.cpp
@@ -30,7 +30,7 @@ SCENARIO("implicit amb sample"){
printf("//! [implicit amb sample]\n");
}
-std::string get_pid();
+#include "main.hpp"
SCENARIO("threaded amb sample"){
printf("//! [threaded amb sample]\n");
diff --git a/Rx/v2/examples/doxygen/buffer.cpp b/Rx/v2/examples/doxygen/buffer.cpp
index 58f023a..503db12 100644
--- a/Rx/v2/examples/doxygen/buffer.cpp
+++ b/Rx/v2/examples/doxygen/buffer.cpp
@@ -35,7 +35,7 @@ SCENARIO("buffer count+skip sample"){
printf("//! [buffer count+skip sample]\n");
}
-std::string get_pid();
+#include "main.hpp"
SCENARIO("buffer period+skip+coordination sample"){
printf("//! [buffer period+skip+coordination sample]\n");
diff --git a/Rx/v2/examples/doxygen/combine_latest.cpp b/Rx/v2/examples/doxygen/combine_latest.cpp
index b220da4..5f2168b 100644
--- a/Rx/v2/examples/doxygen/combine_latest.cpp
+++ b/Rx/v2/examples/doxygen/combine_latest.cpp
@@ -17,7 +17,7 @@ SCENARIO("combine_latest sample"){
printf("//! [combine_latest sample]\n");
}
-std::string get_pid();
+#include "main.hpp"
SCENARIO("Coordination combine_latest sample"){
printf("//! [Coordination combine_latest sample]\n");
diff --git a/Rx/v2/examples/doxygen/composite_exception.cpp b/Rx/v2/examples/doxygen/composite_exception.cpp
index 6cbfce3..00f351d 100644
--- a/Rx/v2/examples/doxygen/composite_exception.cpp
+++ b/Rx/v2/examples/doxygen/composite_exception.cpp
@@ -17,11 +17,11 @@ SCENARIO("composite_exception sample"){
[](std::exception_ptr composite_e) {
printf("OnError %s\n", rxu::what(composite_e).c_str());
try { std::rethrow_exception(composite_e); }
- catch(rxcpp::composite_exception ce) {
+ catch(rxcpp::composite_exception const &ce) {
for(std::exception_ptr particular_e : ce.exceptions) {
try{ std::rethrow_exception(particular_e); }
- catch(std::runtime_error error) { printf(" *** %s\n", error.what()); }
+ catch(std::runtime_error const &error) { printf(" *** %s\n", error.what()); }
}
}
diff --git a/Rx/v2/examples/doxygen/concat_map.cpp b/Rx/v2/examples/doxygen/concat_map.cpp
index 957665f..a087431 100644
--- a/Rx/v2/examples/doxygen/concat_map.cpp
+++ b/Rx/v2/examples/doxygen/concat_map.cpp
@@ -22,7 +22,7 @@ SCENARIO("concat_map sample"){
printf("//! [concat_map sample]\n");
}
-std::string get_pid();
+#include "main.hpp"
SCENARIO("threaded concat_map sample"){
printf("//! [threaded concat_map sample]\n");
diff --git a/Rx/v2/examples/doxygen/create.cpp b/Rx/v2/examples/doxygen/create.cpp
index c2886c2..1f707c6 100644
--- a/Rx/v2/examples/doxygen/create.cpp
+++ b/Rx/v2/examples/doxygen/create.cpp
@@ -90,8 +90,8 @@ SCENARIO("Create great code"){
[](int v){
printf("OnNext: %d\n", v);
},
- [](rxcpp::error_ptr ep){
- printf("OnError: %s\n", rxu::what(ep));
+ [](rxcpp::util::error_ptr ep){
+ printf("OnError: %s\n", rxcpp::util::what(ep).c_str());
},
[](){
printf("OnCompleted\n");
diff --git a/Rx/v2/examples/doxygen/error.cpp b/Rx/v2/examples/doxygen/error.cpp
index 7600b94..87b5b78 100644
--- a/Rx/v2/examples/doxygen/error.cpp
+++ b/Rx/v2/examples/doxygen/error.cpp
@@ -9,8 +9,8 @@ SCENARIO("error sample"){
values.
subscribe(
[](int v){printf("OnNext: %d\n", v);},
- [](rxcpp::error_ptr ep){
- printf("OnError: %s\n", rxu::what(ep));
+ [](rxcpp::util::error_ptr ep){
+ printf("OnError: %s\n", rxcpp::util::what(ep).c_str());
},
[](){printf("OnCompleted\n");});
printf("//! [error sample]\n");
@@ -23,8 +23,8 @@ SCENARIO("threaded error sample"){
as_blocking().
subscribe(
[](int v){printf("OnNext: %d\n", v);},
- [](rxcpp::error_ptr ep){
- printf("OnError: %s\n", rxu::what(ep));
+ [](rxcpp::util::error_ptr ep){
+ printf("OnError: %s\n", rxcpp::util::what(ep).c_str());
},
[](){printf("OnCompleted\n");});
printf("//! [threaded error sample]\n");
diff --git a/Rx/v2/examples/doxygen/finally.cpp b/Rx/v2/examples/doxygen/finally.cpp
index d947320..253d3a9 100644
--- a/Rx/v2/examples/doxygen/finally.cpp
+++ b/Rx/v2/examples/doxygen/finally.cpp
@@ -26,8 +26,8 @@ SCENARIO("error finally sample"){
values.
subscribe(
[](int v){printf("OnNext: %d\n", v);},
- [](rxcpp::error_ptr ep){
- printf("OnError: %s\n", rxu::what(ep));
+ [](rxcpp::util::error_ptr ep){
+ printf("OnError: %s\n", rxcpp::util::what(ep).c_str());
},
[](){printf("OnCompleted\n");});
printf("//! [error finally sample]\n");
diff --git a/Rx/v2/examples/doxygen/flat_map.cpp b/Rx/v2/examples/doxygen/flat_map.cpp
index 0c88cbe..3e0a09f 100644
--- a/Rx/v2/examples/doxygen/flat_map.cpp
+++ b/Rx/v2/examples/doxygen/flat_map.cpp
@@ -22,7 +22,7 @@ SCENARIO("flat_map sample"){
printf("//! [flat_map sample]\n");
}
-std::string get_pid();
+#include "main.hpp"
SCENARIO("threaded flat_map sample"){
printf("//! [threaded flat_map sample]\n");
diff --git a/Rx/v2/examples/doxygen/from.cpp b/Rx/v2/examples/doxygen/from.cpp
index 15186ba..7cc2276 100644
--- a/Rx/v2/examples/doxygen/from.cpp
+++ b/Rx/v2/examples/doxygen/from.cpp
@@ -13,7 +13,7 @@ SCENARIO("from sample"){
printf("//! [from sample]\n");
}
-std::string get_pid();
+#include "main.hpp"
SCENARIO("threaded from sample"){
printf("//! [threaded from sample]\n");
diff --git a/Rx/v2/examples/doxygen/group_by.cpp b/Rx/v2/examples/doxygen/group_by.cpp
index d30f334..74ef859 100644
--- a/Rx/v2/examples/doxygen/group_by.cpp
+++ b/Rx/v2/examples/doxygen/group_by.cpp
@@ -3,6 +3,8 @@
#include "rxcpp/rx-test.hpp"
#include "catch.hpp"
+#include <sstream>
+
SCENARIO("group_by sample"){
printf("//! [group_by sample]\n");
auto values = rxcpp::observable<>::range(0, 8).
@@ -23,7 +25,7 @@ SCENARIO("group_by sample"){
}
//! [group_by full intro]
-bool less(int v1, int v2){
+static bool less(int v1, int v2){
return v1 < v2;
}
//! [group_by full intro]
diff --git a/Rx/v2/examples/doxygen/main.cpp b/Rx/v2/examples/doxygen/main.cpp
index 8a831f2..4da59c5 100644
--- a/Rx/v2/examples/doxygen/main.cpp
+++ b/Rx/v2/examples/doxygen/main.cpp
@@ -4,6 +4,9 @@
#include <iostream>
#include <thread>
#include <string>
+
+#include "main.hpp"
+
std::string get_pid() {
std::stringstream s;
s << std::this_thread::get_id();
diff --git a/Rx/v2/examples/doxygen/main.hpp b/Rx/v2/examples/doxygen/main.hpp
new file mode 100644
index 0000000..7439c6a
--- /dev/null
+++ b/Rx/v2/examples/doxygen/main.hpp
@@ -0,0 +1,3 @@
+#pragma once
+
+std::string get_pid();
diff --git a/Rx/v2/examples/doxygen/merge.cpp b/Rx/v2/examples/doxygen/merge.cpp
index 6ff6539..008c378 100644
--- a/Rx/v2/examples/doxygen/merge.cpp
+++ b/Rx/v2/examples/doxygen/merge.cpp
@@ -30,7 +30,7 @@ SCENARIO("implicit merge sample"){
printf("//! [implicit merge sample]\n");
}
-std::string get_pid();
+#include "main.hpp"
SCENARIO("threaded merge sample"){
printf("//! [threaded merge sample]\n");
diff --git a/Rx/v2/examples/doxygen/merge_delay_error.cpp b/Rx/v2/examples/doxygen/merge_delay_error.cpp
index 8c28cd8..ae75926 100644
--- a/Rx/v2/examples/doxygen/merge_delay_error.cpp
+++ b/Rx/v2/examples/doxygen/merge_delay_error.cpp
@@ -4,6 +4,8 @@ namespace rxu=rxcpp::util;
#include "rxcpp/rx-test.hpp"
#include "catch.hpp"
+#include <sstream>
+
SCENARIO("merge_delay_error sample"){
printf("//! [merge_delay_error sample]\n");
auto o1 = rxcpp::observable<>::timer(std::chrono::milliseconds(15)).map([](int) {return 1;});
@@ -33,24 +35,24 @@ SCENARIO("implicit merge_delay_error sample"){
printf("//! [implicit merge_delay_error sample]\n");
}
-std::string get_pid();
+#include "main.hpp"
SCENARIO("threaded merge_delay_error sample"){
printf("//! [threaded merge_delay_error sample]\n");
printf("[thread %s] Start task\n", get_pid().c_str());
- auto o1 = rxcpp::observable<>::timer(std::chrono::milliseconds(10)).map([](int) {
+ auto o1 = rxcpp::observable<>::timer(std::chrono::milliseconds(10)).map([](long) -> long {
printf("[thread %s] Timer1 fired\n", get_pid().c_str());
return 1;
});
- auto o2 = rxcpp::observable<>::timer(std::chrono::milliseconds(20)).flat_map([](int) {
+ auto o2 = rxcpp::observable<>::timer(std::chrono::milliseconds(20)).flat_map([](long) -> rxcpp::observable<long> {
std::stringstream ss;
ss << "[thread " << get_pid().c_str() << "] Timer2 failed\n";
printf("%s\n", ss.str().c_str());
ss.str(std::string());
ss << "(Error from thread: " << get_pid().c_str() << ")\n";
- return rxcpp::observable<>::error<int>(std::runtime_error(ss.str()));
+ return rxcpp::observable<>::error<long>(std::runtime_error(ss.str()));
});
- auto o3 = rxcpp::observable<>::timer(std::chrono::milliseconds(30)).map([](int) {
+ auto o3 = rxcpp::observable<>::timer(std::chrono::milliseconds(30)).map([](long) -> long {
printf("[thread %s] Timer3 fired\n", get_pid().c_str());
return 3;
});
@@ -68,19 +70,19 @@ SCENARIO("threaded merge_delay_error sample"){
SCENARIO("threaded implicit merge_delay_error sample"){
printf("//! [threaded implicit merge_delay_error sample]\n");
printf("[thread %s] Start task\n", get_pid().c_str());
- auto o1 = rxcpp::observable<>::timer(std::chrono::milliseconds(10)).map([](int) {
+ auto o1 = rxcpp::observable<>::timer(std::chrono::milliseconds(10)).map([](long) -> long {
printf("[thread %s] Timer1 fired\n", get_pid().c_str());
return 1;
});
- auto o2 = rxcpp::observable<>::timer(std::chrono::milliseconds(20)).flat_map([](int) {
+ auto o2 = rxcpp::observable<>::timer(std::chrono::milliseconds(20)).flat_map([](long) -> rxcpp::observable<long> {
std::stringstream ss;
ss << "[thread " << get_pid().c_str() << "] Timer2 failed\n";
printf("%s\n", ss.str().c_str());
ss.str(std::string());
ss << "(Error from thread: " << get_pid().c_str() << ")\n";
- return rxcpp::observable<>::error<int>(std::runtime_error(ss.str()));
+ return rxcpp::observable<>::error<long>(std::runtime_error(ss.str()));
});
- auto o3 = rxcpp::observable<>::timer(std::chrono::milliseconds(30)).map([](int) {
+ auto o3 = rxcpp::observable<>::timer(std::chrono::milliseconds(30)).map([](long) -> long {
printf("[thread %s] Timer3 fired\n", get_pid().c_str());
return 3;
});
@@ -89,7 +91,7 @@ SCENARIO("threaded implicit merge_delay_error sample"){
values.
as_blocking().
subscribe(
- [](int v){printf("[thread %s] OnNext: %d\n", get_pid().c_str(), v);},
+ [](long v){printf("[thread %s] OnNext: %ld\n", get_pid().c_str(), v);},
[](std::exception_ptr eptr) { printf("[thread %s] OnError %s\n", get_pid().c_str(), rxu::what(eptr).c_str()); },
[](){printf("[thread %s] OnCompleted\n", get_pid().c_str());});
printf("[thread %s] Finish task\n", get_pid().c_str());
diff --git a/Rx/v2/examples/doxygen/observe_on.cpp b/Rx/v2/examples/doxygen/observe_on.cpp
index 927c339..9046999 100644
--- a/Rx/v2/examples/doxygen/observe_on.cpp
+++ b/Rx/v2/examples/doxygen/observe_on.cpp
@@ -3,7 +3,7 @@
#include "rxcpp/rx-test.hpp"
#include "catch.hpp"
-std::string get_pid();
+#include "main.hpp"
SCENARIO("observe_on sample"){
printf("//! [observe_on sample]\n");
diff --git a/Rx/v2/examples/doxygen/pairwise.cpp b/Rx/v2/examples/doxygen/pairwise.cpp
index 3dd8d34..3133679 100644
--- a/Rx/v2/examples/doxygen/pairwise.cpp
+++ b/Rx/v2/examples/doxygen/pairwise.cpp
@@ -23,7 +23,7 @@ SCENARIO("pairwise short sample"){
printf("//! [pairwise short sample]\n");
}
-//std::string get_pid();
+//#include "main.hpp"
//
//SCENARIO("threaded flat_map sample"){
// printf("//! [threaded flat_map sample]\n");
diff --git a/Rx/v2/examples/doxygen/range.cpp b/Rx/v2/examples/doxygen/range.cpp
index 69eecbd..3abb0ec 100644
--- a/Rx/v2/examples/doxygen/range.cpp
+++ b/Rx/v2/examples/doxygen/range.cpp
@@ -13,7 +13,7 @@ SCENARIO("range sample"){
printf("//! [range sample]\n");
}
-std::string get_pid();
+#include "main.hpp"
SCENARIO("threaded range sample"){
printf("//! [threaded range sample]\n");
diff --git a/Rx/v2/examples/doxygen/replay.cpp b/Rx/v2/examples/doxygen/replay.cpp
index d6f08ed..2340851 100644
--- a/Rx/v2/examples/doxygen/replay.cpp
+++ b/Rx/v2/examples/doxygen/replay.cpp
@@ -3,7 +3,7 @@
#include "rxcpp/rx-test.hpp"
#include "catch.hpp"
-std::string get_pid();
+#include "main.hpp"
SCENARIO("replay sample"){
printf("//! [replay sample]\n");
diff --git a/Rx/v2/examples/doxygen/skip_until.cpp b/Rx/v2/examples/doxygen/skip_until.cpp
index c539d8e..d99cb6e 100644
--- a/Rx/v2/examples/doxygen/skip_until.cpp
+++ b/Rx/v2/examples/doxygen/skip_until.cpp
@@ -15,7 +15,7 @@ SCENARIO("skip_until sample"){
printf("//! [skip_until sample]\n");
}
-std::string get_pid();
+#include "main.hpp"
SCENARIO("threaded skip_until sample"){
printf("//! [threaded skip_until sample]\n");
diff --git a/Rx/v2/examples/doxygen/subscribe_on.cpp b/Rx/v2/examples/doxygen/subscribe_on.cpp
index e2614bc..7a9da50 100644
--- a/Rx/v2/examples/doxygen/subscribe_on.cpp
+++ b/Rx/v2/examples/doxygen/subscribe_on.cpp
@@ -3,7 +3,7 @@
#include "rxcpp/rx-test.hpp"
#include "catch.hpp"
-std::string get_pid();
+#include "main.hpp"
SCENARIO("subscribe_on sample"){
printf("//! [subscribe_on sample]\n");
diff --git a/Rx/v2/examples/doxygen/take_until.cpp b/Rx/v2/examples/doxygen/take_until.cpp
index 5c98bc4..082171b 100644
--- a/Rx/v2/examples/doxygen/take_until.cpp
+++ b/Rx/v2/examples/doxygen/take_until.cpp
@@ -26,7 +26,7 @@ SCENARIO("take_until time sample"){
printf("//! [take_until time sample]\n");
}
-std::string get_pid();
+#include "main.hpp"
SCENARIO("threaded take_until sample"){
printf("//! [threaded take_until sample]\n");
diff --git a/Rx/v2/examples/doxygen/with_latest_from.cpp b/Rx/v2/examples/doxygen/with_latest_from.cpp
index 200f446..cf0a422 100644
--- a/Rx/v2/examples/doxygen/with_latest_from.cpp
+++ b/Rx/v2/examples/doxygen/with_latest_from.cpp
@@ -17,7 +17,7 @@ SCENARIO("with_latest_from sample"){
printf("//! [with_latest_from sample]\n");
}
-std::string get_pid();
+#include "main.hpp"
SCENARIO("Coordination with_latest_from sample"){
printf("//! [Coordination with_latest_from sample]\n");
diff --git a/Rx/v2/examples/doxygen/zip.cpp b/Rx/v2/examples/doxygen/zip.cpp
index c5cd07b..6bd295b 100644
--- a/Rx/v2/examples/doxygen/zip.cpp
+++ b/Rx/v2/examples/doxygen/zip.cpp
@@ -17,7 +17,7 @@ SCENARIO("zip sample"){
printf("//! [zip sample]\n");
}
-std::string get_pid();
+#include "main.hpp"
SCENARIO("Coordination zip sample"){
printf("//! [Coordination zip sample]\n");