sources/mystring.h

Wed, 27 Jan 2021 19:01:37 +0200

author
Teemu Piippo <teemu@hecknology.net>
date
Wed, 27 Jan 2021 19:01:37 +0200
changeset 188
5fc32e4b2a8c
parent 183
9b6a0daedfc0
child 189
248d0b85cbda
permissions
-rw-r--r--

validate the ip address octets better

/*
	Copyright 2014 - 2016 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, ...);
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& str, const std::string& other);
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