LIMA
Libre Multilingual Analyzer — C++ API
Loading...
Searching...
No Matches
Lima::Common::Misc Namespace Reference

Classes

class  CompareObjectPtr
 
class  DoubleAccessObjectToIdMap
 storage for double access: from object to id and from id to object : id must be integer. More...
 
class  GenericDocumentProperties
 
class  GenericDocumentPropertiesPrivate
 
class  MultiValuedPropertyIterator
 Holds document properties. More...
 
class  S2ByteString
 
class  TextFormater
 This class is dedicated to the various adaptations that have to be done on texts : More...
 

Typedefs

typedef std::vector< std::string >::const_iterator StringPropMultIter
 
typedef std::vector< std::pair< std::string, float > >::const_iterator WeightedPropMultIter
 
typedef std::vector< std::pair< Position, Length > > PositionLengthList
 

Functions

bool mypredicate (const std::pair< std::string, float > &a, const std::pair< std::string, float > &b)
 
std::ostream & operator<< (std::ostream &os, const GenericDocumentProperties &p)
 
QDebug & operator<< (QDebug &os, const GenericDocumentProperties &p)
 
QTextStream & operator<< (QTextStream &os, const GenericDocumentProperties &p)
 
uint64_t readCodedInt (std::istream &file)
 read a integer coded in variable-byte format in a file
 
void writeCodedInt (std::ostream &file, const uint64_t number)
 write a integer coded in variable-byte format in a file
 
uint8_t readOneByteInt (std::istream &file)
 read a integer coded on one byte in a file
 
void writeOneByteInt (std::ostream &file, const uint8_t number)
 write a integer coded on one byte format in a file
 
void readStream (std::istream &is, std::string &dest)
 Read an input stream into a string, until EOF.
 
void writeStream (std::ostream &os, const std::string &src)
 Write a string to an output stream.
 
std::string readLine (std::istream &inputFile)
 
void readString (std::istream &file, std::string &s)
 Read an input stream into a wide string, until EOF.
 
void writeString (std::ostream &file, const std::string &s)
 write a string on an output file stream
 
void readStringField (istream &file, string &s)
 
void writeStringField (ostream &file, const string &s)
 
void readUTF8StringField (std::istream &file, Lima::LimaString &s)
 Binary read an utf8 string from a file and store it in a LimaString.
 
void writeUTF8StringField (std::ostream &file, const Lima::LimaString &s)
 Binary write a a LimaString in a file as an utf8 string.
 
LimaString utf8stdstring2limastring (const std::string &src)
 
std::string localestring2utf8string (const std::string &src)
 ␈rief Convert a string in the locale codepage to a UTF8 string
 
LimaString latin15stdstring2limastring (const std::string &src)
 Convert a latin15 string to a LimaString.
 
std::string limastring2utf8stdstring (const Lima::LimaString &phrase, uint32_t size)
 Convert a wide string to a string , in dest up to size bytes.
 
std::string limastring2utf8stdstring (const Lima::LimaString &src)
 Convert a Lima string to a string.
 
LimaString setStringSameEndian (const unsigned short *s, const uint32_t count)
 redefine an existing LimaString from UTF-16
 
LimaString setStringReverseEndian (const unsigned short *s, const uint32_t count)
 redefine an existing LimaString from UTF-16 changing the endian mode
 
LimaString transcodeToXmlEntities (const LimaString &str)
 
template<typename C >
void chomp (std::basic_string< C > &str)
 
template<typename C >
void chop (std::basic_string< C > &str)
 
template<typename charT >
std::string convertString (const std::basic_string< charT > &input)
 
LIMA_DATA_EXPORT LimaString setStringSameEndian (const short unsigned int *s, const uint32_t count)
 
LIMA_DATA_EXPORT LimaString setStringReverseEndian (const short unsigned int *s, const uint32_t count)
 
uint64_t countLines (std::istream &file)
 Count the number of lines in the given file from the current position.
 
uint64_t countLines (QFile &file)
 Count the number of lines in the given file from the current position.
 
void appendNonEmptyDirs (QStringList &target, const QStringList &source)
 
QString getEnvVar (const QString &name)
 
QString getDataHome ()
 
void appendFirstOrSecond (QStringList &target, const QString &path, const QString &alt_path)
 
void appendFirstOrSecondForProject (QStringList &target, const QString &project, const QString &path_prefix, const QString &path_postfix=QString(""))
 
