ClickHouse/programs/library-bridge/ExternalDictionaryLibraryUtils.h

Ignoring revisions in .git-blame-ignore-revs. Click here to bypass and see the normal blame view.

44 lines
875 B
C++
Raw Permalink Normal View History

2021-03-05 09:38:00 +00:00
#pragma once
2024-05-19 08:02:06 +00:00
#include <Common/StringUtils.h>
2021-03-05 09:38:00 +00:00
#include <Core/Block.h>
2021-10-02 07:13:14 +00:00
#include <base/range.h>
2021-03-05 09:38:00 +00:00
#include "ExternalDictionaryLibraryAPI.h"
2021-03-05 09:38:00 +00:00
namespace DB
{
class CStringsHolder
{
public:
using Container = std::vector<std::string>;
explicit CStringsHolder(const Container & strings_pass)
{
strings_holder = strings_pass;
strings.size = strings_holder.size();
ptr_holder = std::make_unique<ExternalDictionaryLibraryAPI::CString[]>(strings.size);
2021-03-05 09:38:00 +00:00
strings.data = ptr_holder.get();
size_t i = 0;
for (auto & str : strings_holder)
{
strings.data[i] = str.c_str();
++i;
}
}
ExternalDictionaryLibraryAPI::CStrings strings; // will pass pointer to lib
2021-03-05 09:38:00 +00:00
private:
std::unique_ptr<ExternalDictionaryLibraryAPI::CString[]> ptr_holder;
2021-03-05 09:38:00 +00:00
Container strings_holder;
};
}