DFT-FE 1.1.0-pre
Density Functional Theory With Finite-Elements
Loading...
Searching...
No Matches
StringOperations.h
Go to the documentation of this file.
1/******************************************************************************
2 * Copyright (c) 2021. *
3 * The Regents of the University of Michigan and DFT-EFE developers. *
4 * *
5 * This file is part of the DFT-EFE code. *
6 * *
7 * DFT-EFE is free software: you can redistribute it and/or modify *
8 * it under the terms of the Lesser GNU General Public License as *
9 * published by the Free Software Foundation, either version 3 of *
10 * the License, or (at your option) any later version. *
11 * *
12 * DFT-EFE is distributed in the hope that it will be useful, but *
13 * WITHOUT ANY WARRANTY; without even the implied warranty *
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. *
15 * See the Lesser GNU General Public License for more details. *
16 * *
17 * You should have received a copy of the GNU Lesser General Public *
18 * License at the top level of DFT-EFE distribution. If not, see *
19 * <https://www.gnu.org/licenses/>. *
20 ******************************************************************************/
21/*
22 * @author Bikash Kanungo
23 */
24
25#ifndef DFTFE_STRINGOPERATIONS_H
26#define DFTFE_STRINGOPERATIONS_H
27#include <TypeConfig.h>
28namespace dftfe
29{
30 namespace utils
31 {
32 namespace stringOps
33 {
34 bool
35 strToInt(const std::string s, dftfe::Int &i);
36
37 bool
38 strToDouble(const std::string s, double &x);
39
40 void
41 trim(std::string &s);
42
43 std::string
44 trimCopy(const std::string &s);
45
46 /*
47 *@brief Function to split a string into vector of strings based on a delimiter(s).
48 *@param[in] inpStr The string to split
49 *@param[in] delimiter A string containing all the characters that are to
50 treated as delimiters. Default delimiter is space (" ") Examples:
51 1. delimiter = " " will use a space as a delimiter
52 2. delimiter = ", " will use both comma, space as a delimiter
53 @param[in] skipAdjacentDelimiters Boolean to specify whether to merge
54 adjacent delimiters. To elaborate, if set to false, then two adjacent
55 delimiters will be treated as containing an empty string which will be
56 added to the output. If set to true, adjacent delimiters will be treated
57 as a single delimiter Default: true
58 @param[in] skipLeadTrailWhiteSpace Boolean to specify whether to skip
59 any leading and trailing whitespaces. If set to false, leading and
60 trailing whitespaces are treated as non-empty strings and included in the
61 output. If set to true, leading and trailing whitespaces are not
62 included. Default = true
63 *@return A vector of strings obtained by spliting \p inpStr
64 */
65 std::vector<std::string>
66 split(const std::string &inpStr,
67 std::string delimiter = " ",
68 bool skipAdjacentDelimiters = true,
69 bool skipLeadTrailWhiteSpace = true);
70 } // end of namespace stringOps
71 } // end of namespace utils
72} // end of namespace dftfe
73#endif // DFTFE_STRINGOPERATIONS_H
Definition StringOperations.h:33
bool strToDouble(const std::string s, double &x)
std::string trimCopy(const std::string &s)
std::vector< std::string > split(const std::string &inpStr, std::string delimiter=" ", bool skipAdjacentDelimiters=true, bool skipLeadTrailWhiteSpace=true)
void trim(std::string &s)
bool strToInt(const std::string s, dftfe::Int &i)
Definition Cell.h:36
Definition pseudoPotentialToDftfeConverter.cc:34
std::int32_t Int
Definition TypeConfig.h:11