void buildDirectoriesListForProject (QStringList &target, const QString &project, const QString &env_postfix, const QString &path_prefix, const QString &path_postfix=QString(""))
 
QStringList buildConfigurationDirectoriesList (const QStringList &projects=QStringList(), const QStringList &paths=QStringList())
 Build a list of configuration directories from a list of project names and a list of paths.
 
QStringList buildResourcesDirectoriesList (const QStringList &projects, const QStringList &paths=QStringList())
 Build a list of resources directories from a list of project names and a list of paths.
 
QString findFileInPaths (const QString &paths, const QString &fileName, const QChar &separator=QLatin1Char(LIMA_PATH_SEPARATOR))
 Find the given file in the given paths.
 

Typedef Documentation

◆ PositionLengthList

typedef std::vector<std::pair<Position, Length> > Lima::Common::Misc::PositionLengthList

Definition at line 31 of file positionLengthList.h.

◆ StringPropMultIter

typedef std::vector<std::string>::const_iterator Lima::Common::Misc::StringPropMultIter

Definition at line 53 of file genericDocumentProperties.h.

◆ WeightedPropMultIter

typedef std::vector<std::pair<std::string,float>>::const_iterator Lima::Common::Misc::WeightedPropMultIter

Definition at line 54 of file genericDocumentProperties.h.

Function Documentation

◆ appendFirstOrSecond()

void Lima::Common::Misc::appendFirstOrSecond ( QStringList &  target,
const QString &  path,
const QString &  alt_path 
)

Definition at line 95 of file FileUtils.cpp.

◆ appendFirstOrSecondForProject()

void Lima::Common::Misc::appendFirstOrSecondForProject ( QStringList &  target,
const QString &  project,
const QString &  path_prefix,
const QString &  path_postfix = QString("") 
)

Definition at line 108 of file FileUtils.cpp.

◆ appendNonEmptyDirs()

void Lima::Common::Misc::appendNonEmptyDirs ( QStringList &  target,
const QStringList &  source 
)

Definition at line 64 of file FileUtils.cpp.

◆ buildConfigurationDirectoriesList()

LIMA_COMMONTOOLS_EXPORT QStringList Lima::Common::Misc::buildConfigurationDirectoriesList ( const QStringList &  projects = QStringList(),
const QStringList &  paths = QStringList() 
)

Build a list of configuration directories from a list of project names and a list of paths.

  1. Add the paths explicitly given
  2. Add dirs from LIMA_CONF if no project is given
  3. Add dirs from each PROJECT_CONF
  4. Add conf dir in XDG_DATA_HOME or ~/.local/share/ after LIMA_CONF but before /usr
  5. Then add the *_CONF for each given project and complete if necessary with *_DIST/… or /usr/…

In LIMA the projects list will be empty (or just "lima") but projects depending on LIMA will be able to add their own separate configurations.

If the environment variable LIMA_SHOW_CONFIG_PATH is defined and non-empty, then the list built is written on stderr

Parameters
projectsThe list of project names to explore
pathsThe list of paths to look into first.
Returns
The list of directories that will be searched for configuration files

Definition at line 141 of file FileUtils.cpp.

◆ buildDirectoriesListForProject()

void Lima::Common::Misc::buildDirectoriesListForProject ( QStringList &  target,
const QString &  project,
const QString &  env_postfix,
const QString &  path_prefix,
const QString &  path_postfix = QString("") 
)

Definition at line 118 of file FileUtils.cpp.

◆ buildResourcesDirectoriesList()

LIMA_COMMONTOOLS_EXPORT QStringList Lima::Common::Misc::buildResourcesDirectoriesList ( const QStringList &  projects,
const QStringList &  paths = QStringList() 
)

Build a list of resources directories from a list of project names and a list of paths.

For each project name "project", try to add the dir from the environment variable $PROJECT_RESOURCES. If it does not exist, try $PROJECT_DIST/share/apps/project/resources. If it does not exist either, try /usr/share/apps/project/resources. Then add existing paths from the given list. In LIMA the projects list will be limited to the single element "lima" but projects depending on LIMA will be able to add their own separate resources.

Parameters
projectsThe list of project names to explore
pathsThe list of paths to look into.

Definition at line 193 of file FileUtils.cpp.

◆ chomp()

template<typename C >
void Lima::Common::Misc::chomp ( std::basic_string< C > &  str)

Definition at line 165 of file strwstrtools.h.

◆ chop()

