ZRColaWS: Return source->destination index mapping
Signed-off-by: Simon Rozman <simon@rozman.si>
This commit is contained in:
parent
fa59e71fe3
commit
3aba608001
@ -65,6 +65,7 @@ public:
|
|||||||
std::u16string dst, dst2;
|
std::u16string dst, dst2;
|
||||||
if (input->text)
|
if (input->text)
|
||||||
dst = cIn.convert(*input->text);
|
dst = cIn.convert(*input->text);
|
||||||
|
size_t src_len = dst.length();
|
||||||
std::vector<ZRCola::mapping_vector> mapping;
|
std::vector<ZRCola::mapping_vector> mapping;
|
||||||
if (input->transet) {
|
if (input->transet) {
|
||||||
ZRCola::mapping_vector map;
|
ZRCola::mapping_vector map;
|
||||||
@ -92,6 +93,15 @@ public:
|
|||||||
utf16toutf8 cOut;
|
utf16toutf8 cOut;
|
||||||
auto dto = translateOutDto::createShared();
|
auto dto = translateOutDto::createShared();
|
||||||
dto->text = cOut.convert(dst);
|
dto->text = cOut.convert(dst);
|
||||||
|
auto map = oatpp::Vector<oatpp::UInt32>::createShared();
|
||||||
|
auto m_end = mapping.cend();
|
||||||
|
for (size_t i = 0; i < src_len; ++i) {
|
||||||
|
auto j = i;
|
||||||
|
for (auto m = mapping.cbegin(); m != m_end; ++m)
|
||||||
|
j = m->to_dst(j);
|
||||||
|
map->push_back(j);
|
||||||
|
}
|
||||||
|
dto->map = map;
|
||||||
return createDtoResponse(Status::CODE_200, dto);
|
return createDtoResponse(Status::CODE_200, dto);
|
||||||
} catch (std::exception &ex) {
|
} catch (std::exception &ex) {
|
||||||
OATPP_LOGE("ZRColaWS", "%s: %s", typeid(ex).name(), ex.what());
|
OATPP_LOGE("ZRColaWS", "%s: %s", typeid(ex).name(), ex.what());
|
||||||
|
@ -39,6 +39,7 @@ class translateOutDto : public oatpp::DTO
|
|||||||
{
|
{
|
||||||
DTO_INIT(translateOutDto, DTO)
|
DTO_INIT(translateOutDto, DTO)
|
||||||
DTO_FIELD(String, text);
|
DTO_FIELD(String, text);
|
||||||
|
DTO_FIELD(Vector<UInt32>, map);
|
||||||
};
|
};
|
||||||
|
|
||||||
#include OATPP_CODEGEN_END(DTO)
|
#include OATPP_CODEGEN_END(DTO)
|
||||||
|
Loading…
x
Reference in New Issue
Block a user