Inline qstring_helpers methods.

git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@21792 a592a061-630c-0410-9148-cb99ea01b6c8
This commit is contained in:
Abdelrazak Younes 2007-11-26 10:26:03 +00:00
parent 504fe5343b
commit 09ff5016cd
4 changed files with 14 additions and 43 deletions

View File

@ -363,7 +363,6 @@ src_support_files = Split('''
lyxtime.cpp
mkdir.cpp
os.cpp
qstring_helpers.cpp
rename.cpp
socktools.cpp
tempname.cpp

View File

@ -69,7 +69,6 @@ liblyxsupport_la_SOURCES = \
Path.h \
Package.cpp \
Package.h \
qstring_helpers.cpp \
qstring_helpers.h \
rename.cpp \
socktools.cpp \
@ -124,7 +123,7 @@ check_PROGRAMS = \
check_lstrings
check_convert_LDADD = ../debug.o convert.o docstring.o lstrings.o unicode.o \
qstring_helpers.o $(BOOST_LIBS) $(QT4_CORE_LIB)
$(BOOST_LIBS) $(QT4_CORE_LIB)
check_convert_LDFLAGS = $(QT4_CORE_LDFLAGS)
check_convert_SOURCES = \
tests/check_convert.cpp \
@ -136,7 +135,7 @@ check_filetools_SOURCES = \
tests/boost.cpp
check_lstrings_LDADD = ../debug.o lstrings.o convert.o docstring.o unicode.o \
qstring_helpers.o $(QT4_CORE_LIB)
$(QT4_CORE_LIB)
check_lstrings_LDFLAGS = $(QT4_CORE_LDFLAGS)
check_lstrings_SOURCES = \
tests/check_lstrings.cpp \

View File

@ -1,36 +0,0 @@
/**
* \file qstring_helpers.cpp
* This file is part of LyX, the document processor.
* Licence details can be found in the file COPYING.
*
* \author Dekel Tsur
* \author Jürgen Spitzmüller
*
* Full author contact details are available in file CREDITS.
*/
#include <config.h>
#include "qstring_helpers.h"
#include "unicode.h"
#include <QVector>
namespace lyx {
using std::string;
docstring const qstring_to_ucs4(QString const & qstr)
{
QVector<uint> const ucs4 = qstr.toUcs4();
return docstring(ucs4.begin(), ucs4.end());
}
string const fromqstr(QString const & str)
{
return str.isEmpty() ? string() : string(str.toUtf8());
}
} // namespace lyx

View File

@ -15,6 +15,7 @@
#include "support/docstring.h"
#include <QString>
#include <QVector>
namespace lyx {
@ -70,8 +71,13 @@ inline QString const toqstr(docstring const & ucs4)
* This is the preferred method of converting anything that possibly
* contains non-ASCII stuff to docstring.
*/
docstring const qstring_to_ucs4(QString const & qstr);
inline docstring const qstring_to_ucs4(QString const & qstr)
{
if (qstr.isEmpty())
return docstring();
QVector<uint> const ucs4 = qstr.toUcs4();
return docstring((char_type const *)(ucs4.constData()), ucs4.size());
}
/**
* fromqstr - convert a QString into a UTF8 encoded std::string
@ -79,7 +85,10 @@ docstring const qstring_to_ucs4(QString const & qstr);
* This should not be used except for output to lyxerr, since all possibly
* non-ASCII stuff should be stored in a docstring.
*/
std::string const fromqstr(QString const & str);
inline std::string const fromqstr(QString const & str)
{
return str.isEmpty() ? std::string() : std::string(str.toUtf8());
}
} // namespace lyx