• Skip to content
  • Skip to link menu
Trinity API Reference
  • Trinity API Reference
  • tdecore
 

tdecore

Enumerations | Functions
KMacroExpander Namespace Reference

Enumerations

enum  Quoting {
  noquote , singlequote , doublequote , dollarquote ,
  paren , subst , group , math
}
 

Functions

TQString expandMacros (const TQString &str, const TQMap< TQChar, TQString > &map, TQChar c='%')
 
TQString expandMacrosShellQuote (const TQString &str, const TQMap< TQChar, TQString > &map, TQChar c='%')
 
TQString expandMacros (const TQString &str, const TQMap< TQString, TQString > &map, TQChar c='%')
 
TQString expandMacrosShellQuote (const TQString &str, const TQMap< TQString, TQString > &map, TQChar c='%')
 
TQString expandMacros (const TQString &str, const TQMap< TQChar, TQStringList > &map, TQChar c='%')
 
TQString expandMacrosShellQuote (const TQString &str, const TQMap< TQChar, TQStringList > &map, TQChar c='%')
 
TQString expandMacros (const TQString &str, const TQMap< TQString, TQStringList > &map, TQChar c='%')
 
TQString expandMacrosShellQuote (const TQString &str, const TQMap< TQString, TQStringList > &map, TQChar c='%')
 

Detailed Description

A group of functions providing macro expansion (substitution) in strings, optionally with quoting appropriate for shell execution.

Since
3.1.3

Enumeration Type Documentation

◆ Quoting

enum KMacroExpander::Quoting
Internal use only. Quoting state of the expander code. Not available publicly.

Definition at line 85 of file kmacroexpander.cpp.

Function Documentation

◆ expandMacros() [1/4]

TQString KMacroExpander::expandMacros ( const TQString &  str,
const TQMap< TQChar, TQString > &  map,
TQChar  c = '%' 
)

Perform safe macro expansion (substitution) on a string.

The escape char must be quoted with itself to obtain its literal representation in the resulting string.

Parameters
strThe string to expand
mapmap with substitutions
cescape char indicating start of macro, or TQChar::null if none
Returns
the string with all valid macros expanded
// Code example
TQMap<TQChar,TQString> map;
map.insert('u', "/tmp/myfile.txt");
map.insert('n', "My File");
TQString s = "%% Title: %u:%n";
s = KMacroExpander::expandMacros(s, map);
// s is now "% Title: /tmp/myfile.txt:My File";
KMacroExpander::expandMacros
TQString expandMacros(const TQString &ostr, const TQMap< TQChar, TQString > &map, TQChar c)
Perform safe macro expansion (substitution) on a string.
Definition: kmacroexpander.cpp:520

Definition at line 520 of file kmacroexpander.cpp.

◆ expandMacros() [2/4]

TQString KMacroExpander::expandMacros ( const TQString &  ostr,
const TQMap< TQChar, TQStringList > &  map,
TQChar  c 
)

Same as above, except that the macros expand to string lists that are simply join(" ")ed together.

Definition at line 524 of file kmacroexpander.cpp.

◆ expandMacros() [3/4]

TQString KMacroExpander::expandMacros ( const TQString &  str,
const TQMap< TQString, TQString > &  map,
TQChar  c = '%' 
)

Perform safe macro expansion (substitution) on a string.

The escape char must be quoted with itself to obtain its literal representation in the resulting string. Macro names can consist of chars in the range [A-Za-z0-9_]; use braces to delimit macros from following words starting with these chars, or to use other chars for macro names.

Parameters
strThe string to expand
mapmap with substitutions
cescape char indicating start of macro, or TQChar::null if none
Returns
the string with all valid macros expanded
// Code example
TQMap<TQString,TQString> map;
map.insert("url", "/tmp/myfile.txt");
map.insert("name", "My File");
TQString s = "Title: %{url}-%name";
s = KMacroExpander::expandMacros(s, map);
// s is now "Title: /tmp/myfile.txt-My File";

Definition at line 522 of file kmacroexpander.cpp.

◆ expandMacros() [4/4]

TQString KMacroExpander::expandMacros ( const TQString &  ostr,
const TQMap< TQString, TQStringList > &  map,
TQChar  c 
)

Same as above, except that the macros expand to string lists that are simply join(" ")ed together.

Definition at line 526 of file kmacroexpander.cpp.

◆ expandMacrosShellQuote() [1/4]

TQString KMacroExpander::expandMacrosShellQuote ( const TQString &  str,
const TQMap< TQChar, TQString > &  map,
TQChar  c = '%' 
)

Perform safe macro expansion (substitution) on a string for use in shell commands.

The escape char must be quoted with itself to obtain its literal representation in the resulting string.

Parameters
strThe string to expand
mapmap with substitutions
cescape char indicating start of macro, or TQChar::null if none
Returns
the string with all valid macros expanded, or a null string if a shell syntax error was detected in the command
// Code example
TQMap<TQChar,TQString> map;
map.insert('u', "/tmp/myfile.txt");
map.insert('n', "My File");
TQString s = "kedit --caption %n %u";
s = KMacroExpander::expandMacrosShellQuote(s, map);
// s is now "kedit --caption 'My File' '/tmp/myfile.txt'";
system(TQFile::encodeName(s));
KMacroExpander::expandMacrosShellQuote
TQString expandMacrosShellQuote(const TQString &ostr, const TQMap< TQChar, TQString > &map, TQChar c)
Perform safe macro expansion (substitution) on a string for use in shell commands.
Definition: kmacroexpander.cpp:521

Definition at line 521 of file kmacroexpander.cpp.

◆ expandMacrosShellQuote() [2/4]

TQString KMacroExpander::expandMacrosShellQuote ( const TQString &  str,
const TQMap< TQChar, TQStringList > &  map,
TQChar  c = '%' 
)

Same as above, except that the macros expand to string lists.

If the macro appears inside a quoted string, the list is simply join(" ")ed together; otherwise every element expands to a separate quoted string.

Definition at line 525 of file kmacroexpander.cpp.

◆ expandMacrosShellQuote() [3/4]

TQString KMacroExpander::expandMacrosShellQuote ( const TQString &  str,
const TQMap< TQString, TQString > &  map,
TQChar  c = '%' 
)

Perform safe macro expansion (substitution) on a string for use in shell commands.

The escape char must be quoted with itself to obtain its literal representation in the resulting string. Macro names can consist of chars in the range [A-Za-z0-9_]; use braces to delimit macros from following words starting with these chars, or to use other chars for macro names.

Parameters
strThe string to expand
mapmap with substitutions
cescape char indicating start of macro, or TQChar::null if none
Returns
the string with all valid macros expanded, or a null string if a shell syntax error was detected in the command
// Code example
TQMap<TQString,TQString> map;
map.insert("url", "/tmp/myfile.txt");
map.insert("name", "My File");
TQString s = "kedit --caption %name %{url}";
s = KMacroExpander::expandMacrosShellQuote(s, map);
// s is now "kedit --caption 'My File' '/tmp/myfile.txt'";
system(TQFile::encodeName(s));

Definition at line 523 of file kmacroexpander.cpp.

◆ expandMacrosShellQuote() [4/4]

TQString KMacroExpander::expandMacrosShellQuote ( const TQString &  str,
const TQMap< TQString, TQStringList > &  map,
TQChar  c = '%' 
)

Same as above, except that the macros expand to string lists.

If the macro appears inside a quoted string, the list is simply join(" ")ed together; otherwise every element expands to a separate quoted string.

Definition at line 527 of file kmacroexpander.cpp.

tdecore

Skip menu "tdecore"
  • Main Page
  • Modules
  • Namespace List
  • Class Hierarchy
  • Alphabetical List
  • Class List
  • File List
  • Namespace Members
  • Class Members
  • Related Pages

tdecore

Skip menu "tdecore"
  • arts
  • dcop
  • dnssd
  • interfaces
  •   kspeech
  •     interface
  •     library
  •   tdetexteditor
  • kate
  • kded
  • kdoctools
  • kimgio
  • kjs
  • libtdemid
  • libtdescreensaver
  • tdeabc
  • tdecmshell
  • tdecore
  • tdefx
  • tdehtml
  • tdeinit
  • tdeio
  •   bookmarks
  •   httpfilter
  •   kpasswdserver
  •   kssl
  •   tdefile
  •   tdeio
  •   tdeioexec
  • tdeioslave
  •   http
  • tdemdi
  •   tdemdi
  • tdenewstuff
  • tdeparts
  • tdeprint
  • tderandr
  • tderesources
  • tdespell2
  • tdesu
  • tdeui
  • tdeunittest
  • tdeutils
  • tdewallet
Generated for tdecore by doxygen 1.9.4
This website is maintained by Timothy Pearson.