mirror of
https://github.com/fltk/fltk.git
synced 2026-02-05 15:59:50 +08:00
Removes the remaining references to Fl_String.
Still to do: rename fl_filename... to fl_filename..._str and introduce into core library.
This commit is contained in:
@@ -20,7 +20,7 @@
|
||||
#include "fluid.h"
|
||||
#include "Fl_Window_Type.h"
|
||||
|
||||
#include "../src/Fl_String.H"
|
||||
#include <string>
|
||||
|
||||
struct Fl_Menu_Item;
|
||||
|
||||
|
||||
@@ -22,12 +22,12 @@
|
||||
#ifndef fl_screenshot_H
|
||||
#define fl_screenshot_H
|
||||
|
||||
#include "../src/Fl_String.H"
|
||||
|
||||
#include <FL/Fl_Export.H>
|
||||
#include <FL/Fl_Window.H>
|
||||
#include <FL/Fl_Rect.H>
|
||||
|
||||
#include <string>
|
||||
|
||||
/** Class to initialize a Rect by providing the margin around a rect. */
|
||||
class Fl_Margin : public Fl_Rect {
|
||||
public:
|
||||
|
||||
@@ -798,7 +798,7 @@ int Fd_Code_Writer::write_code(const char *s, const char *t, bool to_codeview) {
|
||||
// Remember the last code file location for MergeBack
|
||||
if (s && g_project.write_mergeback_data && !to_codeview) {
|
||||
std::string proj_filename = g_project.projectfile_path() + g_project.projectfile_name();
|
||||
int i, n = proj_filename.size();
|
||||
int i, n = (int)proj_filename.size();
|
||||
for (i=0; i<n; i++) if (proj_filename[i]=='\\') proj_filename[i] = '/';
|
||||
Fl_Preferences build_records(Fl_Preferences::USER_L, "fltk.org", "fluid-build");
|
||||
Fl_Preferences path(build_records, proj_filename.c_str());
|
||||
|
||||
@@ -18,10 +18,10 @@
|
||||
#define _FLUID_CODE_H
|
||||
|
||||
#include <FL/fl_attr.h>
|
||||
#include "../src/Fl_String.H"
|
||||
|
||||
#include <stdarg.h>
|
||||
#include <stdio.h>
|
||||
#include <string>
|
||||
|
||||
class Fl_Type;
|
||||
struct Fd_Identifier_Tree;
|
||||
|
||||
@@ -20,7 +20,8 @@
|
||||
#include "fluid_filename.h"
|
||||
#include <FL/Fl_Preferences.H>
|
||||
#include <FL/Fl_Menu_Item.H>
|
||||
#include "../src/Fl_String.H"
|
||||
|
||||
#include <string>
|
||||
|
||||
#define BROWSERWIDTH 300
|
||||
#define BROWSERHEIGHT 500
|
||||
|
||||
@@ -30,12 +30,11 @@
|
||||
*/
|
||||
|
||||
#include <stdlib.h>
|
||||
#include <string>
|
||||
|
||||
#include <FL/filename.H>
|
||||
#include <FL/Fl.H>
|
||||
#include <FL/fl_string_functions.h>
|
||||
|
||||
#include "../src/Fl_String.H" // NOTE: FLTK 1.4.x only !
|
||||
#include "../src/flstring.h"
|
||||
|
||||
|
||||
@@ -187,7 +186,7 @@ std::string fl_filename_shortened(const std::string &filename, int max_chars) {
|
||||
static int home_chars = -1;
|
||||
if (home_chars==-1) {
|
||||
home = fl_filename_expand(tilde);
|
||||
home_chars = fl_utf_nb_char((const uchar*)home.c_str(), home.size());
|
||||
home_chars = fl_utf_nb_char((const uchar*)home.c_str(), (int)home.size());
|
||||
}
|
||||
std::string homed_filename;
|
||||
#if defined(_WIN32) || defined(__APPLE__)
|
||||
@@ -203,7 +202,7 @@ std::string fl_filename_shortened(const std::string &filename, int max_chars) {
|
||||
// C style pointer will stay valid until filename is modified.
|
||||
const unsigned char *u8str = reinterpret_cast<const unsigned char *>(homed_filename.c_str());
|
||||
// Count the number of UTF-8 characters in the name.
|
||||
int num_chars = fl_utf_nb_char(u8str, homed_filename.size());
|
||||
int num_chars = fl_utf_nb_char(u8str, (int)homed_filename.size());
|
||||
if (num_chars+ell_bytes-1 > max_chars) {
|
||||
// Create a new string by replacing characters in the middle.
|
||||
int remove_chars = num_chars - max_chars + ell_bytes;
|
||||
|
||||
@@ -39,7 +39,7 @@
|
||||
|
||||
# if defined(__cplusplus)
|
||||
|
||||
#include "../src/Fl_String.H"
|
||||
#include <string>
|
||||
|
||||
std::string fl_filename_shortened(const std::string &filename, int maxchars);
|
||||
std::string fl_filename_name(const std::string &filename);
|
||||
|
||||
@@ -22,9 +22,8 @@
|
||||
|
||||
#include <FL/fl_attr.h>
|
||||
|
||||
#include "../src/Fl_String.H"
|
||||
|
||||
#include <stdio.h>
|
||||
#include <string>
|
||||
|
||||
const int FD_TAG_GENERIC = 0;
|
||||
const int FD_TAG_CODE = 1;
|
||||
|
||||
@@ -364,7 +364,7 @@ void shell_pipe_cb(FL_SOCKET, void*) {
|
||||
|
||||
static void expand_macro(std::string &cmd, const std::string ¯o, const std::string &content) {
|
||||
for (int i=0;;) {
|
||||
i = cmd.find(macro, i);
|
||||
i = (int)cmd.find(macro, i);
|
||||
if (i==(int)std::string::npos) break;
|
||||
cmd.replace(i, macro.size(), content);
|
||||
}
|
||||
|
||||
@@ -19,11 +19,11 @@
|
||||
|
||||
#include "fluid.h"
|
||||
|
||||
#include "../src/Fl_String.H"
|
||||
#include <FL/Enumerations.H>
|
||||
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <string>
|
||||
#if defined(_WIN32) && !defined(__CYGWIN__)
|
||||
# include <direct.h>
|
||||
# include <windows.h>
|
||||
|
||||
@@ -52,7 +52,6 @@
|
||||
#include <FL/Fl_Pixmap.H>
|
||||
#include <FL/Fl_Menu_Item.H>
|
||||
#include "Fl_Int_Vector.H"
|
||||
#include "Fl_String.H"
|
||||
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
@@ -63,6 +62,7 @@
|
||||
#include <ctype.h>
|
||||
#include <errno.h>
|
||||
#include <math.h>
|
||||
#include <string>
|
||||
|
||||
#define MAX_COLUMNS 200
|
||||
|
||||
@@ -304,14 +304,14 @@ void Fl_Help_View::hv_draw(const char *t, int x, int y, int entity_extra_length)
|
||||
/* Note: Don't use Doxygen docs for this internal class.
|
||||
|
||||
Internal class to manage the Fl_Help_View edit buffer.
|
||||
This is a subclass of Fl_String since FLTK 1.4.0.
|
||||
This is a subclass of Fl_String since FLTK 1.4.0 and std::string since 1.5.0.
|
||||
|
||||
This class is for internal use in this file. Its sole purpose is to
|
||||
allow buffer management to avoid buffer overflows in stack variables
|
||||
used to edit strings for formatting and drawing (STR #3275).
|
||||
*/
|
||||
|
||||
class HV_Edit_Buffer : public Fl_String {
|
||||
class HV_Edit_Buffer : public std::string {
|
||||
public:
|
||||
// use default constructor and destructor, none defined here
|
||||
|
||||
@@ -1021,7 +1021,7 @@ Fl_Help_View::draw()
|
||||
if (qch < 0)
|
||||
buf += '&';
|
||||
else {
|
||||
int utf8l = buf.size();
|
||||
size_t utf8l = buf.size();
|
||||
buf.add(qch);
|
||||
utf8l = buf.size() - utf8l; // length of added UTF-8 text
|
||||
const char *oldptr = ptr;
|
||||
|
||||
@@ -24,7 +24,7 @@
|
||||
*/
|
||||
|
||||
#include <FL/Fl_Native_File_Chooser.H>
|
||||
#include "Fl_String.H"
|
||||
#include <string>
|
||||
|
||||
class Fl_Kdialog_Native_File_Chooser_Driver : public Fl_Native_File_Chooser_FLTK_Driver {
|
||||
friend class Fl_Native_File_Chooser;
|
||||
@@ -46,7 +46,7 @@ class Fl_Kdialog_Native_File_Chooser_Driver : public Fl_Native_File_Chooser_FLTK
|
||||
int count() const FL_OVERRIDE;
|
||||
const char *filename() const FL_OVERRIDE;
|
||||
const char *filename(int i) const FL_OVERRIDE;
|
||||
virtual void build_command(Fl_String& command);
|
||||
virtual void build_command(std::string& command);
|
||||
int show() FL_OVERRIDE;
|
||||
char *parse_filter(const char *f);
|
||||
const char *filter() const FL_OVERRIDE;
|
||||
@@ -58,7 +58,7 @@ class Fl_Kdialog_Native_File_Chooser_Driver : public Fl_Native_File_Chooser_FLTK
|
||||
const char *directory() const FL_OVERRIDE;
|
||||
void title(const char *val) FL_OVERRIDE;
|
||||
const char *title() const FL_OVERRIDE;
|
||||
void shell_quote(Fl_String& s);
|
||||
void shell_quote(std::string& s);
|
||||
};
|
||||
|
||||
/**
|
||||
|
||||
@@ -73,7 +73,7 @@ static int fnfc_dispatch(int /*event*/, Fl_Window* /*win*/) {
|
||||
}
|
||||
|
||||
|
||||
void Fl_Kdialog_Native_File_Chooser_Driver::build_command(Fl_String& command) {
|
||||
void Fl_Kdialog_Native_File_Chooser_Driver::build_command(std::string& command) {
|
||||
const char *option;
|
||||
switch (_btype) {
|
||||
case Fl_Native_File_Chooser::BROWSE_DIRECTORY:
|
||||
@@ -105,7 +105,7 @@ void Fl_Kdialog_Native_File_Chooser_Driver::build_command(Fl_String& command) {
|
||||
// Build command
|
||||
command = "kdialog";
|
||||
if (_title) {
|
||||
Fl_String quoted_title = _title; shell_quote(quoted_title);
|
||||
std::string quoted_title = _title; shell_quote(quoted_title);
|
||||
command += " --title ";
|
||||
command += quoted_title;
|
||||
}
|
||||
@@ -114,7 +114,7 @@ void Fl_Kdialog_Native_File_Chooser_Driver::build_command(Fl_String& command) {
|
||||
command += " ";
|
||||
command += preset;
|
||||
if (_parsedfilt) {
|
||||
Fl_String quoted_filt = _parsedfilt; shell_quote(quoted_filt); // NOTE: orig code used double quoting -erco 1/10/24
|
||||
std::string quoted_filt = _parsedfilt; shell_quote(quoted_filt); // NOTE: orig code used double quoting -erco 1/10/24
|
||||
command += " ";
|
||||
command += quoted_filt;
|
||||
}
|
||||
@@ -146,7 +146,7 @@ int Fl_Kdialog_Native_File_Chooser_Driver::show() {
|
||||
return retval;
|
||||
}
|
||||
|
||||
Fl_String command;
|
||||
std::string command;
|
||||
build_command(command);
|
||||
//fprintf(stderr, "DEBUG: POPEN: %s\n", command.c_str());
|
||||
FILE *pipe = popen(command.c_str(), "r");
|
||||
@@ -310,8 +310,8 @@ const char *Fl_Kdialog_Native_File_Chooser_Driver::title() const {
|
||||
// Add shell quotes around string 's'.
|
||||
// Handles quoting embedded quotes.
|
||||
//
|
||||
void Fl_Kdialog_Native_File_Chooser_Driver::shell_quote(Fl_String& s) {
|
||||
Fl_String out = "'"; // leading quote
|
||||
void Fl_Kdialog_Native_File_Chooser_Driver::shell_quote(std::string& s) {
|
||||
std::string out = "'"; // leading quote
|
||||
for (int t=0; t<(int)s.size(); t++) {
|
||||
if (s[t] == '\'') out += "'\"'\"'"; // quote any quotes
|
||||
else out += s[t];
|
||||
|
||||
@@ -30,8 +30,8 @@ class Fl_Zenity_Native_File_Chooser_Driver : public Fl_Kdialog_Native_File_Choos
|
||||
static bool did_find_zenity;
|
||||
static bool have_looked_for_zenity;
|
||||
Fl_Zenity_Native_File_Chooser_Driver(int val);
|
||||
void append_filter(Fl_String& command);
|
||||
void build_command(Fl_String& command) FL_OVERRIDE;
|
||||
void append_filter(std::string& command);
|
||||
void build_command(std::string& command) FL_OVERRIDE;
|
||||
};
|
||||
|
||||
/**
|
||||
|
||||
@@ -36,8 +36,8 @@ bool Fl_Zenity_Native_File_Chooser_Driver::have_looked_for_zenity = false;
|
||||
Fl_Zenity_Native_File_Chooser_Driver::Fl_Zenity_Native_File_Chooser_Driver(int val) : Fl_Kdialog_Native_File_Chooser_Driver(val) {
|
||||
}
|
||||
|
||||
void Fl_Zenity_Native_File_Chooser_Driver::append_filter(Fl_String& ret_command) {
|
||||
// TODO: This could probably be simplified + toughened with Fl_String -erco 1/10/24
|
||||
void Fl_Zenity_Native_File_Chooser_Driver::append_filter(std::string& ret_command) {
|
||||
// TODO: This could probably be simplified + toughened with std::string -erco 1/10/24
|
||||
int l;
|
||||
int lcommand = 10000;
|
||||
char *command = new char[lcommand];
|
||||
@@ -72,11 +72,11 @@ void Fl_Zenity_Native_File_Chooser_Driver::append_filter(Fl_String& ret_command)
|
||||
p = strtok(NULL, "\n");
|
||||
}
|
||||
free(parsed_filter_copy);
|
||||
ret_command += command; // append to parent's Fl_String
|
||||
ret_command += command; // append to parent's std::string
|
||||
delete [] command;
|
||||
}
|
||||
|
||||
void Fl_Zenity_Native_File_Chooser_Driver::build_command(Fl_String& command) {
|
||||
void Fl_Zenity_Native_File_Chooser_Driver::build_command(std::string& command) {
|
||||
const char *option;
|
||||
switch (_btype) {
|
||||
case Fl_Native_File_Chooser::BROWSE_DIRECTORY:
|
||||
@@ -100,14 +100,14 @@ void Fl_Zenity_Native_File_Chooser_Driver::build_command(Fl_String& command) {
|
||||
}
|
||||
|
||||
// Build preset
|
||||
Fl_String preset;
|
||||
std::string preset;
|
||||
if (_preset_file) {
|
||||
Fl_String quoted_filename = _preset_file; shell_quote(quoted_filename);
|
||||
std::string quoted_filename = _preset_file; shell_quote(quoted_filename);
|
||||
preset = "--filename=";
|
||||
preset += quoted_filename;
|
||||
} else if (_directory) {
|
||||
// This doesn't actually seem to do anything, but supply it anyway.
|
||||
Fl_String quoted_dir = _directory; shell_quote(quoted_dir);
|
||||
std::string quoted_dir = _directory; shell_quote(quoted_dir);
|
||||
preset = "--filename=";
|
||||
preset += quoted_dir;
|
||||
}
|
||||
@@ -115,7 +115,7 @@ void Fl_Zenity_Native_File_Chooser_Driver::build_command(Fl_String& command) {
|
||||
// Build command
|
||||
command = "zenity";
|
||||
if (_title) {
|
||||
Fl_String quoted_title = _title; shell_quote(quoted_title);
|
||||
std::string quoted_title = _title; shell_quote(quoted_title);
|
||||
command += " --title ";
|
||||
command += quoted_title;
|
||||
}
|
||||
|
||||
@@ -29,13 +29,13 @@
|
||||
#include <string.h> // strlen
|
||||
#include <stdarg.h> // vprintf, va_list
|
||||
#include <assert.h>
|
||||
#include <string>
|
||||
|
||||
#include <FL/Fl.H>
|
||||
#include <FL/Fl_Terminal.H>
|
||||
#include <FL/fl_utf8.h> // fl_utf8len1
|
||||
#include <FL/fl_draw.H>
|
||||
#include <FL/fl_string_functions.h>
|
||||
#include "Fl_String.H"
|
||||
|
||||
/////////////////////////////////
|
||||
////// Static Functions /////////
|
||||
@@ -3948,7 +3948,7 @@ int Fl_Terminal::handle(int e) {
|
||||
\return A string allocated with strdup(3) which must be free'd, text is UTF-8.
|
||||
*/
|
||||
const char* Fl_Terminal::text(bool lines_below_cursor) const {
|
||||
Fl_String lines; // lines of text we'll return
|
||||
std::string lines; // lines of text we'll return
|
||||
// See how many display rows we need to include
|
||||
int disprows = lines_below_cursor ? disp_rows() - 1 // all display lines
|
||||
: cursor_row(); // only lines up to cursor
|
||||
|
||||
@@ -21,7 +21,6 @@
|
||||
#include <FL/fl_string_functions.h> // fl_strdup
|
||||
#include <FL/platform.H>
|
||||
#include "../../flstring.h"
|
||||
#include "../../Fl_String.H"
|
||||
#include "../../Fl_Timeout.h"
|
||||
|
||||
#include <locale.h>
|
||||
@@ -31,6 +30,7 @@
|
||||
#include <pwd.h>
|
||||
#include <string.h> // strerror(errno)
|
||||
#include <errno.h> // errno
|
||||
#include <string>
|
||||
#if HAVE_DLSYM && HAVE_DLFCN_H
|
||||
#include <dlfcn.h> // for dlsym
|
||||
#endif
|
||||
@@ -538,7 +538,7 @@ char *Fl_Unix_System_Driver::preference_user_rootnode(
|
||||
char *buffer)
|
||||
{
|
||||
// Find the path to the user's home directory.
|
||||
Fl_String home_path = getenv("HOME");
|
||||
std::string home_path = getenv("HOME");
|
||||
if (home_path.empty()) {
|
||||
struct passwd *pw = getpwuid(getuid());
|
||||
if (pw)
|
||||
@@ -546,7 +546,7 @@ char *Fl_Unix_System_Driver::preference_user_rootnode(
|
||||
}
|
||||
|
||||
// 1: Generate the 1.4 path for this vendor and application.
|
||||
Fl_String prefs_path_14 = getenv("XDG_CONFIG_HOME");
|
||||
std::string prefs_path_14 = getenv("XDG_CONFIG_HOME");
|
||||
if (prefs_path_14.empty()) {
|
||||
prefs_path_14 = home_path + "/.config";
|
||||
} else {
|
||||
@@ -567,7 +567,7 @@ char *Fl_Unix_System_Driver::preference_user_rootnode(
|
||||
|
||||
// 2: If this base path does not exist, try the 1.3 path
|
||||
if (::access(prefs_path_14.c_str(), F_OK) == -1) {
|
||||
Fl_String prefs_path_13 = home_path + "/.fltk/" + vendor;
|
||||
std::string prefs_path_13 = home_path + "/.fltk/" + vendor;
|
||||
if (::access(prefs_path_13.c_str(), F_OK) == 0) {
|
||||
prefs_path_13.append("/");
|
||||
prefs_path_13.append(application);
|
||||
|
||||
@@ -19,72 +19,25 @@
|
||||
#include <FL/Fl_Group.H>
|
||||
#include <FL/Fl_Button.H>
|
||||
#include <FL/Fl_Terminal.H>
|
||||
#include "../src/Fl_String.H"
|
||||
#include <FL/Fl_Preferences.H>
|
||||
#include <FL/fl_callback_macros.H>
|
||||
#include <FL/filename.H>
|
||||
#include <FL/fl_utf8.h>
|
||||
|
||||
#if (0) // FIXME - Fl_String
|
||||
#include <string>
|
||||
|
||||
/* Test all Fl_String functions that are no part of the class. */
|
||||
TEST(Fl_String, Non-Member Functions) {
|
||||
Fl_String a = "a", b = "b", empty = "", result;
|
||||
result = a + b;
|
||||
EXPECT_STREQ(result.c_str(), "ab");
|
||||
result = a + empty;
|
||||
EXPECT_STREQ(result.c_str(), "a");
|
||||
result = a + "c";
|
||||
EXPECT_STREQ(result.c_str(), "ac");
|
||||
result = empty + "x";
|
||||
EXPECT_STREQ(result.c_str(), "x");
|
||||
EXPECT_TRUE(!(a == b));
|
||||
EXPECT_TRUE(a == a);
|
||||
EXPECT_FALSE((a != a)); // neq -erco
|
||||
EXPECT_TRUE((a != b)); // neq -erco
|
||||
EXPECT_TRUE(empty == empty);
|
||||
EXPECT_TRUE(a+b == "ab");
|
||||
EXPECT_TRUE(a+"b" == "a" + b);
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
/* Test additions to Fl_Preferences. */
|
||||
TEST(Fl_String, fl_filename_...) {
|
||||
const Fl_String ref = "/test/me.txt";
|
||||
Fl_String name = fl_filename_name(ref);
|
||||
EXPECT_STREQ(name.c_str(), "me.txt");
|
||||
name = fl_filename_name(Fl_String("/test/"));
|
||||
EXPECT_STREQ(name.c_str(), "");
|
||||
Fl_String path = fl_filename_path(ref);
|
||||
EXPECT_STREQ(path.c_str(), "/test/");
|
||||
Fl_String ext = fl_filename_ext(ref);
|
||||
EXPECT_STREQ(ext.c_str(), ".txt");
|
||||
ext = fl_filename_setext(ref, ".rtf");
|
||||
EXPECT_STREQ(ext.c_str(), "/test/me.rtf");
|
||||
fl_putenv("FL_UNITTEST=unit/test");
|
||||
name = fl_filename_expand(Fl_String("abc/$FL_UNITTEST/xyz"));
|
||||
EXPECT_STREQ(name.c_str(), "abc/unit/test/xyz");
|
||||
Fl_String abs = fl_filename_absolute(Fl_String("./abc/def.txt"));
|
||||
Fl_String rel = fl_filename_relative(abs);
|
||||
EXPECT_STREQ(rel.c_str(), "abc/def.txt");
|
||||
EXPECT_STREQ(ref.c_str(), "/test/me.txt");
|
||||
return true;
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
/* Test additions to Fl_Preferences. */
|
||||
TEST(Fl_Preferences, Strings) {
|
||||
{
|
||||
Fl_Preferences prefs(Fl_Preferences::USER_L, "fltk.org", "unittests");
|
||||
prefs.set("a", Fl_String());
|
||||
prefs.set("b", Fl_String("Hello"));
|
||||
prefs.set("c", Fl_String("Hel\\l\nö"));
|
||||
prefs.set("a", std::string());
|
||||
prefs.set("b", std::string("Hello"));
|
||||
prefs.set("c", std::string("Hel\\l\nö"));
|
||||
}
|
||||
{
|
||||
Fl_Preferences prefs(Fl_Preferences::USER_L, "fltk.org", "unittests");
|
||||
Fl_String r;
|
||||
std::string r;
|
||||
prefs.get("a", r, "x");
|
||||
EXPECT_STREQ(r.c_str(), "");
|
||||
prefs.get("b", r, "x");
|
||||
@@ -100,7 +53,7 @@ TEST(Fl_Preferences, Strings) {
|
||||
#if 0
|
||||
|
||||
TEST(fl_filename, ext) {
|
||||
Fl_String r = fl_filename_ext("test.txt");
|
||||
std::string r = fl_filename_ext("test.txt");
|
||||
EXPECT_STREQ(r.c_str(), ".txt");
|
||||
r = fl_filename_ext("test");
|
||||
EXPECT_STREQ(r.c_str(), "");
|
||||
@@ -110,22 +63,22 @@ TEST(fl_filename, ext) {
|
||||
}
|
||||
|
||||
TEST(fl_filename, setext) {
|
||||
Fl_String r = fl_filename_setext(Fl_String("test.txt"), ".rtf");
|
||||
std::string r = fl_filename_setext(std::string("test.txt"), ".rtf");
|
||||
EXPECT_STREQ(r.c_str(), "test.rtf");
|
||||
r = fl_filename_setext(Fl_String("test"), ".rtf");
|
||||
r = fl_filename_setext(std::string("test"), ".rtf");
|
||||
EXPECT_STREQ(r.c_str(), "test.rtf");
|
||||
r = fl_filename_setext(Fl_String("test.txt"), "");
|
||||
r = fl_filename_setext(std::string("test.txt"), "");
|
||||
EXPECT_STREQ(r.c_str(), "test");
|
||||
r = fl_filename_setext(Fl_String(""), ".rtf");
|
||||
r = fl_filename_setext(std::string(""), ".rtf");
|
||||
EXPECT_STREQ(r.c_str(), ".rtf");
|
||||
r = fl_filename_setext(Fl_String("path/test"), ".rtf");
|
||||
r = fl_filename_setext(std::string("path/test"), ".rtf");
|
||||
EXPECT_STREQ(r.c_str(), "path/test.rtf");
|
||||
return true;
|
||||
}
|
||||
|
||||
TEST(fl_filename, relative) {
|
||||
Fl_String base = "/var/tmp/somedir";
|
||||
Fl_String r = fl_filename_relative("/var/tmp/somedir/foo.txt", base);
|
||||
std::string base = "/var/tmp/somedir";
|
||||
std::string r = fl_filename_relative("/var/tmp/somedir/foo.txt", base);
|
||||
EXPECT_STREQ(r.c_str(), "foo.txt");
|
||||
r = fl_filename_relative("/var/tmp/foo.txt", base);
|
||||
EXPECT_STREQ(r.c_str(), "../foo.txt");
|
||||
@@ -137,8 +90,8 @@ TEST(fl_filename, relative) {
|
||||
}
|
||||
|
||||
TEST(fl_filename, absolute) {
|
||||
Fl_String base = "/var/tmp/somedir";
|
||||
Fl_String r = fl_filename_absolute("foo.txt", base);
|
||||
std::string base = "/var/tmp/somedir";
|
||||
std::string r = fl_filename_absolute("foo.txt", base);
|
||||
EXPECT_STREQ(r.c_str(), "/var/tmp/somedir/foo.txt");
|
||||
r = fl_filename_absolute("/var/tmp/foo.txt", base);
|
||||
EXPECT_STREQ(r.c_str(), "/var/tmp/foo.txt");
|
||||
@@ -152,11 +105,11 @@ TEST(fl_filename, absolute) {
|
||||
|
||||
bool cb1a_ok = false, cb1b_ok = false, cb1c_ok = false;
|
||||
int cb1_alloc = 0;
|
||||
class MyString : public Fl_String {
|
||||
class MyString : public std::string {
|
||||
public:
|
||||
MyString() : Fl_String() { cb1_alloc++; }
|
||||
MyString(const MyString &str) : Fl_String(str) { cb1_alloc++; }
|
||||
MyString(const char *t) : Fl_String(t) { cb1_alloc++; }
|
||||
MyString() : std::string() { cb1_alloc++; }
|
||||
MyString(const MyString &str) : std::string(str) { cb1_alloc++; }
|
||||
MyString(const char *t) : std::string(t) { cb1_alloc++; }
|
||||
~MyString() { cb1_alloc--; }
|
||||
};
|
||||
void cb1(MyString a, int b) {
|
||||
@@ -187,9 +140,9 @@ TEST(Fl_Callback_Macros, FL_FUNCTION_CALLBACK) {
|
||||
|
||||
TEST(Fl_Callback_Macros, FL_METHOD_CALLBACK) {
|
||||
Fl_Group::current(NULL);
|
||||
Fl_String *str = new Fl_String("FLTK");
|
||||
std::string *str = new std::string("FLTK");
|
||||
Fl_Button *btn = new Fl_Button(10, 10, 100, 100);
|
||||
FL_METHOD_CALLBACK_2(btn, Fl_String, str, insert, int, 2, const char*, "XX");
|
||||
FL_METHOD_CALLBACK_2(btn, std::string, str, insert, int, 2, const char*, "XX");
|
||||
btn->do_callback();
|
||||
EXPECT_STREQ(str->c_str(), "FLXXTK");
|
||||
delete btn;
|
||||
|
||||
Reference in New Issue
Block a user