1999-10-02 16:21:10 +00:00
|
|
|
// -*- C++ -*-
|
2002-09-25 10:03:41 +00:00
|
|
|
/**
|
|
|
|
* \file lstrings.h
|
|
|
|
* This file is part of LyX, the document processor.
|
|
|
|
* Licence details can be found in the file COPYING.
|
|
|
|
*
|
2008-11-14 15:58:50 +00:00
|
|
|
* \author Lars Gullik Bjønnes
|
2002-09-25 10:03:41 +00:00
|
|
|
* \author Jean-Marc Lasgouttes
|
|
|
|
*
|
2003-08-23 00:17:00 +00:00
|
|
|
* Full author contact details are available in file CREDITS.
|
2002-09-25 10:03:41 +00:00
|
|
|
*
|
|
|
|
* A collection of string helper functions that works with string.
|
|
|
|
* Some of these would certainly benefit from a rewrite/optimization.
|
|
|
|
*/
|
1999-10-02 16:21:10 +00:00
|
|
|
|
|
|
|
#ifndef LSTRINGS_H
|
|
|
|
#define LSTRINGS_H
|
|
|
|
|
2006-09-13 21:13:49 +00:00
|
|
|
#include "support/docstring.h"
|
2006-08-13 22:54:59 +00:00
|
|
|
|
2002-04-15 12:05:07 +00:00
|
|
|
#include <vector>
|
1999-10-02 16:21:10 +00:00
|
|
|
|
|
|
|
|
2003-06-30 23:56:22 +00:00
|
|
|
namespace lyx {
|
|
|
|
namespace support {
|
|
|
|
|
2007-02-26 09:03:21 +00:00
|
|
|
/// Compare \p s and \p s2, ignoring the case.
|
|
|
|
/// Does not depend on the locale.
|
2006-10-21 00:16:43 +00:00
|
|
|
int compare_no_case(docstring const & s, docstring const & s2);
|
1999-11-26 06:57:35 +00:00
|
|
|
|
2014-05-19 20:37:14 +00:00
|
|
|
/// Compare \p s and \p s2 using the collating rules of the current locale.
|
|
|
|
int compare_locale(docstring const & s, docstring const & s2);
|
|
|
|
|
2007-02-26 09:03:21 +00:00
|
|
|
/// Compare \p s and \p s2, ignoring the case of ASCII characters only.
|
2003-10-06 15:43:21 +00:00
|
|
|
int compare_ascii_no_case(std::string const & s, std::string const & s2);
|
2001-06-25 00:06:33 +00:00
|
|
|
|
2007-02-26 09:03:21 +00:00
|
|
|
/// Compare \p s and \p s2, ignoring the case of ASCII characters only.
|
2006-10-11 19:40:50 +00:00
|
|
|
int compare_ascii_no_case(docstring const & s, docstring const & s2);
|
|
|
|
|
1999-10-02 16:21:10 +00:00
|
|
|
///
|
2003-10-06 15:43:21 +00:00
|
|
|
bool isStrInt(std::string const & str);
|
1999-10-02 16:21:10 +00:00
|
|
|
|
2003-10-06 15:43:21 +00:00
|
|
|
/// does the std::string represent an unsigned integer value ?
|
|
|
|
bool isStrUnsignedInt(std::string const & str);
|
2000-12-04 17:18:01 +00:00
|
|
|
|
2000-06-12 11:27:15 +00:00
|
|
|
///
|
2003-10-06 15:43:21 +00:00
|
|
|
bool isStrDbl(std::string const & str);
|
2000-06-12 11:27:15 +00:00
|
|
|
|
2010-02-09 17:35:35 +00:00
|
|
|
/// does the string contain a digit?
|
2010-12-07 00:13:19 +00:00
|
|
|
bool hasDigitASCII(docstring const & str);
|
2010-02-09 17:35:35 +00:00
|
|
|
|
2010-12-07 22:53:07 +00:00
|
|
|
bool isHexChar(char_type);
|
|
|
|
|
2007-11-10 13:44:50 +00:00
|
|
|
bool isHex(docstring const & str);
|
2006-10-22 18:47:19 +00:00
|
|
|
|
2007-11-10 13:44:50 +00:00
|
|
|
int hexToInt(docstring const & str);
|
2006-10-22 18:47:19 +00:00
|
|
|
|
2006-11-11 12:00:34 +00:00
|
|
|
/// is \p str pure ascii?
|
|
|
|
bool isAscii(docstring const & str);
|
|
|
|
|
2007-07-06 14:43:18 +00:00
|
|
|
/// is \p str pure ascii?
|
|
|
|
bool isAscii(std::string const & str);
|
|
|
|
|
2007-03-02 16:52:49 +00:00
|
|
|
/**
|
|
|
|
* Changes the case of \p c to lowercase.
|
|
|
|
* Don't use this for non-ASCII characters, since it depends on the locale.
|
|
|
|
* This overloaded function is only implemented because the char_type variant
|
|
|
|
* would be used otherwise, and we assert in this function that \p c is in
|
|
|
|
* the ASCII range.
|
|
|
|
*/
|
2000-07-24 13:53:19 +00:00
|
|
|
char lowercase(char c);
|
|
|
|
|
2007-03-02 16:52:49 +00:00
|
|
|
/**
|
|
|
|
* Changes the case of \p c to uppercase.
|
|
|
|
* Don't use this for non-ASCII characters, since it depends on the locale.
|
|
|
|
* This overloaded function is only implemented because the char_type variant
|
|
|
|
* would be used otherwise, and we assert in this function that \p c is in
|
|
|
|
* the ASCII range.
|
|
|
|
*/
|
2000-07-24 13:53:19 +00:00
|
|
|
char uppercase(char c);
|
|
|
|
|
2007-02-26 09:03:21 +00:00
|
|
|
/// Changes the case of \p c to lowercase.
|
|
|
|
/// Does not depend on the locale.
|
2006-09-03 14:09:24 +00:00
|
|
|
char_type lowercase(char_type c);
|
|
|
|
|
2007-02-26 09:03:21 +00:00
|
|
|
/// Changes the case of \p c to uppercase.
|
|
|
|
/// Does not depend on the locale.
|
2006-09-03 14:09:24 +00:00
|
|
|
char_type uppercase(char_type c);
|
|
|
|
|
2010-10-14 11:01:15 +00:00
|
|
|
/// Checks if the supplied character is lower-case
|
|
|
|
bool isLowerCase(char_type ch);
|
|
|
|
|
|
|
|
/// Checks if the supplied character is upper-case
|
|
|
|
bool isUpperCase(char_type ch);
|
|
|
|
|
2002-07-16 21:17:10 +00:00
|
|
|
/// same as lowercase(), but ignores locale
|
2003-10-06 15:43:21 +00:00
|
|
|
std::string const ascii_lowercase(std::string const &);
|
2006-12-15 16:09:05 +00:00
|
|
|
docstring const ascii_lowercase(docstring const &);
|
2002-07-16 21:17:10 +00:00
|
|
|
|
2007-02-26 09:03:21 +00:00
|
|
|
/// Changes the case of \p s to lowercase.
|
|
|
|
/// Does not depend on the locale.
|
|
|
|
docstring const lowercase(docstring const & s);
|
2014-02-23 17:04:56 +00:00
|
|
|
// Currently unused, but the code is there if needed.
|
|
|
|
// std::string const lowercase(std::string const & s);
|
2007-02-26 09:03:21 +00:00
|
|
|
|
|
|
|
/// Changes the case of \p s to uppercase.
|
2007-02-26 18:54:03 +00:00
|
|
|
/// Does not depend on the locale.
|
|
|
|
docstring const uppercase(docstring const & s);
|
1999-12-15 06:12:28 +00:00
|
|
|
|
2010-11-21 17:00:12 +00:00
|
|
|
/// Returns the superscript of \p c or \p c if no superscript exists.
|
|
|
|
/// Does not depend on the locale.
|
|
|
|
char_type superscript(char_type c);
|
|
|
|
|
|
|
|
/// Returns the subscript of \p c or \p c if no subscript exists.
|
|
|
|
/// Does not depend on the locale.
|
|
|
|
char_type subscript(char_type c);
|
|
|
|
|
2008-03-01 16:27:56 +00:00
|
|
|
/// Does str start with c?
|
|
|
|
bool prefixIs(docstring const & str, char_type c);
|
2007-01-05 17:11:32 +00:00
|
|
|
|
2008-03-01 16:27:56 +00:00
|
|
|
/// Does str start with pre?
|
|
|
|
bool prefixIs(std::string const & str, std::string const & pre);
|
|
|
|
bool prefixIs(docstring const & str, docstring const & pre);
|
2000-09-26 13:54:57 +00:00
|
|
|
|
1999-10-02 16:21:10 +00:00
|
|
|
/// Does the string end with this char?
|
2003-10-06 15:43:21 +00:00
|
|
|
bool suffixIs(std::string const &, char);
|
2007-01-05 17:11:32 +00:00
|
|
|
bool suffixIs(docstring const &, char_type);
|
1999-10-02 16:21:10 +00:00
|
|
|
|
2008-07-16 15:29:00 +00:00
|
|
|
/// Does the string end with this suffix?
|
2003-10-06 15:43:21 +00:00
|
|
|
bool suffixIs(std::string const &, std::string const &);
|
2008-07-16 15:29:00 +00:00
|
|
|
bool suffixIs(docstring const &, docstring const &);
|
2000-09-26 13:54:57 +00:00
|
|
|
|
2009-01-13 00:55:12 +00:00
|
|
|
/// Is b contained in a?
|
2006-10-22 10:15:23 +00:00
|
|
|
inline bool contains(std::string const & a, std::string const & b)
|
2004-01-31 15:30:24 +00:00
|
|
|
{
|
2004-02-01 12:46:14 +00:00
|
|
|
return a.find(b) != std::string::npos;
|
|
|
|
}
|
2002-02-16 15:59:55 +00:00
|
|
|
|
2006-10-22 10:15:23 +00:00
|
|
|
inline bool contains(docstring const & a, docstring const & b)
|
|
|
|
{
|
|
|
|
return a.find(b) != docstring::npos;
|
|
|
|
}
|
|
|
|
|
|
|
|
inline bool contains(std::string const & a, char b)
|
|
|
|
{
|
|
|
|
return a.find(b) != std::string::npos;
|
|
|
|
}
|
|
|
|
|
|
|
|
inline bool contains(docstring const & a, char_type b)
|
2006-09-02 10:18:20 +00:00
|
|
|
{
|
2006-10-21 00:16:43 +00:00
|
|
|
return a.find(b) != docstring::npos;
|
2006-09-02 10:18:20 +00:00
|
|
|
}
|
|
|
|
|
2016-09-25 10:37:40 +00:00
|
|
|
/// Returns true if the first argument is made of ascii chars given in the
|
|
|
|
/// second argument.
|
2003-10-06 15:43:21 +00:00
|
|
|
bool containsOnly(std::string const &, std::string const &);
|
2016-09-25 10:37:40 +00:00
|
|
|
///
|
|
|
|
bool containsOnly(docstring const &, std::string const &);
|
2000-06-12 11:27:15 +00:00
|
|
|
|
1999-10-02 16:21:10 +00:00
|
|
|
/** Extracts a token from this string at the nth delim.
|
2001-02-16 09:25:43 +00:00
|
|
|
Doesn't modify the original string. Similar to strtok.
|
|
|
|
Example:
|
|
|
|
\code
|
2002-07-21 15:51:07 +00:00
|
|
|
token("a;bc;d", ';', 1) == "bc";
|
|
|
|
token("a;bc;d", ';', 2) == "d";
|
2001-02-16 09:25:43 +00:00
|
|
|
\endcode
|
1999-10-02 16:21:10 +00:00
|
|
|
*/
|
2003-10-06 15:43:21 +00:00
|
|
|
std::string const token(std::string const & a, char delim, int n);
|
1999-10-02 16:21:10 +00:00
|
|
|
|
2006-10-21 00:16:43 +00:00
|
|
|
docstring const token(docstring const & a, char_type delim, int n);
|
1999-10-02 16:21:10 +00:00
|
|
|
|
|
|
|
/** Search a token in this string using the delim.
|
2001-02-16 09:25:43 +00:00
|
|
|
Doesn't modify the original string. Returns -1 in case of
|
2002-03-21 17:09:55 +00:00
|
|
|
failure.
|
2001-02-16 09:25:43 +00:00
|
|
|
Example:
|
|
|
|
\code
|
2002-07-21 15:51:07 +00:00
|
|
|
tokenPos("a;bc;d", ';', "bc") == 1;
|
|
|
|
tokenPos("a;bc;d", ';', "d") == 2;
|
2001-02-16 09:25:43 +00:00
|
|
|
\endcode
|
1999-10-02 16:21:10 +00:00
|
|
|
*/
|
2003-10-06 15:43:21 +00:00
|
|
|
int tokenPos(std::string const & a, char delim, std::string const & tok);
|
2008-04-19 15:52:35 +00:00
|
|
|
int tokenPos(docstring const & a, char_type delim, docstring const & tok);
|
1999-10-02 16:21:10 +00:00
|
|
|
|
|
|
|
|
2001-02-16 09:25:43 +00:00
|
|
|
/// Substitute all \a oldchar with \a newchar
|
2003-10-06 15:43:21 +00:00
|
|
|
std::string const subst(std::string const & a, char oldchar, char newchar);
|
1999-10-02 16:21:10 +00:00
|
|
|
|
2006-09-03 07:02:38 +00:00
|
|
|
/// Substitute all \a oldchar with \a newchar
|
2006-10-21 00:16:43 +00:00
|
|
|
docstring const subst(docstring const & a, char_type oldchar, char_type newchar);
|
2006-09-03 07:02:38 +00:00
|
|
|
|
2001-02-16 09:25:43 +00:00
|
|
|
/// substitutes all instances of \a oldstr with \a newstr
|
2003-10-06 15:43:21 +00:00
|
|
|
std::string const subst(std::string const & a,
|
|
|
|
std::string const & oldstr, std::string const & newstr);
|
2000-09-26 13:54:57 +00:00
|
|
|
|
2006-09-03 07:02:38 +00:00
|
|
|
/// substitutes all instances of \a oldstr with \a newstr
|
2006-10-21 00:16:43 +00:00
|
|
|
docstring const subst(docstring const & a,
|
|
|
|
docstring const & oldstr, docstring const & newstr);
|
2006-09-03 07:02:38 +00:00
|
|
|
|
2017-09-22 07:29:16 +00:00
|
|
|
/// Count all occurrences of char \a chr inside \a str
|
2013-04-12 20:31:48 +00:00
|
|
|
int count_char(std::string const & str, char chr);
|
|
|
|
|
2017-09-22 07:29:16 +00:00
|
|
|
/// Count all occurrences of char \a chr inside \a str
|
2010-04-16 23:47:39 +00:00
|
|
|
int count_char(docstring const & str, docstring::value_type chr);
|
|
|
|
|
2017-09-22 07:29:16 +00:00
|
|
|
/** Count all occurrences of binary chars inside \a str.
|
2014-06-05 15:33:25 +00:00
|
|
|
It is assumed that \a str is utf-8 encoded and that a binary char
|
|
|
|
belongs to the unicode class names Zl, Zp, Cc, Cf, Cs, Co, or Cn
|
|
|
|
(excluding white space characters such as '\t', '\n', '\v', '\f', '\r').
|
|
|
|
See http://www.unicode.org/Public/6.2.0/ucd/UnicodeData.txt
|
|
|
|
*/
|
|
|
|
int count_bin_chars(std::string const & str);
|
|
|
|
|
2006-10-09 09:15:37 +00:00
|
|
|
/** Trims characters off the end and beginning of a string.
|
|
|
|
\code
|
|
|
|
trim("ccabccc", "c") == "ab".
|
|
|
|
\endcode
|
|
|
|
*/
|
2006-10-21 00:16:43 +00:00
|
|
|
docstring const trim(docstring const & a, char const * p = " ");
|
2006-10-09 09:15:37 +00:00
|
|
|
|
2002-07-28 22:50:13 +00:00
|
|
|
/** Trims characters off the end and beginning of a string.
|
2001-02-16 09:25:43 +00:00
|
|
|
\code
|
2002-07-28 22:50:13 +00:00
|
|
|
trim("ccabccc", "c") == "ab".
|
2001-02-16 09:25:43 +00:00
|
|
|
\endcode
|
|
|
|
*/
|
2003-10-06 15:43:21 +00:00
|
|
|
std::string const trim(std::string const & a, char const * p = " ");
|
1999-10-02 16:21:10 +00:00
|
|
|
|
2008-07-16 14:49:36 +00:00
|
|
|
/** Trims characters off the end of a string, removing any character
|
|
|
|
in p.
|
2001-02-16 09:25:43 +00:00
|
|
|
\code
|
2008-07-16 14:49:36 +00:00
|
|
|
rtrim("abcde", "dec") == "ab".
|
2001-02-16 09:25:43 +00:00
|
|
|
\endcode
|
|
|
|
*/
|
2003-10-06 15:43:21 +00:00
|
|
|
std::string const rtrim(std::string const & a, char const * p = " ");
|
2006-10-22 10:15:23 +00:00
|
|
|
docstring const rtrim(docstring const & a, char const * p = " ");
|
2002-07-28 22:50:13 +00:00
|
|
|
|
|
|
|
/** Trims characters off the beginning of a string.
|
|
|
|
\code
|
2008-07-16 14:49:36 +00:00
|
|
|
("abbabcdef", "ab") = "cdef"
|
2002-07-28 22:50:13 +00:00
|
|
|
\endcode
|
|
|
|
*/
|
2003-10-06 15:43:21 +00:00
|
|
|
std::string const ltrim(std::string const & a, char const * p = " ");
|
2006-10-22 10:15:23 +00:00
|
|
|
docstring const ltrim(docstring const & a, char const * p = " ");
|
1999-10-02 16:21:10 +00:00
|
|
|
|
2017-07-03 17:45:58 +00:00
|
|
|
/** Splits the string given in the first argument at the first occurence
|
2010-02-15 07:39:39 +00:00
|
|
|
of the third argument, delim.
|
2007-09-08 15:15:31 +00:00
|
|
|
What precedes delim is returned in the second argument, piece; this
|
|
|
|
will be the whole of the string if no delimiter is found.
|
|
|
|
The return value is what follows delim, if anything. So the return
|
|
|
|
value is the null string if no delimiter is found.
|
2012-07-15 21:25:34 +00:00
|
|
|
'a' and 'piece' must be different variables.
|
2007-09-08 15:15:31 +00:00
|
|
|
Examples:
|
2001-02-16 09:25:43 +00:00
|
|
|
\code
|
2007-09-08 15:15:31 +00:00
|
|
|
s1= "a;bc"; s2= ""
|
|
|
|
ret = split(s1, s2, ';') -> ret = "bc", s2 == "a"
|
2001-02-16 09:25:43 +00:00
|
|
|
\endcode
|
2007-09-08 15:15:31 +00:00
|
|
|
*/
|
2003-10-06 15:43:21 +00:00
|
|
|
std::string const split(std::string const & a, std::string & piece, char delim);
|
2006-10-11 18:32:32 +00:00
|
|
|
docstring const split(docstring const & a, docstring & piece, char_type delim);
|
1999-10-02 16:21:10 +00:00
|
|
|
|
|
|
|
/// Same as split but does not return a piece
|
2003-10-06 15:43:21 +00:00
|
|
|
std::string const split(std::string const & a, char delim);
|
1999-10-02 16:21:10 +00:00
|
|
|
|
|
|
|
/// Same as split but uses the last delim.
|
2003-10-06 15:43:21 +00:00
|
|
|
std::string const rsplit(std::string const & a, std::string & piece, char delim);
|
2012-11-23 17:26:02 +00:00
|
|
|
docstring const rsplit(docstring const & a, docstring & piece, char_type delim);
|
2009-07-25 10:44:36 +00:00
|
|
|
docstring const rsplit(docstring const & a, char_type delim);
|
1999-10-02 16:21:10 +00:00
|
|
|
|
2006-11-12 13:42:20 +00:00
|
|
|
/// Escapes non ASCII chars and other problematic characters that cause
|
|
|
|
/// problems in latex labels.
|
2006-10-21 00:16:43 +00:00
|
|
|
docstring const escape(docstring const & lab);
|
2001-06-27 14:10:35 +00:00
|
|
|
|
2017-01-29 11:08:29 +00:00
|
|
|
/// Group contents of an argument if needed
|
|
|
|
docstring const protectArgument(docstring & arg, char const l = '[',
|
|
|
|
char const r = ']');
|
|
|
|
|
2015-10-04 18:38:47 +00:00
|
|
|
/// Truncates a string with an ellipsis at the end. Leaves str unchanged and
|
|
|
|
/// returns false if it is shorter than len. Otherwise resizes str to len, with
|
|
|
|
/// U+2026 HORIZONTAL ELLIPSIS at the end, and returns true.
|
|
|
|
///
|
|
|
|
/// Warning (Unicode): The cases where we want to truncate the text and it does
|
|
|
|
/// not end up converted into a QString for UI display must be really
|
|
|
|
/// rare. Whenever possible, we should prefer calling QFontMetrics::elidedText()
|
|
|
|
/// instead, which takes into account the actual length on the screen and the
|
|
|
|
/// layout direction (RTL or LTR). Or a similar function taking into account the
|
|
|
|
/// font metrics from the buffer view, which still has to be defined. Or set up
|
|
|
|
/// the widgets such that Qt elides the string automatically with the exact
|
|
|
|
/// needed width. Recall that not only graphemes vary greatly in width, but also
|
|
|
|
/// can be made of several code points. See:
|
|
|
|
/// <http://utf8everywhere.org/#myth.strlen>
|
|
|
|
///
|
|
|
|
/// What is acceptable is when we know that the string is probably going to be
|
|
|
|
/// elided by Qt anyway, and len is chosen such that our own ellipsis will only
|
|
|
|
/// be displayed in worst-case scenarios.
|
|
|
|
///
|
|
|
|
/// FIXME: apply those principles in the current code.
|
2017-07-03 17:45:58 +00:00
|
|
|
///
|
2015-10-04 18:38:47 +00:00
|
|
|
bool truncateWithEllipsis(docstring & str, size_t const len);
|
|
|
|
|
2009-05-07 12:23:12 +00:00
|
|
|
/// Word-wraps the provided docstring, returning a line-broken string
|
2017-07-03 17:45:58 +00:00
|
|
|
/// of width no wider than width, with the string broken at spaces.
|
|
|
|
/// If the string cannot be broken appropriately, it returns something
|
2009-05-07 12:23:12 +00:00
|
|
|
/// with "..." at the end, again no wider than width.
|
|
|
|
/// We assume here that str does not contain newlines.
|
2017-07-03 17:45:58 +00:00
|
|
|
/// If indent is positive, then the first line is indented that many
|
2009-05-07 12:23:12 +00:00
|
|
|
/// spaces. If it is negative, then successive lines are indented, as
|
|
|
|
/// if the first line were "outdented".
|
2015-10-04 18:38:47 +00:00
|
|
|
///
|
|
|
|
/// Warning (Unicode): uses truncateWithEllipsis() internally. Therefore it is
|
|
|
|
/// subject to the same warning and FIXME as above.
|
|
|
|
///
|
2009-05-07 12:23:12 +00:00
|
|
|
docstring wrap(docstring const & str, int const indent = 0,
|
|
|
|
size_t const width = 80);
|
|
|
|
|
2009-05-07 18:04:05 +00:00
|
|
|
/// Like the preceding, except it is intended to operate on strings
|
|
|
|
/// that may contain embedded newlines.
|
|
|
|
/// \param numlines Don't return more than numlines lines. If numlines
|
|
|
|
/// is 0, we return everything.
|
2015-10-04 18:38:47 +00:00
|
|
|
///
|
|
|
|
/// Warning (Unicode): uses truncateWithEllipsis() internally. Therefore it is
|
|
|
|
/// subject to the same warning and FIXME as above.
|
|
|
|
///
|
2009-05-07 18:04:05 +00:00
|
|
|
docstring wrapParas(docstring const & str, int const indent = 0,
|
2009-05-07 20:44:07 +00:00
|
|
|
size_t const width = 80, size_t const maxlines = 10);
|
2009-05-07 18:04:05 +00:00
|
|
|
|
2002-04-15 12:05:07 +00:00
|
|
|
/// gives a vector of stringparts which have the delimiter delim
|
2008-07-14 16:09:59 +00:00
|
|
|
/// If \p keepempty is true, empty strings will be pushed to the vector as well
|
2017-10-18 16:26:35 +00:00
|
|
|
/// If \p trimit is true, leading and trailing whitespace will be trimmed from
|
|
|
|
/// all values. Note that this can affect what counts as "empty".
|
2018-03-22 03:08:12 +00:00
|
|
|
/// NOTE: If you want to split a string on whitespace, then do:
|
|
|
|
/// getVectorFromString(str, " ", false, true);
|
2003-10-06 15:43:21 +00:00
|
|
|
std::vector<std::string> const getVectorFromString(std::string const & str,
|
2017-10-18 16:26:35 +00:00
|
|
|
std::string const & delim = std::string(","),
|
|
|
|
bool keepempty = false, bool trimit = true);
|
2006-12-17 10:52:04 +00:00
|
|
|
std::vector<docstring> const getVectorFromString(docstring const & str,
|
2017-10-18 16:26:35 +00:00
|
|
|
docstring const & delim = from_ascii(","),
|
|
|
|
bool keepempty = false, bool trimit = true);
|
2002-04-15 12:05:07 +00:00
|
|
|
|
2009-05-07 18:04:05 +00:00
|
|
|
/// the same vice versa
|
2003-10-06 15:43:21 +00:00
|
|
|
std::string const getStringFromVector(std::vector<std::string> const & vec,
|
|
|
|
std::string const & delim = std::string(","));
|
2009-05-07 18:04:05 +00:00
|
|
|
docstring const getStringFromVector(std::vector<docstring> const & vec,
|
|
|
|
docstring const & delim = from_ascii(","));
|
2002-04-15 12:05:07 +00:00
|
|
|
|
2006-04-20 09:55:45 +00:00
|
|
|
/// Search \p search_token in \p str and return the position if it is
|
|
|
|
/// found, else -1. The last item in \p str must be "".
|
|
|
|
int findToken(char const * const str[], std::string const & search_token);
|
|
|
|
|
2015-05-14 10:10:42 +00:00
|
|
|
|
|
|
|
/// Format a floating point number with at least 6 siginificant digits, but
|
|
|
|
/// without scientific notation.
|
|
|
|
/// Scientific notation would be invalid in some contexts, such as lengths for
|
|
|
|
/// LaTeX. Simply using std::ostream with std::fixed would produce results
|
|
|
|
/// like "1000000.000000", and precision control would not be that easy either.
|
|
|
|
std::string formatFPNumber(double);
|
|
|
|
|
|
|
|
|
2016-11-23 23:30:13 +00:00
|
|
|
docstring bformat(docstring const & fmt, int arg1);
|
|
|
|
docstring bformat(docstring const & fmt, long arg1);
|
2016-05-05 11:05:12 +00:00
|
|
|
#ifdef LYX_USE_LONG_LONG
|
2016-11-23 23:30:13 +00:00
|
|
|
docstring bformat(docstring const & fmt, long long arg1);
|
2016-05-05 11:05:12 +00:00
|
|
|
#endif
|
2016-11-23 23:30:13 +00:00
|
|
|
docstring bformat(docstring const & fmt, unsigned int arg1);
|
|
|
|
docstring bformat(docstring const & fmt, docstring const & arg1);
|
|
|
|
docstring bformat(docstring const & fmt, char * arg1);
|
|
|
|
docstring bformat(docstring const & fmt, docstring const & arg1, docstring const & arg2);
|
|
|
|
docstring bformat(docstring const & fmt, docstring const & arg1, int arg2);
|
|
|
|
docstring bformat(docstring const & fmt, char const * arg1, docstring const & arg2);
|
|
|
|
docstring bformat(docstring const & fmt, int arg1, int arg2);
|
|
|
|
docstring bformat(docstring const & fmt, docstring const & arg1, docstring const & arg2, docstring const & arg3);
|
|
|
|
docstring bformat(docstring const & fmt, docstring const & arg1, docstring const & arg2, docstring const & arg3, docstring const & arg4);
|
2007-12-01 10:24:48 +00:00
|
|
|
|
|
|
|
|
2003-06-30 23:56:22 +00:00
|
|
|
} // namespace support
|
|
|
|
} // namespace lyx
|
|
|
|
|
1999-10-02 16:21:10 +00:00
|
|
|
#endif
|