template<typename C >
void Lima::Common::Misc::chop ( std::basic_string< C > &  str)

Definition at line 173 of file strwstrtools.h.

◆ convertString()

template<typename charT >
std::string Lima::Common::Misc::convertString ( const std::basic_string< charT > &  input)

Definition at line 185 of file strwstrtools.h.

◆ countLines() [1/2]

LIMA_COMMONTOOLS_EXPORT uint64_t Lima::Common::Misc::countLines ( QFile &  file)

Count the number of lines in the given file from the current position.

If the last line has no character (no character after the last line break)' it is not counted. After this function, the file is at the same position.

Parameters
filethe file to count the lines of
Returns
the number of lines of the file

Definition at line 42 of file FileUtils.cpp.

◆ countLines() [2/2]

LIMA_COMMONTOOLS_EXPORT uint64_t Lima::Common::Misc::countLines ( std::istream &  file)

Count the number of lines in the given file from the current position.

If the last line has no character (no character after the last line break)' it is not counted. After this function, the file is in the same good state and at the same position.

Parameters
filethe file to count the lines of
Returns
the number of lines of the file

Definition at line 23 of file FileUtils.cpp.

◆ findFileInPaths()

LIMA_COMMONTOOLS_EXPORT QString Lima::Common::Misc::findFileInPaths ( const QString &  paths,
const QString &  fileName,
const QChar &  separator = QLatin1Char(LIMA_PATH_SEPARATOR) 
)

Find the given file in the given paths.

Parameters
pathsthe list of concatenated paths to search the file in
fileNamethe name of the file to search into the paths. Can include a relative path. Can be a concatenation of several possible file names. Stop on the first file found in the first path
separatorthe character used to split the list of paths. Defaults to semicolon
Returns
the full path of the found file if found. Empty string otherwise.

Definition at line 220 of file FileUtils.cpp.

◆ getDataHome()

QString Lima::Common::Misc::getDataHome ( )

Definition at line 80 of file FileUtils.cpp.

◆ getEnvVar()

QString Lima::Common::Misc::getEnvVar ( const QString &  name)

Definition at line 75 of file FileUtils.cpp.

◆ latin15stdstring2limastring()

LimaString Lima::Common::Misc::latin15stdstring2limastring ( const std::string &  src)

Convert a latin15 string to a LimaString.

Definition at line 212 of file strwstrtools.cpp.

◆ limastring2utf8stdstring() [1/2]

std::string Lima::Common::Misc::limastring2utf8stdstring ( const Lima::LimaString &  phrase,
uint32_t  size0 
)

Convert a wide string to a string , in dest up to size bytes.

Definition at line 221 of file strwstrtools.cpp.

◆ limastring2utf8stdstring() [2/2]

std::string Lima::Common::Misc::limastring2utf8stdstring ( const Lima::LimaString &  src)

Convert a Lima string to a string.

Definition at line 226 of file strwstrtools.cpp.

◆ localestring2utf8string()

std::string Lima::Common::Misc::localestring2utf8string ( const std::string &  src)

␈rief Convert a string in the locale codepage to a UTF8 string

LIMA own code.

Convert a string in the locale codepage to a UTF8 string

Definition at line 203 of file strwstrtools.cpp.

◆ mypredicate()

bool Lima::Common::Misc::mypredicate ( const std::pair< std::string, float > &  a,
const std::pair< std::string, float > &  b 
)

Definition at line 307 of file genericDocumentProperties.cpp.

◆ operator<<() [1/3]

QDebug & Lima::Common::Misc::operator<< ( QDebug &  os,
const GenericDocumentProperties &  p 
)

Definition at line 653 of file genericDocumentProperties.cpp.

◆ operator<<() [2/3]

QTextStream & Lima::Common::Misc::operator<< ( QTextStream &  os,
const GenericDocumentProperties &  p 
)

Definition at line 658 of file genericDocumentProperties.cpp.

◆ operator<<() [3/3]

std::ostream & Lima::Common::Misc::operator<< ( std::ostream &  os,
const GenericDocumentProperties &  p 
)

Definition at line 648 of file genericDocumentProperties.cpp.

◆ readCodedInt()

LIMA_DATA_EXPORT uint64_t Lima::Common::Misc::readCodedInt ( std::istream &  file)

read a integer coded in variable-byte format in a file

Parameters
filethe file from which to read
Returns
the integer read

Definition at line 25 of file readwritetools.cpp.

◆ readLine()

LIMA_DATA_EXPORT std::string Lima::Common::Misc::readLine ( std::istream &  inputFile)

Definition at line 75 of file strwstrtools.cpp.

◆ readOneByteInt()

LIMA_DATA_EXPORT uint8_t Lima::Common::Misc::readOneByteInt ( std::istream &  file)

read a integer coded on one byte in a file

Parameters
filethe file from which to read
Returns
the integer read

Definition at line 65 of file readwritetools.cpp.

◆ readStream()

void Lima::Common::Misc::readStream ( std::istream &  is,
std::string &  dest 
)

Read an input stream into a string, until EOF.

Definition at line 51 of file strwstrtools.cpp.

◆ readString()

void Lima::Common::Misc::readString ( std::istream &  file,
std::string &  s 
)

Read an input stream into a wide string, until EOF.

read a string in an input file stream

Definition at line 101 of file strwstrtools.cpp.

◆ readStringField()

LIMA_DATA_EXPORT void Lima::Common::Misc::readStringField ( istream &  file,
string &  s 
)

Definition at line 127 of file strwstrtools.cpp.

◆ readUTF8StringField()

LIMA_DATA_EXPORT void Lima::Common::Misc::readUTF8StringField ( std::istream &  file,
Lima::LimaString &  s 
)

Binary read an utf8 string from a file and store it in a LimaString.

Parameters
filethe file from which to read
sthe LimaString read

Definition at line 153 of file strwstrtools.cpp.

◆ setStringReverseEndian() [1/2]

LIMA_DATA_EXPORT LimaString Lima::Common::Misc::setStringReverseEndian ( const short unsigned int *  s,
const uint32_t  count 
)

◆ setStringReverseEndian() [2/2]

LimaString Lima::Common::Misc::setStringReverseEndian ( const unsigned short *  s,
const uint32_t  count 
)

redefine an existing LimaString from UTF-16 changing the endian mode

Definition at line 255 of file strwstrtools.cpp.

◆ setStringSameEndian() [1/2]

LIMA_DATA_EXPORT LimaString Lima::Common::Misc::setStringSameEndian ( const short unsigned int *  s,
const uint32_t  count 
)

◆ setStringSameEndian() [2/2]

LimaString Lima::Common::Misc::setStringSameEndian ( const unsigned short *  s,
const uint32_t  count 
)

redefine an existing LimaString from UTF-16

Definition at line 236 of file strwstrtools.cpp.

◆ transcodeToXmlEntities()

LIMA_DATA_EXPORT LimaString Lima::Common::Misc::transcodeToXmlEntities ( const LimaString &  str)

Definition at line 281 of file strwstrtools.cpp.

◆ utf8stdstring2limastring()

LIMA_DATA_EXPORT LimaString Lima::Common::Misc::utf8stdstring2limastring ( const std::string &  src)

Definition at line 193 of file strwstrtools.cpp.

◆ writeCodedInt()

LIMA_DATA_EXPORT void Lima::Common::Misc::writeCodedInt ( std::ostream &  file,
const uint64_t  number 
)

write a integer coded in variable-byte format in a file

Parameters
filethe file to write in
numberthe integer to write

Definition at line 36 of file readwritetools.cpp.

◆ writeOneByteInt()

LIMA_DATA_EXPORT void Lima::Common::Misc::writeOneByteInt ( std::ostream &  file,
const uint8_t  number 
)

write a integer coded on one byte format in a file

Parameters
filethe file to write in
numberthe integer to write

Definition at line 72 of file readwritetools.cpp.

◆ writeStream()

void Lima::Common::Misc::writeStream ( std::ostream &  os,
const std::string &  src 
)

Write a string to an output stream.

Definition at line 64 of file strwstrtools.cpp.

◆ writeString()

void Lima::Common::Misc::writeString ( ostream &  file,
const string &  s 
)

write a string on an output file stream

Definition at line 114 of file strwstrtools.cpp.

◆ writeStringField()

LIMA_DATA_EXPORT void Lima::Common::Misc::writeStringField ( ostream &  file,
const string &  s 
)

Definition at line 141 of file strwstrtools.cpp.

◆ writeUTF8StringField()

LIMA_DATA_EXPORT void Lima::Common::Misc::writeUTF8StringField ( std::ostream &  file,
const Lima::LimaString &  s 
)

Binary write a a LimaString in a file as an utf8 string.

Parameters
filethe file to write in
sthe wstring to write

Definition at line 171 of file strwstrtools.cpp.