Develop Biology
The language of life
String.h
Go to the documentation of this file.
1/*
2 * This file is a part of the Biology project by eons LLC.
3 * Biology (aka Develop Biology) is a framework for approaching software
4 * development from a natural sciences perspective.
5 *
6 * Copyright (C) 2021 Séon O'Shannon & eons LLC
7 *
8 * This program is free software: you can redistribute it and/or modify
9 * it under the terms of the GNU Affero General Public License as
10 * published by the Free Software Foundation, either version 3 of the
11 * License, or (at your option) any later version.
12 *
13 * This program is distributed in the hope that it will be useful,
14 * but WITHOUT ANY WARRANTY; without even the implied warranty of
15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 * GNU Affero General Public License for more details.
17 *
18 * You should have received a copy of the GNU Affero General Public License
19 * along with this program. If not, see <https://www.gnu.org/licenses/>.
20 */
21
22#pragma once
27#include "bio/common/Types.h"
28#include <string>
29#include <vector>
30#include <stdlib.h>
31#include <sstream>
32
33namespace bio {
34namespace string {
42bool ToBool(
43 const char* s,
44 bool* returned
45);
46
53bool ToInt(
54 const char* s,
55 int32_t* returned
56);
57
64bool ToUInt(
65 const char* s,
66 uint32_t* returned
67);
68
75bool ToFloat(
76 const char* s,
77 float* returned
78);
79
86template < typename T >
87std::string From(const T& value)
88{
89 std::ostringstream str;
90 str << value;
91 return str.str();
92}
93
103 const std::string& s,
104 char delimiter = ',',
105 bool trimLeadingSpaces = true
106);
107
115std::string FromVectorOfStrings(
116 const StdStrings& v,
117 char delimiter = ',',
118 bool trimLeadingSpaces = true
119);
120
128std::string FromVectorOfStrings(
129 const CharStrings& v,
130 char delimiter = ',',
131 bool trimLeadingSpaces = true
132);
133
139CharStrings ToCharStrings(const StdStrings& strings);
140
146StdStrings ToStdStrings(const CharStrings& strings);
147
153void CloneInto(
154 const char* source,
155 const char*& target
156);
157
162{
163 const char* string;
164 unsigned int echelon;
165};
166typedef std::vector< Echelon > Echelons;
167
168
169} //string namespace
170} //bio namespace
CharStrings ToCharStrings(const StdStrings &strings)
Definition: String.cpp:207
void CloneInto(const char *source, const char *&target)
Definition: String.cpp:236
StdStrings ToStdStrings(const CharStrings &strings)
Definition: String.cpp:221
bool ToBool(const char *s, bool *returned)
Definition: String.cpp:28
bool ToFloat(const char *s, float *returned)
Definition: String.cpp:79
std::string From(const T &value)
Definition: String.h:87
bool ToInt(const char *s, int32_t *returned)
Definition: String.cpp:41
std::string FromVectorOfStrings(const StdStrings &v, char delimiter=',', bool trimLeadingSpaces=true)
Definition: String.cpp:131
bool ToUInt(const char *s, uint32_t *returned)
Definition: String.cpp:60
std::vector< Echelon > Echelons
Definition: String.h:166
StdStrings Parse(const std::string &s, char delimiter=',', bool trimLeadingSpaces=true)
Definition: String.cpp:97
Definition: Cell.h:31
std::vector< std::string > StdStrings
Definition: Types.h:50
std::vector< const char * > CharStrings
Definition: Types.h:49
unsigned int echelon
Definition: String.h:164
const char * string
Definition: String.h:163