54 lines
1.3 KiB
C++
54 lines
1.3 KiB
C++
#pragma once
|
|
/**
|
|
* @file item2chinese.hpp
|
|
* @brief
|
|
* @author your name (you@domain.com)
|
|
* @version 0.1
|
|
* @date 2026-01-15
|
|
*
|
|
* Copyright: Baosight Co. Ltd.
|
|
* DO NOT COPY/USE WITHOUT PERMISSION
|
|
*
|
|
*/
|
|
|
|
#include <glob/BinaryTele.h>
|
|
#include <string>
|
|
#include <unordered_map>
|
|
#include <zlib/MemVar.h>
|
|
#include <zlib/zoneDef.h>
|
|
class Item2Chines {
|
|
private:
|
|
std::unordered_map<std::string, std::string> data_;
|
|
|
|
BinaryTele binary_tele{CMemVar::Const()->event_eis_start, "T_LOV_FDAAITEM"};
|
|
|
|
private:
|
|
void select_fdaaitem() {
|
|
|
|
const auto prefix = string(CMemVar::Const()->UnitNo) + "_";
|
|
for (int i = CMemVar::Const()->event_eis_start;
|
|
i <= CMemVar::Const()->event_eis_end; i++) {
|
|
binary_tele.ReBuild(i);
|
|
auto size = binary_tele.size();
|
|
for (int j = 0; j < size; j++) {
|
|
std::string item = binary_tele[j].item;
|
|
std::string chinese = binary_tele[j].chinese;
|
|
// auto item_name = prefix + item;
|
|
auto item_name = item;
|
|
data_[item_name] = chinese;
|
|
}
|
|
}
|
|
}
|
|
|
|
public:
|
|
std::string operator()(const std::string &item) const {
|
|
auto it = data_.find(item);
|
|
if (it != data_.end()) {
|
|
return it->second; // 返回找到的翻译副本
|
|
}
|
|
return item; // 安全地返回传入项的副本
|
|
}
|
|
|
|
Item2Chines() { select_fdaaitem(); }
|
|
~Item2Chines() {}
|
|
}; |