yast2-core
|
#include <unistd.h>
#include <ctype.h>
#include <stdio.h>
#include <regex.h>
#include <libintl.h>
#include <string>
#include <boost/algorithm/string.hpp>
#include "ycp/YCPBuiltinString.h"
#include "ycp/YCPString.h"
#include "ycp/YCPInteger.h"
#include "ycp/YCPPath.h"
#include "ycp/YCPSymbol.h"
#include "ycp/YCPBoolean.h"
#include "ycp/YCPVoid.h"
#include "ycp/y2log.h"
#include "y2string.h"
#include "y2crypt.h"
#include "ycp/StaticDeclaration.h"
Classes | |
struct | REG_RET |
(regexp builtins) More... | |
Macros | |
#define | _GNU_SOURCE |
#define | ERR_MAX 80 |
#define | SUB_MAX 10 |
#define | ETC 0, NULL, constTypePtr(), NULL |
#define | ETCf NULL, constTypePtr(), NULL |
Typedefs | |
typedef struct REG_RET | Reg_Ret |
(regexp builtins) More... | |
Variables | |
StaticDeclaration | static_declarations |
#define _GNU_SOURCE |
#define ERR_MAX 80 |
Referenced by solve_regular_expression().
#define ETC 0, NULL, constTypePtr(), NULL |
Referenced by YCPBuiltinString::YCPBuiltinString().
#define ETCf NULL, constTypePtr(), NULL |
Referenced by YCPBuiltinString::YCPBuiltinString().
#define SUB_MAX 10 |
Referenced by solve_regular_expression().
crypt Encrypts a string Encrypts the string UNENCRYPTED
using the standard password encryption provided by the system.
string | UNENCRYPTED |
crypt ("readable") -> "Y2PEyAiaeaFy6"
References YaST::CRYPT, YaST::crypt_pass(), YCPElement::isNull(), and ycp2error.
Referenced by YCPBuiltinString::YCPBuiltinString().
cryptblowfish Encrypts a string with blowfish Encrypts the string UNENCRYPTED
using blowfish password encryption. The password is not truncated.
string | UNENCRYPTED |
References YaST::BLOWFISH, YaST::crypt_pass(), YCPElement::isNull(), and ycp2error.
Referenced by YCPBuiltinString::YCPBuiltinString().
cryptmd5 Encrypts a string using md5 Encrypts the string UNENCRYPTED
using MD5 password encryption.
string | UNENCRYPTED |
cryptmd5 ("readable") -> "$1$BBtzrzzz$zc2vEB7XnA3Iq7pOgDsxD0"
References YaST::crypt_pass(), YCPElement::isNull(), YaST::MD5, and ycp2error.
Referenced by YCPBuiltinString::YCPBuiltinString().
cryptsha256 Encrypts a string with sha256 Encrypts the string UNENCRYPTED
using sha256 password encryption. The password is not truncated.
string | UNENCRYPTED |
References YaST::crypt_pass(), YCPElement::isNull(), YaST::SHA256, and ycp2error.
Referenced by YCPBuiltinString::YCPBuiltinString().
cryptsha512 Encrypts a string with sha512 Encrypts the string UNENCRYPTED
using sha512 password encryption. The password is not truncated.
string | UNENCRYPTED |
References YaST::crypt_pass(), YCPElement::isNull(), YaST::SHA512, and ycp2error.
Referenced by YCPBuiltinString::YCPBuiltinString().
_(string text) -> string Translates the text using the current textdomain.
Example
_("File") -> "Soubor"
dgettext Translates the text using the given text domain Translates the text using the given text domain into the current language.
This is a special case builtin not intended for general use. See _() instead.
string | textdomain |
string | text |
References YLocale::ensureBindDomain(), and YCPElement::isNull().
Referenced by YCPBuiltinString::YCPBuiltinString().
|
static |
_(string singular, string plural, integer value) -> string Translates the text using a locale-aware plural form handling and the current textdomain. The chosen form of the translation depends on the value
.
Example
_("%1 File", "%1 Files", 2) -> "%1 soubory"
dngettext Translates the text using a locale-aware plural form handling Translates the text using a locale-aware plural form handling using the given textdomain.
The chosen form of the translation depend on the value
.
This is a special case builtin not intended for general use. See _() instead.
string | textdomain |
string | singular |
string | plural |
integer | value |
dngettext ("base", "%1 File", "%1 Files", 2) -> "%1 soubory"
References YLocale::ensureBindDomain(), and YCPElement::isNull().
Referenced by YCPBuiltinString::YCPBuiltinString().
|
static |
dpgettext Translates the text using the given text domain and path Translates the text using the given text domain into the current language and path of localization . Path of localization is same than dirname in function bindtextdomain()
This is a special case builtin not intended for general use. See _() instead.
string | textdomain |
string | dirname |
string | text |
References YLocale::bindDomainDir(), YLocale::findDomain(), YCPElement::isNull(), and result().
Referenced by YCPBuiltinString::YCPBuiltinString().
filterchars Filters characters out of a String
string | STRING |
string | CHARS chars to be included |
Returns a string that results from string STRING
by removing all characters that do not occur in CHARS
.
References YCPElement::isNull().
Referenced by YCPBuiltinString::YCPBuiltinString().
find find-string Returns position of a substring
string | STRING1 String |
string | STRING2 Substring |
The find
function searches string for the first occurency of a specified substring (possibly a single character) and returns its starting position.
Returns the first position in STRING1
where the string STRING2
is contained in STRING1
. OFFSET
starts with 0.
References YCPElement::isNull(), and s_search().
Referenced by YCPBuiltinString::YCPBuiltinString().
findfirstnotof Searches string for the first non matching chars
string | STRING |
string | CHARS |
The findfirstnotof
function searches the first element of string that doesn't match any character stored in chars and returns its position.
STRING
that is not contained in CHARS
.References YCPElement::isNull().
Referenced by YCPBuiltinString::YCPBuiltinString().
findfirstof Finds position of the first matching characters in string
string | STRING |
string | CHARS Characters to find |
The findfirstof
function searches string for the first match of any character stored in chars and returns its position.
If no match is found findfirstof returns `nil'.
STRING
that is contained in CHARS
.References YCPElement::isNull().
Referenced by YCPBuiltinString::YCPBuiltinString().
findlastnotof Searches the last element of string that doesn't match
string | STRING |
string | CHARS Characters The `findlastnotof' function searches the last element of string that doesn't match any character stored in chars and returns its position. |
If no match is found the function returns `nil'.
STRING
that is NOT contained in CHARS
.References YCPElement::isNull().
Referenced by YCPBuiltinString::YCPBuiltinString().
findlastof Searches string for the last match The `findlastof' function searches string for the last match of any character stored in chars and returns its position.
string | STRING String |
string | CHARS Characters to find |
STRING
that is contained in CHARS
.References YCPElement::isNull().
Referenced by YCPBuiltinString::YCPBuiltinString().
isempty isempty-string Returns whether the string s
is empty.
string | s String |
s
Notice that the string s
must not be nil.
isempty("") -> true isempty("test") -> false
References YCPString::isEmpty().
Referenced by YCPBuiltinString::YCPBuiltinString().
issubstring searches for a specific string within another string
string | s String to be searched |
string | substring Pattern to be searched for |
substring
is a substring of s
.issubstring ("some text", "tex") -> true
References YCPElement::isNull().
Referenced by YCPBuiltinString::YCPBuiltinString().
mergestring Joins list elements with a string
list<string> | PIECES A List of strings |
string | GLUE |
Returns a string containing a string representation of all the list elements in the same order, with the glue string between each element.
List elements which are not of type strings are ignored.
mergestring (["", "abc", "dev", "ghi"], "/") -> "/abc/dev/ghi" mergestring (["abc", "dev", "ghi", ""], "/") -> "abc/dev/ghi/" mergestring ([1, "a", 3], ".") -> "a" mergestring ([], ".") -> "" mergestring (["abc", "dev", "ghi"], "") -> "abcdevghi" mergestring (["abc", "dev", "ghi"], "123") -> "abc123dev123ghi"
References YCPList::isEmpty(), YCPElement::isNull(), YCPList::size(), YCPList::value(), and ycp2error.
Referenced by YCPBuiltinString::YCPBuiltinString().
string s1 + string s2 -> string Returns concatenation of s1
and s2
.
Example:
"YaST" + "2" -> "YaST2"
References YCPElement::isNull().
Referenced by YCPBuiltinString::YCPBuiltinString().
|
static |
string s1 + integer i2 -> string String and integer Concatenation
Returns concatenation of s1
and i2
after transforming i2
to a string.
Example:
"YaST" + 2 -> "YaST2"
References YCPElement::isNull(), and toString().
Referenced by YCPBuiltinString::YCPBuiltinString().
string s1 + path p2 -> string String and path Concatenation Returns concatenation of s1
and p2
after transforming p2
to a string.
Example: "YaST" + .two -> "YaST.two"
References YCPElement::isNull().
Referenced by YCPBuiltinString::YCPBuiltinString().
string s1 + symbol s2 -> string String and symbol Concatenation
Returns concatenation of s1
and s2
after transforming s2
to a string AND stripping the leading backquote.
Example: "YaST" + `two -> "YaSTtwo"
References YCPElement::isNull().
Referenced by YCPBuiltinString::YCPBuiltinString().
regexpmatch
Searches a string for a POSIX Extended Regular Expression match.
string | INPUT |
string | PATTERN |
regexpmatch ("aaabbbccc", "ab") -> true regexpmatch ("aaabbbccc", "^ab") -> false regexpmatch ("aaabbbccc", "ab+c") -> true regexpmatch ("aaa(bbb)ccc", "\\(.*\\)") -> true
References REG_RET::error, REG_RET::error_str, YCPElement::isNull(), result(), solve_regular_expression(), REG_RET::solved, and ycp2error.
Referenced by YCPBuiltinString::YCPBuiltinString().
regexppos Returns a pair with position and length of the first match.
string | INPUT |
string | PATTERN |
If no match is found it returns an empty list.
regexppos ("abcd012efgh345", "[0-9]+") -> [4, 3] ("aaabbb", "[0-9]+") -> []
References YCPList::add(), REG_RET::error, REG_RET::error_str, YCPElement::isNull(), REG_RET::match_str, result(), solve_regular_expression(), REG_RET::solved, and ycp2error.
Referenced by YCPBuiltinString::YCPBuiltinString().
|
static |
regexpsub Regex Substitution
string | INPUT |
string | PATTERN |
string | OUTPUT |
Searches a string for a POSIX Extended Regular Expression match and returns OUTPUT with the matched subexpressions substituted or nil if no match was found.
regexpsub ("aaabbb", "(.*ab)", "s_\\1_e") -> "s_aaab_e" regexpsub ("aaabbb", "(.*ba)", "s_\\1_e") -> nil
References REG_RET::error, REG_RET::error_str, YCPElement::isNull(), result(), REG_RET::result_str, solve_regular_expression(), REG_RET::solved, and ycp2error.
Referenced by YCPBuiltinString::YCPBuiltinString().
regexptokenize Regex tokenize
string | INPUT |
string | PATTERN |
If the pattern does not match, the list is empty. Otherwise the list contains then matchted subexpressions for each pair of parenthesize in pattern.
If the pattern is invalid, 'nil' is returned.
Examples: // e == [ "aaabbB" ] list e = regexptokenize ("aaabbBb", "(.*[A-Z]).*");
// h == [ "aaab", "bb" ] list h = regexptokenize ("aaabbb", "(.*ab)(.*)");
// h == [] list h = regexptokenize ("aaabbb", "(.*ba).*");
// h == nil list h = regexptokenize ("aaabbb", "(.*ba).*(");
References YCPList::add(), REG_RET::error, REG_RET::error_str, YCPElement::isNull(), REG_RET::match_nb, REG_RET::match_str, result(), solve_regular_expression(), REG_RET::solved, and ycp2error.
Referenced by YCPBuiltinString::YCPBuiltinString().
deletechars
Removes all characters from a string
string | STRING |
string | REMOVE Characters to be removed from STRING |
Returns a string that results from string STRING
by removing all characters that occur in string REMOVE
.
References YCPElement::isNull().
Referenced by YCPBuiltinString::YCPBuiltinString().
search Returns position of a substring
string | STRING1 String |
string | STRING2 Substring |
The search
function searches string for the first occurency of a specified substring (possibly a single character) and returns its starting position.
Returns the first position in STRING1
where the string STRING2
is contained in STRING1
. OFFSET
starts with 0.
References YCPElement::isNull().
Referenced by s_find(), and YCPBuiltinString::YCPBuiltinString().
size size-string Returns the number of characters of the string s
string | s String |
s
Notice, that size(nil) -> nil
size("size") -> 4
References YCPElement::isNull().
Referenced by YCPBuiltinString::YCPBuiltinString().
|
static |
substring substring-rest Returns part of a string
string | STRING Original String |
integer | OFFSET Start position integer LENGTH Length of new string |
Returns the portion of STRING
specified by the OFFSET
and LENGHT
parameters. OFFSET
starts with 0.
substring ("some text", 5) -> "text" substring ("some text", 42) -> "" substring ("some text", 5, 2) -> "te" substring ("some text", 42, 2) -> "" substring("123456789", 2, 3) -> "345"
References YCPElement::isNull(), and ycp2error.
Referenced by YCPBuiltinString::YCPBuiltinString().
|
static |
substring substring-length Extracts a substring
Extracts a substring of the string STRING
, starting at OFFSET
after the first one with length of at most LENGTH
. OFFSET
starts with 0.
string | STRING |
integer | OFFSET |
integer | LENGTH |
References YCPElement::isNull(), and ycp2error.
Referenced by YCPBuiltinString::YCPBuiltinString().
|
static |
timestring Returns time string Combination of standard libc functions gmtime or localtime and strftime.
string | FORMAT |
integer | TIME |
boolean | UTC |
timestring ("%F %T %Z", time (), false) -> "2004-08-24 14:55:05 CEST"
References format(), and YCPElement::isNull().
Referenced by YCPBuiltinString::YCPBuiltinString().
toascii Returns characters below 0x7F included in STRING
string | STRING |
Returns a string that results from string STRING
by copying each character that is below 0x7F (127).
toascii ("aBë") -> "aB" toascii ("123+-abcABCöëä") -> "123+-abcABC"
References YCPElement::isNull().
Referenced by YCPBuiltinString::YCPBuiltinString().
|
static |
tohexstring tohexstring-1 Converts an integer to a hexadecimal string.
integer | number Number |
tohexstring (31) -> "0x1f"
References YCPElement::isNull().
Referenced by YCPBuiltinString::YCPBuiltinString().
|
static |
tohexstring tohexstring-2 Converts an integer to a hexadecimal string.
integer | number Number |
integer | width Width |
tohexstring (31, 1) -> "0x1f" tohexstring (31, 4) -> "0x001f"
References YCPElement::isNull().
Referenced by YCPBuiltinString::YCPBuiltinString().
tolower Makes a string lowercase
string | s String |
Returns string with all alphabetic characters converted to lowercase. Notice: National characters are left unchanged. Use when working with e.g. options in config files.
tolower ("aBcDeF") -> "abcdef" tolower ("ABCÁÄÖČ") -> "abcÁÄÖČ"
References YCPElement::isNull().
Referenced by YCPBuiltinString::YCPBuiltinString().
tostring tostring-any Converts a value to a string.
any | VALUE |
tostring(.path) -> ".path" tostring([1,2,3]) -> "[1, 2, 3]" tostring($[1:1,2:2,3:3]) -> "$[1:1, 2:2, 3:3]" tostring(<tt>Empty()) -> "</tt>Empty ()"
References YCPElement::isNull(), and YT_STRING.
Referenced by YCPBuiltinString::YCPBuiltinString().
toupper Makes a string uppercase
Returns string with all alphabetic characters converted to uppercase. Notice: National characters are left unchanged. Use when working with e.g. options in config files.
References YCPElement::isNull().
Referenced by YCPBuiltinString::YCPBuiltinString().
Reg_Ret solve_regular_expression | ( | const char * | input, |
const char * | pattern, | ||
const char * | result | ||
) |
References ERR_MAX, REG_RET::error, REG_RET::error_str, REG_RET::match_nb, REG_RET::match_str, result(), REG_RET::result_str, REG_RET::solved, and SUB_MAX.
Referenced by s_regexpmatch(), s_regexppos(), s_regexpsub(), and s_regexptokenize().
StaticDeclaration static_declarations |