mirror of
https://github.com/ONLYOFFICE/core.git
synced 2026-07-13 16:24:45 +08:00
33 lines
892 B
C++
33 lines
892 B
C++
#ifndef _AVS_IAMGEMETADATA_UTILS_H_INCLUDED_
|
|
#define _AVS_IAMGEMETADATA_UTILS_H_INCLUDED_
|
|
#pragma once
|
|
|
|
#include <string>
|
|
#include <sstream>
|
|
|
|
namespace AVS
|
|
{
|
|
namespace Utils
|
|
{
|
|
/*!
|
|
* \brief Ïåðåâîä ñòðîêè wchar_t * â char * â ñîîòâåòñòâèè ñ çàäàííîé êîäîâîé ñòðàíèöåé
|
|
*
|
|
* \param[in] wstr èñõîäíàÿ ñòðîêà
|
|
* \param[in] codepage Êîäîâàÿ ñòðàíèöà, ïî óìîë÷àíèþ èñïîëüçóåòñÿ CP_ACP — òåêóùàÿ êîäîâàÿ ñòðàíèöà Windows
|
|
*
|
|
*/
|
|
extern std::string __WtoS(const wchar_t* wstr, int codepage = 0);
|
|
extern std::wstring __StoW(const char * str, int codepage = 0);
|
|
|
|
template <typename Target, typename Source>
|
|
Target lexical_cast(Source arg)
|
|
{
|
|
std::wstringstream interpreter;
|
|
Target result;
|
|
if (!(interpreter << arg) || !(interpreter >> result) || !(interpreter >> std::ws).eof())
|
|
throw std::bad_cast();
|
|
return result;
|
|
}
|
|
}
|
|
}
|
|
#endif |