ERKALE
ERKALE - DFT from Hel
 All Classes Functions Variables Friends Pages
stringutil.h
1 /*
2  * This source code is part of
3  *
4  * E R K A L E
5  * -
6  * DFT from Hel
7  *
8  * Written by Susi Lehtola, 2010-2011
9  * Copyright (c) 2010-2011, Susi Lehtola
10  *
11  * This program is free software; you can redistribute it and/or
12  * modify it under the terms of the GNU General Public License
13  * as published by the Free Software Foundation; either version 2
14  * of the License, or (at your option) any later version.
15  */
16 
17 
18 
19 #include "global.h"
20 
21 #ifndef ERKALE_STRUTIL
22 #define ERKALE_STRUTIL
23 
24 #include <armadillo>
25 #include <vector>
26 #include <string>
27 #include <istream>
28 
30 std::string tolower(const std::string & in);
32 std::string toupper(const std::string & in);
33 
35 int stricmp(const std::string & str1, const std::string & str2);
37 int strcmp(const std::string & str1, const std::string & str2);
38 
40 std::string readline(std::istream & in, bool skipempty=true, const std::string & cchars="#!");
42 bool isblank(const std::string & line);
43 
45 std::string readline(FILE *in);
46 
48 std::vector<std::string> splitline(const std::string & line);
49 
51 std::string trim(const std::string & line);
52 
54 std::string rem_dbl_whitespace(const std::string & line);
55 
57 int readint(std::string num);
58 
60 double readdouble(std::string num);
61 
63 void print_E(const arma::vec & E, const std::vector<double> & occ, bool all=false);
64 
66 std::string memory_size(size_t size, bool approx=false);
67 
69 void print_symmat(const arma::mat &mat, bool floatformat=0, double cutoff=1e-3);
71 void print_mat(const arma::mat & mat, const char *fmt=" % .e");
72 
74 void print_orb(const arma::mat & C, const arma::vec & E);
75 
77 std::vector<std::string> parse(std::string in, const std::string & separator);
78 
80 std::vector<size_t> parse_range(const std::string & in, bool convert=false);
81 
83 std::vector<double> parse_range_double(const std::string & in);
84 
86 void parse_cube(const std::string & sizes, std::vector<double> & x, std::vector<double> & y, std::vector<double> & z);
87 
89 std::string space_number(int num);
90 
92 std::string print_bar(std::string msg, char pad='*', int width=80, bool toupper=true);
93 
94 #endif