declare 'std::foo' and remove 'lyx::'

git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@18233 a592a061-630c-0410-9148-cb99ea01b6c8
This commit is contained in:
Abdelrazak Younes 2007-05-08 14:01:40 +00:00
parent b6407071cf
commit 492562091e

View File

@ -23,6 +23,10 @@
#include <map> #include <map>
using std::endl; using std::endl;
using std::map;
using std::make_pair;
using std::string;
using std::vector;
namespace { namespace {
@ -193,13 +197,13 @@ namespace {
template<typename RetType, typename InType> template<typename RetType, typename InType>
std::vector<RetType> vector<RetType>
iconv_convert(IconvProcessor & processor, iconv_convert(IconvProcessor & processor,
InType const * buf, InType const * buf,
size_t buflen) size_t buflen)
{ {
if (buflen == 0) if (buflen == 0)
return std::vector<RetType>(); return vector<RetType>();
char const * inbuf = reinterpret_cast<char const *>(buf); char const * inbuf = reinterpret_cast<char const *>(buf);
size_t inbytesleft = buflen * sizeof(InType); size_t inbytesleft = buflen * sizeof(InType);
@ -212,33 +216,33 @@ iconv_convert(IconvProcessor & processor,
if (bytes <= 0) if (bytes <= 0)
// Conversion failed // Conversion failed
// FIXME Maybe throw an exception and handle that in the caller? // FIXME Maybe throw an exception and handle that in the caller?
return std::vector<RetType>(); return vector<RetType>();
RetType const * tmp = reinterpret_cast<RetType const *>(out); RetType const * tmp = reinterpret_cast<RetType const *>(out);
return std::vector<RetType>(tmp, tmp + bytes / sizeof(RetType)); return vector<RetType>(tmp, tmp + bytes / sizeof(RetType));
} }
} // anon namespace } // anon namespace
std::vector<lyx::char_type> utf8_to_ucs4(std::vector<char> const & utf8str) vector<char_type> utf8_to_ucs4(vector<char> const & utf8str)
{ {
if (utf8str.empty()) if (utf8str.empty())
return std::vector<lyx::char_type>(); return vector<char_type>();
return utf8_to_ucs4(&utf8str[0], utf8str.size()); return utf8_to_ucs4(&utf8str[0], utf8str.size());
} }
std::vector<lyx::char_type> vector<char_type>
utf8_to_ucs4(char const * utf8str, size_t ls) utf8_to_ucs4(char const * utf8str, size_t ls)
{ {
static IconvProcessor processor(ucs4_codeset, "UTF-8"); static IconvProcessor processor(ucs4_codeset, "UTF-8");
return iconv_convert<lyx::char_type>(processor, utf8str, ls); return iconv_convert<char_type>(processor, utf8str, ls);
} }
std::vector<char_type> vector<char_type>
utf16_to_ucs4(unsigned short const * s, size_t ls) utf16_to_ucs4(unsigned short const * s, size_t ls)
{ {
static IconvProcessor processor(ucs4_codeset, utf16_codeset); static IconvProcessor processor(ucs4_codeset, utf16_codeset);
@ -246,7 +250,7 @@ utf16_to_ucs4(unsigned short const * s, size_t ls)
} }
std::vector<unsigned short> vector<unsigned short>
ucs4_to_utf16(char_type const * s, size_t ls) ucs4_to_utf16(char_type const * s, size_t ls)
{ {
static IconvProcessor processor(utf16_codeset, ucs4_codeset); static IconvProcessor processor(utf16_codeset, ucs4_codeset);
@ -254,51 +258,51 @@ ucs4_to_utf16(char_type const * s, size_t ls)
} }
std::vector<char> vector<char>
ucs4_to_utf8(lyx::char_type c) ucs4_to_utf8(char_type c)
{ {
static IconvProcessor processor("UTF-8", ucs4_codeset); static IconvProcessor processor("UTF-8", ucs4_codeset);
return iconv_convert<char>(processor, &c, 1); return iconv_convert<char>(processor, &c, 1);
} }
std::vector<char> vector<char>
ucs4_to_utf8(std::vector<lyx::char_type> const & ucs4str) ucs4_to_utf8(vector<char_type> const & ucs4str)
{ {
if (ucs4str.empty()) if (ucs4str.empty())
return std::vector<char>(); return vector<char>();
return ucs4_to_utf8(&ucs4str[0], ucs4str.size()); return ucs4_to_utf8(&ucs4str[0], ucs4str.size());
} }
std::vector<char> vector<char>
ucs4_to_utf8(lyx::char_type const * ucs4str, size_t ls) ucs4_to_utf8(char_type const * ucs4str, size_t ls)
{ {
static IconvProcessor processor("UTF-8", ucs4_codeset); static IconvProcessor processor("UTF-8", ucs4_codeset);
return iconv_convert<char>(processor, ucs4str, ls); return iconv_convert<char>(processor, ucs4str, ls);
} }
std::vector<lyx::char_type> vector<char_type>
eightbit_to_ucs4(char const * s, size_t ls, std::string const & encoding) eightbit_to_ucs4(char const * s, size_t ls, string const & encoding)
{ {
static std::map<std::string, IconvProcessor> processors; static map<string, IconvProcessor> processors;
if (processors.find(encoding) == processors.end()) { if (processors.find(encoding) == processors.end()) {
IconvProcessor processor(ucs4_codeset, encoding.c_str()); IconvProcessor processor(ucs4_codeset, encoding.c_str());
processors.insert(std::make_pair(encoding, processor)); processors.insert(make_pair(encoding, processor));
} }
return iconv_convert<char_type>(processors[encoding], s, ls); return iconv_convert<char_type>(processors[encoding], s, ls);
} }
std::vector<char> vector<char>
ucs4_to_eightbit(lyx::char_type const * ucs4str, size_t ls, std::string const & encoding) ucs4_to_eightbit(char_type const * ucs4str, size_t ls, string const & encoding)
{ {
static std::map<std::string, IconvProcessor> processors; static map<string, IconvProcessor> processors;
if (processors.find(encoding) == processors.end()) { if (processors.find(encoding) == processors.end()) {
IconvProcessor processor(encoding.c_str(), ucs4_codeset); IconvProcessor processor(encoding.c_str(), ucs4_codeset);
processors.insert(std::make_pair(encoding, processor)); processors.insert(make_pair(encoding, processor));
} }
return iconv_convert<char>(processors[encoding], ucs4str, ls); return iconv_convert<char>(processors[encoding], ucs4str, ls);
} }