Jump to content

LibMISB/LibMISB Introduction/ Functionalities supported: Difference between revisions

no edit summary
No edit summary
No edit summary
Line 56: Line 56:
   * object and viceversa
   * object and viceversa
   *
   *
   * @param formatter Enum formatter that manages the format type that codec
   * @param formatter formatter object that manages the format type that codec
   * will use
   * will use
   */
   */
   void SetFormatter(int formatter_number);
   void SetFormatter(std::shared_ptr<libmisb::formatter::iFormatter> formatter);
</syntaxhighlight>
</syntaxhighlight>


In which the formatter_number is dependent on formatter supported.
 


'''Use case''':
'''Use case''':
Remeber to include the formatter header in your code:
<syntaxhighlight lang=C>
<syntaxhighlight lang=C>
  libmisb::LibMisb libmisb;
#include "libmisb/formatter/jsonformatter.hpp"
  libmisb.SetFormatter(libmisb::formatter::JSON_FORMAT);
</syntaxhighlight>
</syntaxhighlight>
The libmisb::formatter::JSON_FORMAT parameter corresponds to an enum indicating which format type is to be implemented.
At the moment, the enum is as follows:


<syntaxhighlight lang=C>
<syntaxhighlight lang=C>
enum Formats { JSON_FORMAT };
  libmisb::LibMisb libmisb;
  std::shared_ptr<libmisb::formatter::iFormatter> json_formatter = std::make_shared<libmisb::formatter::JsonFormatter>();
  libmisb.SetFormatter(json_formatter);
</syntaxhighlight>
</syntaxhighlight>


=== Encode ===
=== Encode ===
267

edits

Cookies help us deliver our services. By using our services, you agree to our use of cookies.