#include "demo_string_sending_filter.h"
#include <codecvt>
#include <iostream>
#include <locale>
#include <sstream>
cDemoStringSending::cDemoStringSending()
{
SetDescription("This Filter shows how to send samples with string content via output pin. It uses the stream_type_string.");
m_pWriterString = CreateOutputPin<pin_writer<std::string>>("out_string", stream_type_string<std::string>());
SetDescription("out_string", "Provides a string with the current time");
m_pWriterU16String
= CreateOutputPin<pin_writer<std::u16string>>("out_16string", stream_type_string<std::u16string>());
SetDescription("out_16string", "Provides a u16string with the current time");
SetDescription("string_generator_function", "Runner to periodically trigger the function which generates the output data for all pins");
SetHelpLink("$(ADTF_DIR)/doc/adtf_html/page_demo_string_handling_filters.html");
}
namespace
{
std::u16string convert_to_u16string(const std::string& strValue)
{
std::wstring_convert<std::codecvt_utf8_utf16<char16_t>, char16_t> oConverter;
return oConverter.from_bytes(strValue);
}
template<typename T>
std::u16string to_u16string(const T& value)
{
}
}
tResult cDemoStringSending::Process(tNanoSeconds tmTimeOfTrigger,
IRunner* )
{
{
std::stringstream strTimeToSend;
strTimeToSend << "Hello, current trigger time is : " << tmTimeOfTrigger.nCount << " nanoseconds";
}
{
std::u16string strTimeToSend = u"Hello, current trigger time is : " + to_u16string(tmTimeOfTrigger.nCount) + u" nanoseconds"
+ u" with umlauts :" + u"\u00e4" + u" " + u"\u00f6" + u" " + u"\u00fc";
}
}
#define RETURN_IF_FAILED(s)
Return if expression is failed, which requires the calling function's return type to be tResult.
#define RETURN_NOERROR
Return status ERR_NOERROR, which requires the calling function's return type to be tResult.
cString to_string(const tResult &i_oResult, eResultFormatFlags i_eFormatFlags=eResultFormatFlags::RFF_DisableNone, const tChar *i_strFormat=nullptr)
Copy all information of an assigned result object to a (formatted) string.
std::chrono::seconds seconds
Compatibility to C++11 std::chrono::seconds