A C++ wrapper for the basic C datatypes defined by the pEpEngine.
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

86 lines
2.7 KiB

6 months ago
6 months ago
6 months ago
6 months ago
  1. # libpEpDatatypes – A C++ wrapper for the basic C datatypes defined by the pEpEngine.
  2. ## Resources
  3. * Repository: https://gitea.pep.foundation/pEp.foundation/libpEpDatatypes/
  4. * Change management: <TODO: JIRA link here>
  5. ## Requirements & Platforms
  6. * License: GPL3
  7. * C++ standard: C++11
  8. * supported compilers: at least gcc and clang (both have to work)
  9. * Build sytem: GNU Make – Platforms: Linux, macOS
  10. ** Target: static library libpEpDatatypes.a
  11. * Windows and Android builds will be done separatly
  12. ## Design goals & principles
  13. * implement move c'tor & operator for cheep moves
  14. * _Qpen question_: deep copy / shallow copy (with ref couning?) / only explicit copy?
  15. * always initialize all members. Better safe than sorry.
  16. * Ownership of the member pointees: rule of thumb: "const" pointees are non-owned, non-const pointees are owned by the data structure. Exceptional cases are documented explicitly.
  17. ## Public API
  18. * defined in `namespace pEp::DT`
  19. * header files are installed in `PREFIX/include/pEp/` and are used via `#include <pEp/filename.hh>` – (Also shared with libpEpAdapter!)
  20. * the linked list datatypes implement the API of [`std::forward_list`](https://en.cppreference.com/w/cpp/container/forward_list)
  21. ### Example usage
  22. The following API is the target we're heading to:
  23. ```
  24. #include <pEp/Types.hh>
  25. #include <pEp/Adapter.hh>
  26. int main()
  27. {
  28. pEp::Message msg = "From: Alice Cooper <alice@mail.com>\n"
  29. "To: Bob Smith <bob@mail.com>\n"
  30. "Subject: Meeting\n"
  31. "\n"
  32. "Dear Bob,\n"
  33. "\n"
  34. "I will come.\n"
  35. "\n"
  36. "Alice.\n"_CRLF;
  37. try {
  38. auto enc = msg.encrypt();
  39. enc.send();
  40. }
  41. catch (pEp::err& e)
  42. {
  43. }
  44. return 0;
  45. }
  46. ```
  47. As an intermediate step the p≡p API in the engine must be fully
  48. supported:
  49. ```
  50. #include <pEp/message_api.h> // from pEpEngine
  51. #include <pEp/Types.hh> // from libpEpDatatypes
  52. #include <pEp/Adapter.hh> // from libpEpDatatypes
  53. int main()
  54. {
  55. pEp::Message msg_plain =
  56. "From: Alice Cooper <alice@mail.com>\nTo: Bob "
  57. "Smith <bob@mail.com>\nSubject: Meeting\n\n"
  58. "Dear Bob,\n\nI will come.\n\nAlice."_CRLF;
  59. ::message* msg_enc = nullptr;
  60. PEP_STATUS status = encrypt_message(msg_plain, enc_enc, ...);
  61. pEp::Message msg{std::move(msg_enc)}; // ownership of the pointee goes to 'msg'
  62. return 0;
  63. }
  64. ```
  65. ## Implementation details
  66. * Code-formatting: clang-format. Please try and use .clang-format from libpEpAdapter
  67. * Include guards: #ifdef/#define style (not #pragma once), naming style: `LIBPEPDATATYPES_FILENAME_HH`