sources/mystring.h

Thu, 28 Jan 2021 11:37:36 +0200

author
Teemu Piippo <teemu@hecknology.net>
date
Thu, 28 Jan 2021 11:37:36 +0200
branch
protocol5
changeset 197
819fdef70d68
parent 195
be953e1621d9
parent 196
58d4a48f0904
permissions
-rw-r--r--

merged with default

/*
	Copyright 2014 - 2021 Teemu Piippo
	All rights reserved.

	Redistribution and use in source and binary forms, with or without
	modification, are permitted provided that the following conditions
	are met:

	1. Redistributions of source code must retain the above copyright
	   notice, this list of conditions and the following disclaimer.
	2. Redistributions in binary form must reproduce the above copyright
	   notice, this list of conditions and the following disclaimer in the
	   documentation and/or other materials provided with the distribution.
	3. Neither the name of the copyright holder nor the names of its
	   contributors may be used to endorse or promote products derived from
	   this software without specific prior written permission.

	THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
	"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
	TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A
	PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER
	OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
	EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
	PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
	PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
	LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
	NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
	SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/

#pragma once
#include <deque>
#include <string>
#include <stdarg.h>
#include "basics.h"
#include "list.h"

BEGIN_ZFC_NAMESPACE

using String = std::string;
using StringList = std::vector<std::string>;
using namespace std::string_literals;

std::string to_lowercase(const std::string& string);
std::string join_string_list(const std::vector<std::string>& strings, const std::string& delim);
std::string mid(const std::string& str, int rangeBegin, int rangeEnd);
std::string right(const std::string& str, int length);
std::string vsprintf(const char* formatString, va_list args);
std::string __cdecl sprintf(const char* formatString, ...) GNUATTRIBUTE((format(printf, 1, 2)));
std::string remove_range(const std::string& string, int start, int end);
void replace_all(std::string& str, const char* text, const char* replacement);
bool starts_with(const std::string& string, const std::string& substring);
std::vector<std::string> split(const std::string& string, const std::string& delimeter);
std::optional<long> to_int(const char* str, int base = 10);
void normalize(std::string& string, int (*filter)(int) = std::isspace);

END_ZFC_NAMESPACE

mercurial