Skip to content
GitLab
Menu
Projects
Groups
Snippets
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
BC
public
liblinphone
Commits
1e1d0d2f
Commit
1e1d0d2f
authored
Sep 12, 2017
by
Ghislain MARY
Browse files
Add c-tools macros and methods to convert bctbx_list_t to std::list and the opposite.
parent
665ff35e
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
23 additions
and
5 deletions
+23
-5
coreapi/chat.c
coreapi/chat.c
+1
-5
src/c-wrapper/c-tools.h
src/c-wrapper/c-tools.h
+22
-0
No files found.
coreapi/chat.c
View file @
1e1d0d2f
...
...
@@ -682,11 +682,7 @@ void linphone_chat_room_set_call(LinphoneChatRoom *cr, LinphoneCall *call) {
}
bctbx_list_t
*
linphone_chat_room_get_transient_messages
(
const
LinphoneChatRoom
*
cr
)
{
std
::
list
<
LinphoneChatMessage
*>
l
=
L_GET_PRIVATE
(
cr
->
cr
)
->
getTransientMessages
();
bctbx_list_t
*
result
=
nullptr
;
for
(
auto
it
=
l
.
begin
();
it
!=
l
.
end
();
it
++
)
result
=
bctbx_list_append
(
result
,
*
it
);
return
result
;
return
L_GET_C_LIST_FROM_CPP_LIST
(
L_GET_PRIVATE
(
cr
->
cr
)
->
getTransientMessages
(),
LinphoneChatMessage
);
}
const
char
*
linphone_chat_message_state_to_string
(
const
LinphoneChatMessageState
state
)
{
...
...
src/c-wrapper/c-tools.h
View file @
1e1d0d2f
...
...
@@ -19,6 +19,7 @@
#ifndef _C_TOOLS_H_
#define _C_TOOLS_H_
#include <list>
#include <memory>
#include <string>
...
...
@@ -63,6 +64,22 @@ public:
static_cast
<
WrappedObject
<
T
>
*>
(
object
)
->
cppPtr
=
cppPtr
;
}
template
<
typename
T
>
static
inline
bctbx_list_t
*
getCListFromCppList
(
std
::
list
<
T
>
cppList
)
{
bctbx_list_t
*
result
=
nullptr
;
for
(
auto
it
=
cppList
.
begin
();
it
!=
cppList
.
end
();
it
++
)
result
=
bctbx_list_append
(
result
,
*
it
);
return
result
;
}
template
<
typename
T
>
static
inline
std
::
list
<
T
>
getCppListFromCList
(
bctbx_list_t
*
cList
)
{
std
::
list
<
T
>
result
;
for
(
auto
it
=
cList
;
it
;
it
=
bctbx_list_next
(
it
))
result
.
push_back
(
static_cast
<
T
>
(
bctbx_list_get_data
(
it
)));
return
result
;
}
private:
Wrapper
();
...
...
@@ -121,4 +138,9 @@ LINPHONE_END_NAMESPACE
#define L_GET_PRIVATE_FROM_C_STRUCT(OBJECT, TYPE) \
L_GET_PRIVATE(L_GET_CPP_PTR_FROM_C_STRUCT(OBJECT, TYPE).get())
#define L_GET_C_LIST_FROM_CPP_LIST(LIST, TYPE) \
LINPHONE_NAMESPACE::Wrapper::getCListFromCppList<TYPE *>(LIST)
#define L_GET_CPP_LIST_FROM_C_LIST(LIST, TYPE) \
LINPHONE_NAMESPACE::Wrapper::getCppListFromCList<TYPE *>(LIST)
#endif // ifndef _C_TOOLS_H_
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