1
1
mirror of https://github.com/theoludwig/libcproject.git synced 2024-09-20 05:45:53 +02:00
libcproject/lib/convert.h
Théo LUDWIG 72645da4b2
perf: mutate strings instead of copy when possible
BREAKING CHANGE: Most of string functions mutates the string instead of copying now.
This allows better performance when copy is not needed.
It also allows more granual control.
If copy is wanted, simply use `string_copy` before calling the function.

Impacted functions are:
`string_to_uppercase`, `string_to_lowercase`, `string_replace`,
`string_trim_start`, `string_trim_end`, `string_trim`,
`string_capitalize`, `string_reverse`
2023-08-06 23:17:07 +02:00

82 lines
1.6 KiB
C

#ifndef __LIBCPROJECT_CONVERT__
#define __LIBCPROJECT_CONVERT__
#include <stdio.h>
#include <stdlib.h>
#include "character.h"
#include "mathematics.h"
#include "stdbool.h"
#include "string.h"
#include "types.h"
/**
* @brief Convert a character to a string.
*
* @param character
* @since v1.0.0
*/
string_t convert_character_to_string(const char character);
/**
* @brief Convert a character to a digit.
*
* @param character
* @since v1.0.0
*/
char convert_character_to_digit(const char character);
/**
* @brief Convert a digit to a character.
*
* @param digit
* @since v1.0.0
*/
char convert_digit_to_character(const char digit);
/**
* @brief Convert a string to a number.
*
* @param string
* @since v1.0.0
*/
long long convert_string_to_number(const string_t string);
/**
* @brief Convert a number to a string.
*
* @param integer
* @since v1.0.0
*/
string_t convert_number_to_string(const long long integer);
/**
* @brief Convert a number (base 10) to a string with a specific base.
*
* @param number
* @param base
* @since v1.0.0
*/
string_t convert_number_from_base_10_to_base(unsigned long long number, unsigned int base);
/**
* @brief Convert a number with a specific base to a number base 10.
*
* @param number
* @param base
* @since v1.0.0
*/
int convert_number_from_base_to_base_10(string_t number, unsigned int base);
/**
* @brief Convert a number with a specific base to a number of specific base.
*
* @param number
* @param base_from
* @param base_target
* @since v1.0.0
*/
string_t convert_number_from_base_to_another(string_t number, int base_from, int base_target);
#endif