-
Notifications
You must be signed in to change notification settings - Fork 28
/
Copy pathndlstrutil.h
28 lines (26 loc) · 975 Bytes
/
ndlstrutil.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
/*This file contains useful utilities for manipulating and outputting strings.*/
#ifndef NDLSTRUTIL_H
#define NDLSTRUTIL_H
#include <limits>
#include <algorithm>
#include <vector>
#include <string>
#include <iostream>
#include "ndlexceptions.h"
namespace ndlstrutil
{
// allocate doubles in 100k chunks.
const int ALLOCATECHUNK=(int)(100*(double)1024/(double)sizeof(double));
// split a string into tokes given a delimiter.
void tokenise(std::vector<std::string>& tokens,
const std::string& str,
const std::string& delimiters = " ");
// a version of getline which ignores lines starting with #.
bool getline(std::istream& in, std::string& line);
// take a string and sent it to an output stream placing carriage returns correctly.
void wrapOutputText(std::ostream& out, const std::string description, const int width, const int padding);
// convert an integer to a string.
std::string itoa(long value, int base=10);
std::string dirSep();
}
#endif