Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
A
Actor Framework
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Operations
Operations
Metrics
Environments
Analytics
Analytics
CI / CD
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
cpp-libs
Actor Framework
Commits
f20f86a2
Commit
f20f86a2
authored
Jan 30, 2015
by
Dominik Charousset
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Use message builder API instead of removed API
parent
b90ccd38
Changes
5
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
41 additions
and
75 deletions
+41
-75
examples/qtsupport/chatwidget.cpp
examples/qtsupport/chatwidget.cpp
+4
-2
examples/remote_actors/distributed_calculator.cpp
examples/remote_actors/distributed_calculator.cpp
+4
-2
examples/remote_actors/group_chat.cpp
examples/remote_actors/group_chat.cpp
+33
-27
libcaf_core/CMakeLists.txt
libcaf_core/CMakeLists.txt
+0
-1
libcaf_core/src/match.cpp
libcaf_core/src/match.cpp
+0
-43
No files found.
examples/qtsupport/chatwidget.cpp
View file @
f20f86a2
...
@@ -55,7 +55,9 @@ void ChatWidget::sendChatMessage() {
...
@@ -55,7 +55,9 @@ void ChatWidget::sendChatMessage() {
});
});
QString
line
=
input
()
->
text
();
QString
line
=
input
()
->
text
();
if
(
line
.
startsWith
(
'/'
))
{
if
(
line
.
startsWith
(
'/'
))
{
match_split
(
line
.
midRef
(
1
).
toUtf8
().
constData
(),
' '
)
(
vector
<
string
>
words
;
split
(
words
,
line
.
midRef
(
1
).
toUtf8
().
constData
(),
is_any_of
(
" "
));
message_builder
(
words
.
begin
(),
words
.
end
()).
apply
({
on
(
"join"
,
arg_match
)
>>
[
=
](
const
string
&
mod
,
const
string
&
g
)
{
on
(
"join"
,
arg_match
)
>>
[
=
](
const
string
&
mod
,
const
string
&
g
)
{
group
gptr
;
group
gptr
;
try
{
gptr
=
group
::
get
(
mod
,
g
);
}
try
{
gptr
=
group
::
get
(
mod
,
g
);
}
...
@@ -74,7 +76,7 @@ void ChatWidget::sendChatMessage() {
...
@@ -74,7 +76,7 @@ void ChatWidget::sendChatMessage() {
"/join <module> <group id>
\n
"
"/join <module> <group id>
\n
"
"/setName <new name>
\n
"
);
"/setName <new name>
\n
"
);
}
}
);
}
);
return
;
return
;
}
}
if
(
m_name
.
empty
())
{
if
(
m_name
.
empty
())
{
...
...
examples/remote_actors/distributed_calculator.cpp
View file @
f20f86a2
...
@@ -124,7 +124,9 @@ void client_repl(const string& host, uint16_t port) {
...
@@ -124,7 +124,9 @@ void client_repl(const string& host, uint16_t port) {
anon_send_exit
(
client
,
exit_reason
::
user_shutdown
);
anon_send_exit
(
client
,
exit_reason
::
user_shutdown
);
return
;
return
;
}
else
if
(
equal
(
begin
(
connect
),
end
(
connect
)
-
1
,
begin
(
line
)))
{
}
else
if
(
equal
(
begin
(
connect
),
end
(
connect
)
-
1
,
begin
(
line
)))
{
match_split
(
line
,
' '
)
(
vector
<
string
>
words
;
split
(
words
,
line
,
is_any_of
(
" "
));
message_builder
(
words
.
begin
(),
words
.
end
()).
apply
({
on
(
"connect"
,
arg_match
)
>>
[
&
](
string
&
nhost
,
string
&
sport
)
{
on
(
"connect"
,
arg_match
)
>>
[
&
](
string
&
nhost
,
string
&
sport
)
{
try
{
try
{
auto
lport
=
std
::
stoul
(
sport
);
auto
lport
=
std
::
stoul
(
sport
);
...
@@ -144,7 +146,7 @@ void client_repl(const string& host, uint16_t port) {
...
@@ -144,7 +146,7 @@ void client_repl(const string& host, uint16_t port) {
others
()
>>
[]
{
others
()
>>
[]
{
cout
<<
"*** usage: connect <host> <port>"
<<
endl
;
cout
<<
"*** usage: connect <host> <port>"
<<
endl
;
}
}
);
}
);
}
else
{
}
else
{
auto
toint
=
[](
const
string
&
str
)
->
optional
<
int
>
{
auto
toint
=
[](
const
string
&
str
)
->
optional
<
int
>
{
try
{
return
{
std
::
stoi
(
str
)};
}
try
{
return
{
std
::
stoi
(
str
)};
}
...
...
examples/remote_actors/group_chat.cpp
View file @
f20f86a2
...
@@ -18,6 +18,8 @@
...
@@ -18,6 +18,8 @@
#include "caf/all.hpp"
#include "caf/all.hpp"
#include "caf/io/all.hpp"
#include "caf/io/all.hpp"
#include "caf/string_algorithms.hpp"
using
namespace
std
;
using
namespace
std
;
using
namespace
caf
;
using
namespace
caf
;
...
@@ -127,35 +129,39 @@ int main(int argc, char** argv) {
...
@@ -127,35 +129,39 @@ int main(int argc, char** argv) {
return
none
;
return
none
;
};
};
};
};
istream_iterator
<
line
>
lines
(
cin
);
istream_iterator
<
line
>
eof
;
istream_iterator
<
line
>
eof
;
match_each
(
lines
,
eof
,
split_line
)
(
vector
<
string
>
words
;
on
(
"/join"
,
arg_match
)
>>
[
&
](
const
string
&
mod
,
const
string
&
id
)
{
for
(
istream_iterator
<
line
>
i
(
cin
);
i
!=
eof
;
++
i
)
{
try
{
words
.
clear
();
group
grp
=
(
mod
==
"remote"
)
?
io
::
remote_group
(
id
)
split
(
words
,
i
->
str
,
is_any_of
(
" "
));
:
group
::
get
(
mod
,
id
);
message_builder
(
words
.
begin
(),
words
.
end
()).
apply
({
anon_send
(
client_actor
,
join_atom
::
value
,
grp
);
on
(
"/join"
,
arg_match
)
>>
[
&
](
const
string
&
mod
,
const
string
&
id
)
{
}
try
{
catch
(
exception
&
e
)
{
group
grp
=
(
mod
==
"remote"
)
?
io
::
remote_group
(
id
)
cerr
<<
"*** exception: "
<<
to_verbose_string
(
e
)
<<
endl
;
:
group
::
get
(
mod
,
id
);
anon_send
(
client_actor
,
join_atom
::
value
,
grp
);
}
catch
(
exception
&
e
)
{
cerr
<<
"*** exception: "
<<
to_verbose_string
(
e
)
<<
endl
;
}
},
on
(
"/quit"
)
>>
[
&
]
{
// close STDIN; causes this match loop to quit
cin
.
setstate
(
ios_base
::
eofbit
);
},
on
(
starts_with
(
"/"
),
any_vals
)
>>
[
&
]
{
cout
<<
"*** available commands:
\n
"
" /join <module> <group> join a new chat channel
\n
"
" /quit quit the program
\n
"
" /help print this text
\n
"
<<
flush
;
},
others
()
>>
[
&
]
{
if
(
!
s_last_line
.
empty
())
{
anon_send
(
client_actor
,
broadcast_atom
::
value
,
s_last_line
);
}
}
}
},
});
on
(
"/quit"
)
>>
[
&
]
{
}
// close STDIN; causes this match loop to quit
cin
.
setstate
(
ios_base
::
eofbit
);
},
on
(
starts_with
(
"/"
),
any_vals
)
>>
[
&
]
{
cout
<<
"*** available commands:
\n
"
" /join <module> <group> join a new chat channel
\n
"
" /quit quit the program
\n
"
" /help print this text
\n
"
<<
flush
;
},
others
()
>>
[
&
]
{
if
(
!
s_last_line
.
empty
())
{
anon_send
(
client_actor
,
broadcast_atom
::
value
,
s_last_line
);
}
}
);
// force actor to quit
// force actor to quit
anon_send_exit
(
client_actor
,
exit_reason
::
user_shutdown
);
anon_send_exit
(
client_actor
,
exit_reason
::
user_shutdown
);
await_all_actors_done
();
await_all_actors_done
();
...
...
libcaf_core/CMakeLists.txt
View file @
f20f86a2
...
@@ -52,7 +52,6 @@ set (LIBCAF_CORE_SRCS
...
@@ -52,7 +52,6 @@ set (LIBCAF_CORE_SRCS
src/local_actor.cpp
src/local_actor.cpp
src/logging.cpp
src/logging.cpp
src/mailbox_element.cpp
src/mailbox_element.cpp
src/match.cpp
src/memory.cpp
src/memory.cpp
src/memory_managed.cpp
src/memory_managed.cpp
src/message.cpp
src/message.cpp
...
...
libcaf_core/src/match.cpp
deleted
100644 → 0
View file @
b90ccd38
/******************************************************************************
* ____ _ _____ *
* / ___| / \ | ___| C++ *
* | | / _ \ | |_ Actor *
* | |___ / ___ \| _| Framework *
* \____/_/ \_|_| *
* *
* Copyright (C) 2011 - 2014 *
* Dominik Charousset <dominik.charousset (at) haw-hamburg.de> *
* *
* Distributed under the terms and conditions of the BSD 3-Clause License or *
* (at your option) under the terms and conditions of the Boost Software *
* License 1.0. See accompanying files LICENSE and LICENSE_ALTERNATIVE. *
* *
* If you did not receive a copy of the license files, see *
* http://opensource.org/licenses/BSD-3-Clause and *
* http://www.boost.org/LICENSE_1_0.txt. *
******************************************************************************/
#include <vector>
#include <string>
#include <sstream>
#include "caf/match.hpp"
using
namespace
std
;
namespace
caf
{
detail
::
match_helper
match_split
(
const
std
::
string
&
str
,
char
delim
,
bool
keep_empties
)
{
message_builder
result
;
stringstream
strs
(
str
);
string
tmp
;
while
(
getline
(
strs
,
tmp
,
delim
))
{
if
(
!
tmp
.
empty
()
&&
!
keep_empties
)
{
result
.
append
(
std
::
move
(
tmp
));
}
}
return
result
.
to_message
();
}
}
// namespace caf
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment