Survival Royale 1.0.0
A very simple yet funny card game.
Loading...
Searching...
No Matches
utility.h
Go to the documentation of this file.
1// Copyright (C) 2025 Giulio Salvi, Jacopo Paradisi
2//
3// This program is free software: you can redistribute it and/or modify
4// it under the terms of the GNU General Public License as published by
5// the Free Software Foundation, either version 3 of the License, or
6// (at your option) any later version.
7//
8// This program is distributed in the hope that it will be useful,
9// but WITHOUT ANY WARRANTY; without even the implied warranty of
10// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11// GNU General Public License for more details.
12//
13// You should have received a copy of the GNU General Public License
14// along with this program. If not, see <https://www.gnu.org/licenses/>.
15
20
21#include "consts.h"
22#include "includes.h"
23
24#ifndef _UTILITY_H_
26 #define _UTILITY_H_
27
33 char* substring(const char* string, int startPosition, int length);
39 int offsetFromNext(const char* string, char character, int startPosition);
45 int count(const char* string, char character, int startPosition);
51 bool containsFrom(const char* string, char character, int startPosition);
57 bool containsSubstringFrom(const char* string, const char* subString, int startPosition);
61 bool isDecimalDigit(char character);
65 bool isHexDigit(char character);
69 int decimalDigitToInt(char digit);
73 int hexDigitToInt(char digit);
77 int evalutateBase(char* number);
81 int nDigits(int number);
82#endif
Declaration of constants used by the modules.
Preprocessor file used for including library for modules.
bool isHexDigit(char character)
Checks if a char is a hexadecimal digit (not case sensitive).
Definition utility.c:101
bool containsFrom(const char *string, char character, int startPosition)
Checks if there is an occoruncy of the passed char from the passed position in the passed string.
Definition utility.c:63
int decimalDigitToInt(char digit)
If is a decimal digit, converts it to int; Otherwise returns ASCII integer representation of the pass...
Definition utility.c:105
int count(const char *string, char character, int startPosition)
Counts the number of occoruncies in the string, from a passed position, of the passed char.
Definition utility.c:50
int evalutateBase(char *number)
Evalutates the base of the number (by finding the biggest digit up to hexadecimal digit F) and return...
Definition utility.c:123
bool isDecimalDigit(char character)
Checks if a char is a decimal digit.
Definition utility.c:97
int offsetFromNext(const char *string, char character, int startPosition)
Counts the offset in the string between the position and the next occoruncy of the passed char.
Definition utility.c:38
int nDigits(int number)
Evalutates the number of digits of a number. The time complexity of this function is constant (O(1)).
Definition utility.c:138
char * substring(const char *string, int startPosition, int length)
Copies a substring (heap-allocated) from the passed string. If fails when allocating memory for the s...
Definition utility.c:23
int hexDigitToInt(char digit)
If is a hexadecimal digit (not case sensitive), converts it to int; Otherwise returns ASCII integer r...
Definition utility.c:109
bool containsSubstringFrom(const char *string, const char *subString, int startPosition)
Checks if there is an occoruncy of the passed substring from the passed position in the passed string...
Definition utility.c:75