Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
mantid
Manage
Activity
Members
Labels
Plan
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Locked files
Deploy
Releases
Model registry
Analyze
Value stream analytics
Contributor analytics
Repository analytics
Code review analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
mantidproject
mantid
Commits
68f74cd3
Commit
68f74cd3
authored
12 years ago
by
Gigg, Martyn Anthony
Browse files
Options
Downloads
Patches
Plain Diff
Sort out formatting in Strings.{h,cpp}. Refs #5644
Before making real code changes.
parent
8dff6843
Loading
Loading
No related merge requests found
Changes
2
Expand all
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
Code/Mantid/Framework/Kernel/inc/MantidKernel/Strings.h
+130
-131
130 additions, 131 deletions
Code/Mantid/Framework/Kernel/inc/MantidKernel/Strings.h
Code/Mantid/Framework/Kernel/src/Strings.cpp
+997
-998
997 additions, 998 deletions
Code/Mantid/Framework/Kernel/src/Strings.cpp
with
1127 additions
and
1129 deletions
Code/Mantid/Framework/Kernel/inc/MantidKernel/Strings.h
+
130
−
131
View file @
68f74cd3
...
@@ -13,15 +13,12 @@
...
@@ -13,15 +13,12 @@
namespace
Mantid
namespace
Mantid
{
{
namespace
Kernel
namespace
Kernel
{
{
/** Holds support functions for strings.
/** Holds support functions for strings.
@author S. Ansell
Copyright & copy; 2007-2012 ISIS Rutherford Appleton Laboratory & NScD Oak Ridge National Laboratory
@date February 2006
Copyright & copy; 2007 ISIS Rutherford Appleton Laboratory & NScD Oak Ridge National Laboratory
This file is part of Mantid.
This file is part of Mantid.
...
@@ -37,132 +34,134 @@ namespace Kernel
...
@@ -37,132 +34,134 @@ namespace Kernel
You should have received a copy of the GNU General Public License
You should have received a copy of the GNU General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
along with this program. If not, see <http://www.gnu.org/licenses/>.
File change history is stored at: <https://svn.mantidproject.org/mantid/trunk/Code/Mantid>.
File change history is stored at: <https://svn.mantidproject.org/mantid/trunk/Code/Mantid>.
Code Documentation is available at: <http://doxygen.mantidproject.org>
Code Documentation is available at: <http://doxygen.mantidproject.org>
*/
*/
namespace
Strings
namespace
Strings
{
{
//------------------------------------------------------------------------------------------------
//------------------------------------------------------------------------------------------------
/** Join a set or vector of (something that turns into a string) together
/** Join a set or vector of (something that turns into a string) together
* into one string, separated by a string.
* into one string, separated by a string.
* Returns an empty string if the range is null.
* Returns an empty string if the range is null.
* Does not add the separator after the LAST item.
* Does not add the separator after the LAST item.
*
*
* For example, join a vector of strings with commas with:
* For example, join a vector of strings with commas with:
* out = join(v.begin(), v.end(), ", ");
* out = join(v.begin(), v.end(), ", ");
*
*
* @param begin :: iterator at the start
* @param begin :: iterator at the start
* @param end :: iterator at the end
* @param end :: iterator at the end
* @param separator :: string to append.
* @param separator :: string to append.
* @return
* @return
*/
*/
template
<
typename
ITERATOR_TYPE
>
template
<
typename
ITERATOR_TYPE
>
DLLExport
std
::
string
join
(
ITERATOR_TYPE
begin
,
ITERATOR_TYPE
end
,
const
std
::
string
separator
)
DLLExport
std
::
string
join
(
ITERATOR_TYPE
begin
,
ITERATOR_TYPE
end
,
const
std
::
string
separator
)
{
{
std
::
ostringstream
output
;
std
::
ostringstream
output
;
ITERATOR_TYPE
it
;
ITERATOR_TYPE
it
;
for
(
it
=
begin
;
it
!=
end
;
)
for
(
it
=
begin
;
it
!=
end
;
)
{
{
output
<<
*
it
;
output
<<
*
it
;
it
++
;
it
++
;
if
(
it
!=
end
)
if
(
it
!=
end
)
output
<<
separator
;
output
<<
separator
;
}
}
return
output
.
str
();
return
output
.
str
();
}
}
/// Return a string with all matching occurence-strings
/// Return a string with all matching occurence-strings
MANTID_KERNEL_DLL
std
::
string
replace
(
const
std
::
string
&
input
,
const
std
::
string
&
find_what
,
const
std
::
string
&
replace_with
);
MANTID_KERNEL_DLL
std
::
string
replace
(
const
std
::
string
&
input
,
const
std
::
string
&
find_what
,
const
std
::
string
&
replace_with
);
/// Return a string with all occurrences of the characters in the input replaced by the replace string
/// Return a string with all occurrences of the characters in the input replaced by the replace string
MANTID_KERNEL_DLL
std
::
string
replaceAll
(
const
std
::
string
&
input
,
const
std
::
string
&
charStr
,
const
std
::
string
&
substitute
);
MANTID_KERNEL_DLL
std
::
string
replaceAll
(
const
std
::
string
&
input
,
const
std
::
string
&
charStr
,
const
std
::
string
&
substitute
);
/// determine if a character group exists in a string
/// determine if a character group exists in a string
MANTID_KERNEL_DLL
int
confirmStr
(
const
std
::
string
&
S
,
const
std
::
string
&
fullPhrase
);
MANTID_KERNEL_DLL
int
confirmStr
(
const
std
::
string
&
S
,
const
std
::
string
&
fullPhrase
);
/// Get a word from a string
/// Get a word from a string
MANTID_KERNEL_DLL
int
extractWord
(
std
::
string
&
Line
,
const
std
::
string
&
Word
,
const
int
cnt
=
4
);
MANTID_KERNEL_DLL
int
extractWord
(
std
::
string
&
Line
,
const
std
::
string
&
Word
,
const
int
cnt
=
4
);
/// Get an int from the end of a word
/// Get an int from the end of a word
MANTID_KERNEL_DLL
int
endsWithInt
(
const
std
::
string
&
word
);
MANTID_KERNEL_DLL
int
endsWithInt
(
const
std
::
string
&
word
);
/// strip all spaces
/// strip all spaces
MANTID_KERNEL_DLL
std
::
string
removeSpace
(
const
std
::
string
&
CLine
);
MANTID_KERNEL_DLL
std
::
string
removeSpace
(
const
std
::
string
&
CLine
);
/// strip pre/post spaces
/// strip pre/post spaces
MANTID_KERNEL_DLL
std
::
string
fullBlock
(
const
std
::
string
&
A
);
MANTID_KERNEL_DLL
std
::
string
fullBlock
(
const
std
::
string
&
A
);
/// strip pre/post spaces
/// strip pre/post spaces
MANTID_KERNEL_DLL
std
::
string
strip
(
const
std
::
string
&
A
);
MANTID_KERNEL_DLL
std
::
string
strip
(
const
std
::
string
&
A
);
/// strip trailling comments
/// strip trailling comments
MANTID_KERNEL_DLL
void
stripComment
(
std
::
string
&
A
);
MANTID_KERNEL_DLL
void
stripComment
(
std
::
string
&
A
);
/// Determines if a string is only spaces
/// Determines if a string is only spaces
MANTID_KERNEL_DLL
int
isEmpty
(
const
std
::
string
&
A
);
MANTID_KERNEL_DLL
int
isEmpty
(
const
std
::
string
&
A
);
/// Get a line and strip comments
/// Get a line and strip comments
MANTID_KERNEL_DLL
std
::
string
getLine
(
std
::
istream
&
fh
,
const
int
spc
=
256
);
MANTID_KERNEL_DLL
std
::
string
getLine
(
std
::
istream
&
fh
,
const
int
spc
=
256
);
/// get a part of a long line
/// get a part of a long line
MANTID_KERNEL_DLL
int
getPartLine
(
std
::
istream
&
fh
,
std
::
string
&
Out
,
std
::
string
&
Excess
,
const
int
spc
=
256
);
MANTID_KERNEL_DLL
int
getPartLine
(
std
::
istream
&
fh
,
std
::
string
&
Out
,
std
::
string
&
Excess
,
const
int
spc
=
256
);
template
<
typename
T
>
int
convPartNum
(
const
std
::
string
&
A
,
T
&
out
);
/// Takes a character string and evaluates the first [typename T] object
template
<
typename
T
>
int
convPartNum
(
const
std
::
string
&
A
,
T
&
out
);
/// Convert a string into a number
template
<
typename
T
>
int
convert
(
const
std
::
string
&
A
,
T
&
out
);
/// Convert a string into a number
/// Convert a char* into a number
template
<
typename
T
>
int
convert
(
const
std
::
string
&
A
,
T
&
out
);
template
<
typename
T
>
int
convert
(
const
char
*
A
,
T
&
out
);
/// Convert a char* into a number
template
<
typename
T
>
int
convert
(
const
char
*
A
,
T
&
out
);
/// Convert a number to a string
template
<
typename
T
>
std
::
string
toString
(
const
T
value
);
/// Convert a number to a string
template
<
typename
T
>
std
::
string
toString
(
const
T
value
);
/// Convert a vector to a string
template
<
typename
T
>
std
::
string
toString
(
const
std
::
vector
<
T
>
&
value
);
/// Convert a vector to a string
template
<
typename
T
>
std
::
string
toString
(
const
std
::
vector
<
T
>
&
value
);
/// Convert a set to a string
template
<
typename
T
>
std
::
string
toString
(
const
std
::
set
<
T
>
&
value
);
/// Convert a set to a string
template
<
typename
T
>
std
::
string
toString
(
const
std
::
set
<
T
>
&
value
);
template
<
typename
T
>
int
setValues
(
const
std
::
string
&
Line
,
const
std
::
vector
<
int
>&
Index
,
std
::
vector
<
T
>&
Out
);
template
<
typename
T
>
int
setValues
(
const
std
::
string
&
Line
,
const
std
::
vector
<
int
>&
Index
,
std
::
vector
<
T
>&
Out
);
/// Convert and cut a string
template
<
typename
T
>
int
sectPartNum
(
std
::
string
&
A
,
T
&
out
);
/// Convert and cut a string
template
<
typename
T
>
int
sectPartNum
(
std
::
string
&
A
,
T
&
out
);
/// Convert and cut a string
template
<
typename
T
>
int
section
(
std
::
string
&
A
,
T
&
out
);
/// Convert and cut a string
/// Convert and cut a char*
template
<
typename
T
>
int
section
(
std
::
string
&
A
,
T
&
out
);
template
<
typename
T
>
int
section
(
char
*
cA
,
T
&
out
);
/// Convert and cut a char*
template
<
typename
T
>
int
section
(
char
*
cA
,
T
&
out
);
/// Convert and cut a string for MCNPX
template
<
typename
T
>
int
sectionMCNPX
(
std
::
string
&
A
,
T
&
out
);
/// Convert and cut a string for MCNPX
template
<
typename
T
>
int
sectionMCNPX
(
std
::
string
&
A
,
T
&
out
);
/// Write file in standard MCNPX input form
MANTID_KERNEL_DLL
void
writeMCNPX
(
const
std
::
string
&
Line
,
std
::
ostream
&
OX
);
/// Write file in standard MCNPX input form
MANTID_KERNEL_DLL
void
writeMCNPX
(
const
std
::
string
&
Line
,
std
::
ostream
&
OX
);
/// Split tring into spc deliminated components
MANTID_KERNEL_DLL
std
::
vector
<
std
::
string
>
StrParts
(
std
::
string
Ln
);
/// Split tring into spc deliminated components
MANTID_KERNEL_DLL
std
::
vector
<
std
::
string
>
StrParts
(
std
::
string
Ln
);
/// Write a set of containers to a file
template
<
template
<
typename
T
,
typename
A
>
class
V
,
typename
T
,
typename
A
>
/// Write a set of containers to a file
int
writeFile
(
const
std
::
string
&
Fname
,
const
T
&
step
,
const
V
<
T
,
A
>&
Y
);
template
<
template
<
typename
T
,
typename
A
>
class
V
,
typename
T
,
typename
A
>
template
<
template
<
typename
T
,
typename
A
>
class
V
,
typename
T
,
typename
A
>
int
writeFile
(
const
std
::
string
&
Fname
,
const
T
&
step
,
const
V
<
T
,
A
>&
Y
);
int
writeFile
(
const
std
::
string
&
Fname
,
const
V
<
T
,
A
>&
X
,
const
V
<
T
,
A
>&
Y
);
template
<
template
<
typename
T
,
typename
A
>
class
V
,
typename
T
,
typename
A
>
template
<
template
<
typename
T
,
typename
A
>
class
V
,
typename
T
,
typename
A
>
int
writeFile
(
const
std
::
string
&
Fname
,
const
V
<
T
,
A
>&
X
,
const
V
<
T
,
A
>&
Y
);
int
writeFile
(
const
std
::
string
&
Fname
,
const
V
<
T
,
A
>&
X
,
const
V
<
T
,
A
>&
Y
,
const
V
<
T
,
A
>&
Err
);
template
<
template
<
typename
T
,
typename
A
>
class
V
,
typename
T
,
typename
A
>
int
writeFile
(
const
std
::
string
&
Fname
,
const
V
<
T
,
A
>&
X
,
const
V
<
T
,
A
>&
Y
,
const
V
<
T
,
A
>&
Err
);
/// Convert a VAX number to x86 little eindien
float
getVAXnum
(
const
float
A
);
/// Convert a VAX number to x86 little eindien
float
getVAXnum
(
const
float
A
);
MANTID_KERNEL_DLL
void
readToEndOfLine
(
std
::
ifstream
&
in
,
bool
ConsumeEOL
);
/// Eat everything from the stream until the next EOL
MANTID_KERNEL_DLL
std
::
string
getWord
(
std
::
ifstream
&
in
,
bool
consumeEOL
);
MANTID_KERNEL_DLL
void
readToEndOfLine
(
std
::
ifstream
&
in
,
bool
ConsumeEOL
);
/// function parses a path, found in input string "path" and returns vector of the folders contributed into the path */
/// Returns the next word in the stream
MANTID_KERNEL_DLL
size_t
split_path
(
const
std
::
string
&
path
,
std
::
vector
<
std
::
string
>
&
path_components
);
MANTID_KERNEL_DLL
std
::
string
getWord
(
std
::
ifstream
&
in
,
bool
consumeEOL
);
/// function parses a path, found in input string "path" and returns vector of the folders contributed into the path */
/// Loads the entire contents of a text file into a string
MANTID_KERNEL_DLL
size_t
split_path
(
const
std
::
string
&
path
,
std
::
vector
<
std
::
string
>
&
path_components
);
MANTID_KERNEL_DLL
std
::
string
loadFile
(
const
std
::
string
&
filename
);
/// Loads the entire contents of a text file into a string
/// checks if the candidate is the member of the group
MANTID_KERNEL_DLL
std
::
string
loadFile
(
const
std
::
string
&
filename
);
MANTID_KERNEL_DLL
int
isMember
(
const
std
::
vector
<
std
::
string
>
&
group
,
const
std
::
string
&
candidate
);
/// checks if the candidate is the member of the group
}
// NAMESPACE Strings
MANTID_KERNEL_DLL
int
isMember
(
const
std
::
vector
<
std
::
string
>
&
group
,
const
std
::
string
&
candidate
);
}
// NAMESPACE Kernel
}
// NAMESPACE Strings
}
// NAMESPACE Kernel
}
// NAMESPACE Mantid
}
// NAMESPACE Mantid
...
...
This diff is collapsed.
Click to expand it.
Code/Mantid/Framework/Kernel/src/Strings.cpp
+
997
−
998
View file @
68f74cd3
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment