mirror of
https://gitlab.linphone.org/BC/public/linphone-iphone.git
synced 2026-01-30 01:39:20 +00:00
Add c-tools macros and methods to convert bctbx_list_t to std::list and the opposite.
This commit is contained in:
parent
665ff35efc
commit
1e1d0d2f7f
2 changed files with 23 additions and 5 deletions
|
|
@ -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) {
|
||||
|
|
|
|||
|
|
@ -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_
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue