libcppwrap
A collection of C++ wrappers for native APIs
Loading...
Searching...
No Matches
include
wx
slurp.hpp
Go to the documentation of this file.
1
//
2
// libcppwrap - A collection of C++ wrappers for native APIs
3
// Copyright (C) 2021-2023 David A. Norris <danorris@gmail.com>
4
// Published under the MIT license - https://opensource.org/licenses/MIT
5
//
6
7
#pragma once
8
9
#include <
filesystem
>
10
#include <
string
>
11
#include <
string_view
>
12
13
namespace
wx
14
{
29
std::string
read_file_as_string
(
const
char
*path);
30
34
inline
std::string
read_file_as_string
(
const
std::string
& path) {
return
read_file_as_string
(path.
c_str
()); }
35
45
std::string
slurp
(
const
char
*path);
46
50
inline
std::string
slurp
(
const
std::string
& path) {
return
slurp
(path.
c_str
()); }
51
55
inline
std::string
slurp
(
const
std::filesystem::path
& path) {
return
slurp
(path.
c_str
()); }
56
64
void
spew
(
const
char
*path,
std::string_view
str);
65
69
inline
void
spew
(
const
std::string
& path,
std::string_view
str) {
return
spew
(path.
c_str
(), str); }
70
74
inline
void
spew
(
const
std::filesystem::path
& path,
std::string_view
str) {
return
spew
(path.
c_str
(), str); }
75
}
std::string
std::string_view
std::string::c_str
T c_str(T... args)
filesystem
wx
Definition:
ipv6.hpp:14
wx::read_file_as_string
std::string read_file_as_string(const char *path)
Reads the contents of a file as a string.
Definition:
slurp.cpp:19
wx::slurp
std::string slurp(const char *path)
Reads the contents of a file as a string with trailing whitespace removed.
Definition:
slurp.cpp:51
wx::spew
void spew(const char *path, std::string_view str)
Writes a string to a file.
Definition:
slurp.cpp:58
std::filesystem::path::c_str
T c_str(T... args)
std::filesystem::path
string
string_view
Generated by
1.9.5