本文整理汇总了C++中Converter::GetConverter方法的典型用法代码示例。如果您正苦于以下问题:C++ Converter::GetConverter方法的具体用法?C++ Converter::GetConverter怎么用?C++ Converter::GetConverter使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Converter
的用法示例。
在下文中一共展示了Converter::GetConverter方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: CreateConverter
Converter* ConverterFactory::CreateConverter(const std::string& sourceCharset, const std::string& targetCharset, unsigned int targetSingleCharMaxLen, unsigned int timeOfExist) {
XR::CSingleLock lock(m_critSect);
if (targetCharset == "UTF-8" && targetSingleCharMaxLen != 4) {
LOGFATAL("Failed to create converter (%s --> %s) as single character max Lenght for UTF-8 is 4.", sourceCharset.c_str(), targetCharset.c_str());
return nullptr;
}
std::string ident = sourceCharset + targetCharset;
for (unsigned int i = 0; i < m_vConverters.size(); ++i) //check for duplicate
{
ConverterUnit& converterunit = m_vConverters[i];
if (converterunit.m_ident == ident) {
converterunit.m_unloadDelayStartTick = XR::SystemClockMillis();
return converterunit.m_converter;
}
}
Converter* pNewConverter = nullptr;
pNewConverter = new Converter(sourceCharset, targetCharset, targetSingleCharMaxLen, timeOfExist);
XR::CSingleLock convLock(*pNewConverter);
if (NO_ICONV == pNewConverter->GetConverter(convLock)) {
convLock.Leave();
delete pNewConverter;
return nullptr;
}
ConverterFactory::ConverterUnit newUnit;
newUnit.m_converter = pNewConverter;
newUnit.m_ident = ident;
newUnit.m_unloadDelayStartTick = XR::SystemClockMillis();
m_vConverters.push_back(newUnit);
LOGDEBUG("Succesfully created converter (%s --> %s).", sourceCharset.c_str(), targetCharset.c_str());
return pNewConverter;
}