jAPItexts
A set of functions related to texts operations
jSTRremove
AnsiString __fastcall jSTRremove(AnsiString _src, int
_pos, int _len)
- description EN : remove a part of a string
- param _pos : the position of the first character of the
string to be removed
- param _src : the string that shall be cut
- param _len : the lenght of the string to be removed
- return : the string without the part removed
- author : JEG
- example : jSTRremove("I there, how are you ?", 2, 3)
--> "I re how are you ?"
jSTRremove
AnsiString __fastcall jSTRremove(char _c, AnsiString
_src)
- description EN : remove every occurence of a character
inside a string
- param _c : the character to be removed
- param _src : the string that shall be cut
- return : the string without the parts removed
- author : JEG
- example : jSTRremove('o', "I there, how are you ?") -->
"I there hw are yu ?"
jSTRremove
AnsiString __fastcall jSTRremove(AnsiString _key,
AnsiString _src)
- description EN : remove every occurence of a string
inside another string
- param _key : the string to be removed
- param _src : the string that shall be cut
- return : the string without the parts removed
- author : JEG
- example : jSTRremove("there", "I there, how are you ?")
--> "I , how are you ?"
jSTRreplace
AnsiString __fastcall jSTRreplace(char _a, char _b,
AnsiString _src)
- description EN : replace every occurence of a character
inside a string
- param _a : the character to be replaced
- param _b : the character that shall replace _a
- param _src : the string that shall be changed
- return : the string after the replacement
- author : JEG
- example : jSTRreplace('o', 'i', "I there, how are you
?") --> "I there, hiw are yiu ?"
jSTRreplace
AnsiString __fastcall jSTRreplace(AnsiString _ch1,
AnsiString _ch2, AnsiString _src)
- description EN : replace every occurence of a string
inside another string
- param _ch1
: the string to be replaced
- param _ch2
: the string that shall replace _ch1
- param _src : the string that shall be changed
- return : the string after the replacement
- author : JEG
- example : jSTRreplace("there", "everybody", "I there,
how are you ?") --> "I everybody, how are you ?"
jSTRfix
AnsiString __fastcall jSTRfix(AnsiString _src, int
_size)
- description EN : fix the length of a string (can be
fixed longer or shorter), when longer spaces are added
- param _src : the string that shall be changed
- param _size
: the new length of the string
- return : the string after the replacement
- author : JEG
- example : jSTRfix("I there, how are you ?", 27) --> "I
there, how are you ? "
jSTRcrypt
AnsiString __fastcall jSTRcrypt(AnsiString _src,
AnsiString _key)
- description EN : crypt a string using a string for key
(remark : this is a very very poor ciphering)
- param _src : the string to be ciphered
- param _key :the key that is used to cipher the
string (and to uncipher)
- return : the string ciphered
- author : JEG
- example (illustrating) : jSTRcrypt("I there, how are you ?",
"a_key") --> "#gerRbv$ù"
jSTRuncrypt
AnsiString __fastcall jSTRunCrypt(AnsiString _src,
AnsiString _key)
- description EN : uncrypt a string using a string for
key (previously ciphered with jSTRcrypt)
- param _src : the string to be unciphered
- param _key :the key that is used to uncipher the
string
- return : the string unciphered
- author : JEG
- example (illustrating) : jSTRcrypt("#gerRbv$ù",
"a_key") --> "I there, how are you ?"
jSTRinterpret
AnsiString __fastcall jSTRinterpret(AnsiString _src)
- description EN : transform a string containing "\t \n
\\" in clear text into a string with the exrta-character correponding
- param _src : the string to be changed
- return : the string changed
- author : JEG
- example : jSTRinterpret("c:\\\\directory\\\\file.txt")
--> "c:\\directory\\file.txt"
jSTRparse
bool __fastcall jSTRparse(AnsiString _path, char
_delimiter, TStrings * _sl)
- description EN : parse a delimited string into a liste
of substrings
- param _path
: the string to be parsed
- param _delimiter
: the character delimiting the substrings
- param _sl
: the StringList to be filled with the substrings
- author : JEG
- example : jSTRparse("menu/submenu/item", '/',
l_stringlist) --> l_stringlist will contain 3 elements : "menu", "submenu" and
"item"
jSTRparse
bool __fastcall jSTRparse(AnsiString _path, char
_delimiter, vector<AnsiString> & _strings)
- description EN : parse a delimited string into a liste
of substrings
- param _path
: the string to be parsed
- param _delimiter
: the character delimiting the substrings
- param _strings
: the vector of string to be filled with the substrings
- author : JEG
- example : jSTRparse("menu/submenu/item", '/',
l_stringlist) --> l_stringlist will contain 3 elements : "menu", "submenu" and
"item"
jSTRwriteString
bool __fastcall jSTRwriteString(AnsiString _string,
FILE * _f)
- description EN : write a string of any length into a
file
- param _string
: the string to be written
- param _f
: the file descriptor
- author : JEG
jSTRreadString
AnsiString __fastcall jSTRreadString(FILE * f)
- description EN : read a string of any length from a
file (must have been saved by jSTRwrite)
- param _f
: the file descriptor
- return : the string read
- author : JEG
jSTRwriteString
bool __fastcall jSTRwriteString(AnsiString _string,
TStream * _str)
- description EN : write a string of any length into a
stream
- param _string
: the string to be written
- param _str
: the stream (can be either a memory or a file stream)
- author : JEG
jSTRreadString
AnsiString __fastcall jSTRreadString(TStream * _str)
- description EN : read a string of any length from a
stream (must have been saved by jSTRwrite)
- param _str
: the stream (can be either a memory or a file stream)
- return : the string read
- author : JEG
jFILextension
AnsiString __fastcall jFILextension(AnsiString
_fileName)
- description EN : returns the extension of a filename
- param _fileName
: the location of the file (with the extension)
- return : the extension
- author : JEG
jFILcaption
AnsiString __fastcall jFILcaption(AnsiString _fileName)
- description EN : returns the filename without the
extension and the path
- param _fileName
: the location of the file
- return : the filename without the extension and the
path
- author : JEG
- example : jFILcaption("c:\\directory\\file.txt") -->
"file"
jFILgetPath
AnsiString __fastcall jFILgetPath(AnsiString _fileName)
- description EN : returns the path of the filename
- param _fileName
: the location of the file
- return : the path of the filename
- author : JEG
- example : jFILgetPath("c:\\directory\\file.txt") -->
"c:\\directory\\"
jFILstandardizePath
AnsiString __fastcall jFILstandardizePath(AnsiString
_path)
- description EN : ensure that the path ends with "\\"
(if it already ends with "\\", it is not modified)
- param _path:
the path to eventually change
- return :the path changed
- author : JEG
- example : jFILstandardizePath("c:\\directory")
--> "c:\\directory\\"
- example : jFILstandardizePath("c:\\directory\\") -->
"c:\\directory\\"
jFILcreatePath
bool __fastcall jFILcreatePath(AnsiString _path, bool
_force = true)
- description EN : create a path and subpaths
- param _path:
the path to create
- param _force
: force the subdirectories to be created if they does not exists
- author : JEG
- example :
jFILcreatePath("c:\\directory\\subdirectory\\anotherdirectory", true)
(we suppose that c:\\directory does not exists) --> the entire path is created
jFILdeletePath
bool __fastcall jFILdeletePath(AnsiString _path, bool
_force = false)
- description EN : delete a path and subpaths and files
it may contain
- param _path:
the path to be deleted
- param _force
: delete the directory even if it is not empty
- author : JEG
jFILparsePath
bool __fastcall jFILparsePath(AnsiString _path, TStrings
* _sl)
- description EN : parse a path and store the elements
into a list of strings
- param _path:
the path to be parsed
- param _sl
: the list of strings that receive the elements
- author : JEG
- example : jFILparsePath("c:\\directory\\subdirectory",
l_stringlist) --> l_stringlist will contain 3 elements : "c:", "directory" and
"subdirectory"
jFILmove
bool __fastcall jFILmove(AnsiString _src, AnsiString _dst)
- description EN : move a file from a location to another
- param _src
: the location of the file to be moved
- param _dst
: the location where it is supposed to move
- author : JEG
jFILlistFilesOf
bool __fastcall jFILlistFilesOf(AnsiString _path,
TStrings * _sl, bool _fullName = false, AnsiString _filter = "*.*", bool
_showExtension=true)
- description EN : list the files of a directory and
place it into a stringlist
- param _path
: the directory to list the files of
- param _sl
: the stringlist to store the filenames into
- param _fullName
: store the filename and their location or just the caption
- param _filter
: permit to list only some sort of file
- param _showExtension
: store the filename with their extensions or not
- author : JEG
jFILlistSubFilesOf
bool __fastcall jFILlistSubFilesOf(AnsiString & _path,
TStrings * _sl, bool _fullPath = false, AnsiString _filter = "*.*", int
_attrib =
faAnyFile)
- description EN : list the files of a directory and its
subdirectories and place it into a stringlist
- param _path
: the directory to list the files of
- param _sl
: the stringlist to store the filenames into
- param _fullPath
: store the filename and their location or just the caption
- param _filter
: permit to list only some sort of file
- param _attrib
: permit to list also directories, or just files or... (faReadOnly, faHidden,
faSysFile, faVolumeID, faDirectory, faArchive, faAnyFile)
- author : JEG
jFILlistDirStructureOf
bool __fastcall jFILlistDirStructureOf(AnsiString &
_path, TTreeView * _tv, AnsiString _extension = "*", int _attrib = faAnyFile,
TTreeNode * _tn = NULL)
- description EN : list the files of a directory and its
subdirectories and display it into a treeview
- param _path
: the directory to list the files of
- param _tv :
the treeview to store the filenames into
- param _extension
: permit to list only some sort of file
- param _attrib
: permit to list also directories, or just files or... (faReadOnly, faHidden,
faSysFile, faVolumeID, faDirectory, faArchive, faAnyFile)
- param _tn : used for recursion (do not use)
- author : JEG
jFILlistAndParseFilesOf
bool __fastcall jFILlistAndParseFilesOf(AnsiString &
_path, TTreeView * _tv, AnsiString _filter = "*.*", char _delim = '\\', bool
_showExtension=true)
- description EN : list the files of a directory and for
each file parse it to display into a treeview
- param _path
: the directory to list the files of
- param _tv :
the treeview to store the parsed filenames into
- param _filter
: permit to list only some sort of file
- param _delim
: the delimiter to parse the filenames with
- param _showExtension
: display the extension of the files or not
- author : JEG
jTREgetPath
AnsiString __fastcall jTREgetPath(TTreeNode * _tn, char
_delimiter = '\\')
- description EN : get the caption for the treenode
selected
- param _tn
: the treeview to store the parsed filenames into
- param _delimiter
: the delimiter to insert between each element constituating the path of
the node
- return : the caption for the treenode selected
- author : JEG