2 * Copyright (c) 2007-2013, Czirkos Zoltan http://code.google.com/p/gdash/
4 * Permission to use, copy, modify, and distribute this software for any
5 * purpose with or without fee is hereby granted, provided that the above
6 * copyright notice and this permission notice appear in all copies.
8 * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
9 * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
10 * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
11 * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
12 * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
13 * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
14 * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
24 /// find file, looking in user directory and install directory
25 /// @return full path of file if found, "" if not
26 std::string
gd_find_data_file(const std::string
& filename
, const std::vector
<std::string
>& dirs
);
28 /// create a string form a char*, and free it with g_free
29 std::string
gd_tostring_free(char *str
);
31 /// @brief Wrap a text to lines of specified maximum width.
32 /// Honors original newlines as well.
33 /// @param input The UTF-8 text to wrap. May contain UTF-8 characters, and GD_COLOR_SETCOLOR characters.
34 /// @param width The maximum length of lines.
35 /// @return The vector of lines.
36 std::vector
<std::string
> gd_wrap_text(const char *input
, int width
);
38 /// @brief Returns current date in 2008-12-04 format.
39 std::string
gd_get_current_date();
41 /// @brief Returns current date in 2008-12-04 12:34 format.
42 std::string
gd_get_current_date_time();
44 /// clamp integer into range
45 int gd_clamp(int val
, int min
, int max
);
47 /// remove leading and trailing spaces from s
48 void gd_strchomp(std::string
&s
);
50 /// compare two strings, ignoring case for ascii characters
51 int gd_str_ascii_casecmp(const std::string
&s1
, const std::string
&s2
);
53 bool gd_str_ascii_caseequal(const std::string
&s1
, const std::string
&s2
);
55 bool gd_str_equal(const char *a
, const char *b
);
57 bool gd_str_ascii_prefix(const std::string
&str
, const std::string
&prefix
);