VirtualC64 v5.0 beta
Commodore 64 Emulator
Loading...
Searching...
No Matches
StringUtils.h
1// -----------------------------------------------------------------------------
2// This file is part of VirtualC64
3//
4// Copyright (C) Dirk W. Hoffmann. www.dirkwhoffmann.de
5// This FILE is dual-licensed. You are free to choose between:
6//
7// - The GNU General Public License v3 (or any later version)
8// - The Mozilla Public License v2
9//
10// SPDX-License-Identifier: GPL-3.0-or-later OR MPL-2.0
11// -----------------------------------------------------------------------------
12
13#pragma once
14
15#include "Types.h"
16#include <vector>
17
18namespace vc64::util {
19
20//
21// Creating
22//
23
24// Creates a string from a buffer
25string createStr(const u8 *buf, isize maxLen);
26string createAscii(const u8 *buf, isize len, char fill = '.');
27
28
29//
30// Converting
31//
32
33// Parses a hexadecimal number in string format
34bool parseHex(const string &s, isize *result);
35
36// Converts an integer value to a hexadecimal string representation
37template <isize digits> string hexstr(isize number);
38
39
40//
41// Transforming
42//
43
44// Converts the capitalization of a string
45string lowercased(const string& s);
46string uppercased(const string& s);
47
48// Replaces all unprintable characters
49string makePrintable(const string& s);
50
51
52//
53// Stripping off characters
54//
55
56string ltrim(const string &s, const string &characters = " ");
57string rtrim(const string &s, const string &characters = " ");
58string trim(const string &s, const string &characters = " ");
59
60
61//
62// Splitting and concatenating
63//
64
65std::vector<string> split(const string &s, char delimiter);
66string concat(std::vector<string> &s, string delimiter);
67
68
69//
70// Pretty printing
71//
72
73// Returns a textual description for a byte count
74string byteCountAsString(isize bytes);
75
76// Returns a textual description for a fill level
77string fillLevelAsString(double percentage);
78
79}