mirror of
https://develop.openfoam.com/Development/openfoam.git
synced 2025-11-28 03:28:01 +00:00
string trim
This commit is contained in:
@ -6,7 +6,7 @@
|
||||
\\/ M anipulation |
|
||||
-------------------------------------------------------------------------------
|
||||
Copyright (C) 2011-2017 OpenFOAM Foundation
|
||||
Copyright (C) 2004-2011, 2017-2019 OpenCFD Ltd.
|
||||
Copyright (C) 2017-2019 OpenCFD Ltd.
|
||||
-------------------------------------------------------------------------------
|
||||
License
|
||||
This file is part of OpenFOAM.
|
||||
@ -49,6 +49,13 @@ SourceFiles
|
||||
#include <regex.h>
|
||||
#include <string>
|
||||
|
||||
// Transitional feature - support std::smatch as per C++11 regex
|
||||
#undef Foam_regExpPosix_cxx
|
||||
|
||||
#ifdef Foam_regExpPosix_cxx
|
||||
#include <regex>
|
||||
#endif
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
namespace Foam
|
||||
@ -71,8 +78,16 @@ class regExpPosix
|
||||
|
||||
public:
|
||||
|
||||
//- Type for matches
|
||||
typedef SubStrings<std::string> results_type;
|
||||
// Public Types
|
||||
|
||||
#ifdef Foam_regExpPosix_cxx
|
||||
//- Type for matches, as per C++11 regex
|
||||
typedef std::smatch results_type;
|
||||
#else
|
||||
//- Type for matches, use OpenFOAM SubStrings container
|
||||
typedef SubStrings<std::string> results_type;
|
||||
#endif
|
||||
|
||||
|
||||
// Static Member Data
|
||||
|
||||
@ -190,7 +205,6 @@ public:
|
||||
//- Assign and compile pattern from string.
|
||||
// Matching is case sensitive.
|
||||
inline void operator=(const std::string& pattern);
|
||||
|
||||
};
|
||||
|
||||
|
||||
|
||||
@ -27,7 +27,6 @@ License
|
||||
|
||||
#include <algorithm>
|
||||
|
||||
|
||||
// * * * * * * * * * * * * * Static Member Functions * * * * * * * * * * * * //
|
||||
|
||||
inline bool Foam::regExpPosix::meta(char c)
|
||||
|
||||
@ -84,8 +84,11 @@ class regExpCxx
|
||||
|
||||
public:
|
||||
|
||||
//- Type for matches
|
||||
typedef std::smatch results_type;
|
||||
// Public Types
|
||||
|
||||
//- Type for matches
|
||||
typedef std::smatch results_type;
|
||||
|
||||
|
||||
// Static Member Data
|
||||
|
||||
|
||||
@ -48,6 +48,7 @@ SourceFiles
|
||||
#include "stringOpsSort.H"
|
||||
#include "stringOpsEvaluate.H"
|
||||
#include "wordRes.H"
|
||||
#include <utility>
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
@ -256,6 +257,16 @@ namespace stringOps
|
||||
// Return true if a replacement was successful.
|
||||
bool inplaceReplaceVar(std::string& s, const word& varName);
|
||||
|
||||
//- Find first and last non-space locations in string or sub-string
|
||||
//- and return as a (pos, len) pair.
|
||||
// In the future this might become a std::smatch or a std::stringview
|
||||
std::pair<size_t, size_t>
|
||||
findTrim
|
||||
(
|
||||
const std::string& s,
|
||||
size_t pos = 0,
|
||||
size_t len = std::string::npos
|
||||
);
|
||||
|
||||
//- Return string trimmed of leading whitespace
|
||||
string trimLeft(const std::string& s);
|
||||
|
||||
Reference in New Issue
Block a user