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
27namespace dftfe
28{
29 namespace utils
30 {
31 namespace stringOps
32 {
33 bool
34 strToInt(const std::string s, int &i);
35
36 bool
37 strToDouble(const std::string s, double &x);
38
39 void
40 trim(std::string &s);
41
42 std::string
43 trimCopy(const std::string &s);
44
45 /*
46 *@brief Function to split a string into vector of strings based on a delimiter(s).
47 *@param[in] inpStr The string to split
48 *@param[in] delimiter A string containing all the characters that are to
49 treated as delimiters. Default delimiter is space (" ") Examples:
50 1. delimiter = " " will use a space as a delimiter
51 2. delimiter = ", " will use both comma, space as a delimiter
52 @param[in] skipAdjacentDelimiters Boolean to specify whether to merge
53 adjacent delimiters. To elaborate, if set to false, then two adjacent
54 delimiters will be treated as containing an empty string which will be
55 added to the output. If set to true, adjacent delimiters will be treated
56 as a single delimiter Default: true
57 @param[in] skipLeadTrailWhiteSpace Boolean to specify whether to skip
58 any leading and trailing whitespaces. If set to false, leading and
59 trailing whitespaces are treated as non-empty strings and included in the
60 output. If set to true, leading and trailing whitespaces are not
61 included. Default = true
62 *@return A vector of strings obtained by spliting \p inpStr
63 */
64 std::vector<std::string>
65 split(const std::string &inpStr,
66 std::string delimiter = " ",
67 bool skipAdjacentDelimiters = true,
68 bool skipLeadTrailWhiteSpace = true);
69 } // end of namespace stringOps
70 } // end of namespace utils
71} // end of namespace dftfe
72#endif // DFTFE_STRINGOPERATIONS_H
Definition StringOperations.h:32
bool strToInt(const std::string s, int &i)
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)
Definition Cell.h:36
Definition pseudoPotentialToDftfeConverter.cc:34