aboutsummaryrefslogtreecommitdiffstats
path: root/contrib/clickhouse/src/Core/MySQL/MySQLCharset.h
blob: 4371a2853ed36b2007e45e4eb78013f422ad67f6 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
#pragma once
#include <unordered_map>
#include <base/types.h>
#include <boost/noncopyable.hpp>
#include <mutex>

struct UConverter;

namespace DB
{
class MySQLCharset final : boost::noncopyable
{
public:
    ~MySQLCharset();
    String getCharsetFromId(UInt32 id);
    Int32 convertFromId(UInt32 id, String & to, const String & from);
    bool needConvert(UInt32 id);
private:
    std::mutex mutex;
    std::unordered_map<String, UConverter *> conv_cache;
    UConverter * getCachedConverter(const String & charset);
    static const std::unordered_map<Int32, String> charsets;
};

using MySQLCharsetPtr = std::shared_ptr<MySQLCharset>;
}