mirror of
https://github.com/aseprite/aseprite.git
synced 2024-10-03 21:46:20 +00:00
Remove base::string (std::string is good enough for utf8 strings)
This commit is contained in:
parent
3322396357
commit
b33357ed46
@ -145,9 +145,9 @@ App::App(int argc, const char* argv[])
|
|||||||
RenderEngine::loadConfig();
|
RenderEngine::loadConfig();
|
||||||
|
|
||||||
// Default palette.
|
// Default palette.
|
||||||
base::string palFile(!options.paletteFileName().empty() ?
|
std::string palFile(!options.paletteFileName().empty() ?
|
||||||
options.paletteFileName():
|
options.paletteFileName():
|
||||||
base::string(get_config_string("GfxMode", "Palette", "")));
|
std::string(get_config_string("GfxMode", "Palette", "")));
|
||||||
|
|
||||||
if (palFile.empty()) {
|
if (palFile.empty()) {
|
||||||
// Try to use a default pixel art palette.
|
// Try to use a default pixel art palette.
|
||||||
|
@ -26,6 +26,7 @@
|
|||||||
#include "base/unique_ptr.h"
|
#include "base/unique_ptr.h"
|
||||||
#include "raster/pixel_format.h"
|
#include "raster/pixel_format.h"
|
||||||
|
|
||||||
|
#include <string>
|
||||||
#include <vector>
|
#include <vector>
|
||||||
|
|
||||||
namespace ui {
|
namespace ui {
|
||||||
@ -80,7 +81,7 @@ namespace app {
|
|||||||
Signal0<void> CurrentToolChange;
|
Signal0<void> CurrentToolChange;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
typedef std::vector<base::string> FileList;
|
typedef std::vector<std::string> FileList;
|
||||||
class Modules;
|
class Modules;
|
||||||
|
|
||||||
static App* m_instance;
|
static App* m_instance;
|
||||||
|
@ -24,7 +24,7 @@
|
|||||||
|
|
||||||
namespace app {
|
namespace app {
|
||||||
|
|
||||||
Backup::Backup(const base::string& path)
|
Backup::Backup(const std::string& path)
|
||||||
: m_path(path)
|
: m_path(path)
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
@ -21,14 +21,15 @@
|
|||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
#include "base/disable_copying.h"
|
#include "base/disable_copying.h"
|
||||||
#include "base/string.h"
|
|
||||||
|
#include <string>
|
||||||
|
|
||||||
namespace app {
|
namespace app {
|
||||||
|
|
||||||
// A class to record/restore backup information.
|
// A class to record/restore backup information.
|
||||||
class Backup {
|
class Backup {
|
||||||
public:
|
public:
|
||||||
Backup(const base::string& path);
|
Backup(const std::string& path);
|
||||||
~Backup();
|
~Backup();
|
||||||
|
|
||||||
// Returns true if there are items that can be restored.
|
// Returns true if there are items that can be restored.
|
||||||
@ -37,7 +38,7 @@ namespace app {
|
|||||||
private:
|
private:
|
||||||
DISABLE_COPYING(Backup);
|
DISABLE_COPYING(Backup);
|
||||||
|
|
||||||
base::string m_path;
|
std::string m_path;
|
||||||
};
|
};
|
||||||
|
|
||||||
} // namespace app
|
} // namespace app
|
||||||
|
@ -73,7 +73,7 @@ void DuplicateSpriteCommand::onExecute(Context* context)
|
|||||||
dst_name = window->findChild("dst_name");
|
dst_name = window->findChild("dst_name");
|
||||||
flatten = window->findChild("flatten");
|
flatten = window->findChild("flatten");
|
||||||
|
|
||||||
base::string fn = document->getFilename();
|
std::string fn = document->getFilename();
|
||||||
src_name->setText(base::get_file_name(fn));
|
src_name->setText(base::get_file_name(fn));
|
||||||
dst_name->setText(base::get_file_title(fn) + " Copy." + base::get_file_extension(fn));
|
dst_name->setText(base::get_file_title(fn) + " Copy." + base::get_file_extension(fn));
|
||||||
|
|
||||||
|
@ -70,7 +70,7 @@ void LoadMaskCommand::onExecute(Context* context)
|
|||||||
{
|
{
|
||||||
const ContextReader reader(context);
|
const ContextReader reader(context);
|
||||||
|
|
||||||
base::string filename = m_filename;
|
std::string filename = m_filename;
|
||||||
|
|
||||||
if (context->isUiAvailable()) {
|
if (context->isUiAvailable()) {
|
||||||
filename = app::show_file_selector("Load .msk File", filename, "msk");
|
filename = app::show_file_selector("Load .msk File", filename, "msk");
|
||||||
|
@ -52,7 +52,7 @@ LoadPaletteCommand::LoadPaletteCommand()
|
|||||||
|
|
||||||
void LoadPaletteCommand::onExecute(Context* context)
|
void LoadPaletteCommand::onExecute(Context* context)
|
||||||
{
|
{
|
||||||
base::string filename = app::show_file_selector("Load Palette", "", "png,pcx,bmp,tga,lbm,col,gpl");
|
std::string filename = app::show_file_selector("Load Palette", "", "png,pcx,bmp,tga,lbm,col,gpl");
|
||||||
if (!filename.empty()) {
|
if (!filename.empty()) {
|
||||||
base::UniquePtr<raster::Palette> palette(raster::Palette::load(filename.c_str()));
|
base::UniquePtr<raster::Palette> palette(raster::Palette::load(filename.c_str()));
|
||||||
if (!palette) {
|
if (!palette) {
|
||||||
|
@ -122,7 +122,7 @@ protected:
|
|||||||
void saveAsDialog(const ContextReader& reader, const char* dlgTitle, bool markAsSaved)
|
void saveAsDialog(const ContextReader& reader, const char* dlgTitle, bool markAsSaved)
|
||||||
{
|
{
|
||||||
const Document* document = reader.document();
|
const Document* document = reader.document();
|
||||||
base::string filename;
|
std::string filename;
|
||||||
|
|
||||||
if (!m_filename.empty()) {
|
if (!m_filename.empty()) {
|
||||||
filename = m_filename;
|
filename = m_filename;
|
||||||
@ -134,7 +134,7 @@ protected:
|
|||||||
get_writable_extensions(exts, sizeof(exts));
|
get_writable_extensions(exts, sizeof(exts));
|
||||||
|
|
||||||
for (;;) {
|
for (;;) {
|
||||||
base::string newfilename = app::show_file_selector(dlgTitle, filename, exts);
|
std::string newfilename = app::show_file_selector(dlgTitle, filename, exts);
|
||||||
if (newfilename.empty())
|
if (newfilename.empty())
|
||||||
return;
|
return;
|
||||||
|
|
||||||
@ -283,7 +283,7 @@ void SaveFileCopyAsCommand::onExecute(Context* context)
|
|||||||
{
|
{
|
||||||
const ContextReader reader(context);
|
const ContextReader reader(context);
|
||||||
const Document* document(reader.document());
|
const Document* document(reader.document());
|
||||||
base::string old_filename = document->getFilename();
|
std::string old_filename = document->getFilename();
|
||||||
|
|
||||||
// show "Save As" dialog
|
// show "Save As" dialog
|
||||||
saveAsDialog(reader, "Save Copy As", false);
|
saveAsDialog(reader, "Save Copy As", false);
|
||||||
|
@ -58,7 +58,7 @@ void SaveMaskCommand::onExecute(Context* context)
|
|||||||
{
|
{
|
||||||
const ContextReader reader(context);
|
const ContextReader reader(context);
|
||||||
const Document* document(reader.document());
|
const Document* document(reader.document());
|
||||||
base::string filename = "default.msk";
|
std::string filename = "default.msk";
|
||||||
int ret;
|
int ret;
|
||||||
|
|
||||||
for (;;) {
|
for (;;) {
|
||||||
|
@ -51,7 +51,7 @@ SavePaletteCommand::SavePaletteCommand()
|
|||||||
|
|
||||||
void SavePaletteCommand::onExecute(Context* context)
|
void SavePaletteCommand::onExecute(Context* context)
|
||||||
{
|
{
|
||||||
base::string filename;
|
std::string filename;
|
||||||
int ret;
|
int ret;
|
||||||
|
|
||||||
again:
|
again:
|
||||||
|
@ -67,7 +67,7 @@ bool SpritePropertiesCommand::onEnabled(Context* context)
|
|||||||
void SpritePropertiesCommand::onExecute(Context* context)
|
void SpritePropertiesCommand::onExecute(Context* context)
|
||||||
{
|
{
|
||||||
Widget* name, *type, *size, *frames, *ok, *box_transparent;
|
Widget* name, *type, *size, *frames, *ok, *box_transparent;
|
||||||
base::string imgtype_text;
|
std::string imgtype_text;
|
||||||
char buf[256];
|
char buf[256];
|
||||||
ColorButton* color_button = NULL;
|
ColorButton* color_button = NULL;
|
||||||
|
|
||||||
|
@ -138,7 +138,7 @@ void Console::printf(const char* format, ...)
|
|||||||
|
|
||||||
const std::string& text = wid_textbox->getText();
|
const std::string& text = wid_textbox->getText();
|
||||||
|
|
||||||
base::string final;
|
std::string final;
|
||||||
if (!text.empty())
|
if (!text.empty())
|
||||||
final += text;
|
final += text;
|
||||||
final += buf;
|
final += buf;
|
||||||
|
@ -39,7 +39,7 @@ DataRecovery::DataRecovery(Context* context)
|
|||||||
, m_context(context)
|
, m_context(context)
|
||||||
{
|
{
|
||||||
// Check if there is already data to recover
|
// Check if there is already data to recover
|
||||||
const base::string existent_data_path = get_config_string("DataRecovery", "Path", "");
|
const std::string existent_data_path = get_config_string("DataRecovery", "Path", "");
|
||||||
if (!existent_data_path.empty() &&
|
if (!existent_data_path.empty() &&
|
||||||
base::is_directory(existent_data_path)) {
|
base::is_directory(existent_data_path)) {
|
||||||
// Load the backup data.
|
// Load the backup data.
|
||||||
|
@ -189,7 +189,7 @@ void Document::notifyCelCopied(Layer* fromLayer, FrameNumber fromFrame, Layer* t
|
|||||||
notifyObservers<DocumentEvent&>(&DocumentObserver::onCelCopied, ev);
|
notifyObservers<DocumentEvent&>(&DocumentObserver::onCelCopied, ev);
|
||||||
}
|
}
|
||||||
|
|
||||||
void Document::setFilename(const base::string& filename)
|
void Document::setFilename(const std::string& filename)
|
||||||
{
|
{
|
||||||
m_document.setFilename(filename);
|
m_document.setFilename(filename);
|
||||||
}
|
}
|
||||||
|
@ -24,13 +24,14 @@
|
|||||||
#include "base/disable_copying.h"
|
#include "base/disable_copying.h"
|
||||||
#include "base/observable.h"
|
#include "base/observable.h"
|
||||||
#include "base/shared_ptr.h"
|
#include "base/shared_ptr.h"
|
||||||
#include "base/string.h"
|
|
||||||
#include "base/unique_ptr.h"
|
#include "base/unique_ptr.h"
|
||||||
#include "doc/document.h"
|
#include "doc/document.h"
|
||||||
#include "gfx/transformation.h"
|
#include "gfx/transformation.h"
|
||||||
#include "raster/frame_number.h"
|
#include "raster/frame_number.h"
|
||||||
#include "raster/pixel_format.h"
|
#include "raster/pixel_format.h"
|
||||||
|
|
||||||
|
#include <string>
|
||||||
|
|
||||||
namespace base {
|
namespace base {
|
||||||
class mutex;
|
class mutex;
|
||||||
}
|
}
|
||||||
@ -122,8 +123,8 @@ namespace app {
|
|||||||
//////////////////////////////////////////////////////////////////////
|
//////////////////////////////////////////////////////////////////////
|
||||||
// File related properties
|
// File related properties
|
||||||
|
|
||||||
const base::string& getFilename() const { return m_document.filename(); }
|
const std::string& getFilename() const { return m_document.filename(); }
|
||||||
void setFilename(const base::string& filename);
|
void setFilename(const std::string& filename);
|
||||||
|
|
||||||
bool isModified() const;
|
bool isModified() const;
|
||||||
bool isAssociatedToFile() const;
|
bool isAssociatedToFile() const;
|
||||||
|
@ -194,7 +194,7 @@ void DocumentExporter::captureSamples(Samples& samples)
|
|||||||
|
|
||||||
for (FrameNumber frame=FrameNumber(0);
|
for (FrameNumber frame=FrameNumber(0);
|
||||||
frame<sprite->getTotalFrames(); ++frame) {
|
frame<sprite->getTotalFrames(); ++frame) {
|
||||||
base::string filename = document->getFilename();
|
std::string filename = document->getFilename();
|
||||||
|
|
||||||
if (sprite->getTotalFrames() > FrameNumber(1)) {
|
if (sprite->getTotalFrames() > FrameNumber(1)) {
|
||||||
int frameNumWidth =
|
int frameNumWidth =
|
||||||
@ -203,9 +203,9 @@ void DocumentExporter::captureSamples(Samples& samples)
|
|||||||
(sprite->getTotalFrames() < 1000)? 3: 4;
|
(sprite->getTotalFrames() < 1000)? 3: 4;
|
||||||
std::sprintf(&buf[0], "%0*d", frameNumWidth, (int)frame);
|
std::sprintf(&buf[0], "%0*d", frameNumWidth, (int)frame);
|
||||||
|
|
||||||
base::string path = base::get_file_path(filename);
|
std::string path = base::get_file_path(filename);
|
||||||
base::string title = base::get_file_title(filename);
|
std::string title = base::get_file_title(filename);
|
||||||
base::string ext = base::get_file_extension(filename);
|
std::string ext = base::get_file_extension(filename);
|
||||||
filename = base::join_path(path, title + &buf[0] + "." + ext);
|
filename = base::join_path(path, title + &buf[0] + "." + ext);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -147,7 +147,7 @@ FileOp* fop_to_load_document(const char* filename, int flags)
|
|||||||
return NULL;
|
return NULL;
|
||||||
|
|
||||||
// Get the extension of the filename (in lower case)
|
// Get the extension of the filename (in lower case)
|
||||||
base::string extension = base::string_to_lower(base::get_file_extension(filename));
|
std::string extension = base::string_to_lower(base::get_file_extension(filename));
|
||||||
|
|
||||||
PRINTF("Loading file \"%s\" (%s)\n", filename, extension.c_str());
|
PRINTF("Loading file \"%s\" (%s)\n", filename, extension.c_str());
|
||||||
|
|
||||||
@ -244,7 +244,7 @@ FileOp* fop_to_save_document(Document* document)
|
|||||||
fop->document = document;
|
fop->document = document;
|
||||||
|
|
||||||
// Get the extension of the filename (in lower case)
|
// Get the extension of the filename (in lower case)
|
||||||
base::string extension = base::string_to_lower(base::get_file_extension(fop->document->getFilename()));
|
std::string extension = base::string_to_lower(base::get_file_extension(fop->document->getFilename()));
|
||||||
|
|
||||||
PRINTF("Saving document \"%s\" (%s)\n",
|
PRINTF("Saving document \"%s\" (%s)\n",
|
||||||
fop->document->getFilename().c_str(), extension.c_str());
|
fop->document->getFilename().c_str(), extension.c_str());
|
||||||
@ -258,7 +258,7 @@ FileOp* fop_to_save_document(Document* document)
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Warnings
|
// Warnings
|
||||||
base::string warnings;
|
std::string warnings;
|
||||||
fatal = false;
|
fatal = false;
|
||||||
|
|
||||||
/* check image type support */
|
/* check image type support */
|
||||||
|
@ -24,9 +24,9 @@
|
|||||||
|
|
||||||
namespace app {
|
namespace app {
|
||||||
|
|
||||||
base::string show_file_selector(const base::string& title,
|
std::string show_file_selector(const std::string& title,
|
||||||
const base::string& initialPath,
|
const std::string& initialPath,
|
||||||
const base::string& showExtensions)
|
const std::string& showExtensions)
|
||||||
{
|
{
|
||||||
FileSelector fileSelector;
|
FileSelector fileSelector;
|
||||||
return fileSelector.show(title, initialPath, showExtensions);
|
return fileSelector.show(title, initialPath, showExtensions);
|
||||||
|
@ -20,13 +20,13 @@
|
|||||||
#define APP_FILE_SELECTOR_H_INCLUDED
|
#define APP_FILE_SELECTOR_H_INCLUDED
|
||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
#include "base/string.h"
|
#include <string>
|
||||||
|
|
||||||
namespace app {
|
namespace app {
|
||||||
|
|
||||||
base::string show_file_selector(const base::string& title,
|
std::string show_file_selector(const std::string& title,
|
||||||
const base::string& initialPath,
|
const std::string& initialPath,
|
||||||
const base::string& showExtensions);
|
const std::string& showExtensions);
|
||||||
|
|
||||||
} // namespace app
|
} // namespace app
|
||||||
|
|
||||||
|
@ -105,9 +105,9 @@ namespace app {
|
|||||||
// a position in the file-system
|
// a position in the file-system
|
||||||
class FileItem : public IFileItem {
|
class FileItem : public IFileItem {
|
||||||
public:
|
public:
|
||||||
base::string keyname;
|
std::string keyname;
|
||||||
base::string filename;
|
std::string filename;
|
||||||
base::string displayname;
|
std::string displayname;
|
||||||
FileItem* parent;
|
FileItem* parent;
|
||||||
FileItemList children;
|
FileItemList children;
|
||||||
unsigned int version;
|
unsigned int version;
|
||||||
@ -138,22 +138,22 @@ public:
|
|||||||
bool isFolder() const;
|
bool isFolder() const;
|
||||||
bool isBrowsable() const;
|
bool isBrowsable() const;
|
||||||
|
|
||||||
base::string getKeyName() const;
|
std::string getKeyName() const;
|
||||||
base::string getFileName() const;
|
std::string getFileName() const;
|
||||||
base::string getDisplayName() const;
|
std::string getDisplayName() const;
|
||||||
|
|
||||||
IFileItem* getParent() const;
|
IFileItem* getParent() const;
|
||||||
const FileItemList& getChildren();
|
const FileItemList& getChildren();
|
||||||
|
|
||||||
bool hasExtension(const base::string& csv_extensions);
|
bool hasExtension(const std::string& csv_extensions);
|
||||||
|
|
||||||
BITMAP* getThumbnail();
|
BITMAP* getThumbnail();
|
||||||
void setThumbnail(BITMAP* thumbnail);
|
void setThumbnail(BITMAP* thumbnail);
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
typedef std::map<base::string, FileItem*> FileItemMap;
|
typedef std::map<std::string, FileItem*> FileItemMap;
|
||||||
typedef std::map<base::string, BITMAP*> ThumbnailMap;
|
typedef std::map<std::string, BITMAP*> ThumbnailMap;
|
||||||
|
|
||||||
// the root of the file-system
|
// the root of the file-system
|
||||||
static FileItem* rootitem = NULL;
|
static FileItem* rootitem = NULL;
|
||||||
@ -180,15 +180,15 @@ static unsigned int current_file_system_version = 0;
|
|||||||
static LPITEMIDLIST clone_pidl(LPITEMIDLIST pidl);
|
static LPITEMIDLIST clone_pidl(LPITEMIDLIST pidl);
|
||||||
static LPITEMIDLIST remove_last_pidl(LPITEMIDLIST pidl);
|
static LPITEMIDLIST remove_last_pidl(LPITEMIDLIST pidl);
|
||||||
static void free_pidl(LPITEMIDLIST pidl);
|
static void free_pidl(LPITEMIDLIST pidl);
|
||||||
static base::string get_key_for_pidl(LPITEMIDLIST pidl);
|
static std::string get_key_for_pidl(LPITEMIDLIST pidl);
|
||||||
|
|
||||||
static FileItem* get_fileitem_by_fullpidl(LPITEMIDLIST pidl, bool create_if_not);
|
static FileItem* get_fileitem_by_fullpidl(LPITEMIDLIST pidl, bool create_if_not);
|
||||||
static void put_fileitem(FileItem* fileitem);
|
static void put_fileitem(FileItem* fileitem);
|
||||||
#else
|
#else
|
||||||
static FileItem* get_fileitem_by_path(const base::string& path, bool create_if_not);
|
static FileItem* get_fileitem_by_path(const std::string& path, bool create_if_not);
|
||||||
static void for_each_child_callback(const char *filename, int attrib, int param);
|
static void for_each_child_callback(const char *filename, int attrib, int param);
|
||||||
static base::string remove_backslash_if_needed(const base::string& filename);
|
static std::string remove_backslash_if_needed(const std::string& filename);
|
||||||
static base::string get_key_for_filename(const base::string& filename);
|
static std::string get_key_for_filename(const std::string& filename);
|
||||||
static void put_fileitem(FileItem* fileitem);
|
static void put_fileitem(FileItem* fileitem);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
@ -317,7 +317,7 @@ IFileItem* FileSystemModule::getRootFileItem()
|
|||||||
return fileitem;
|
return fileitem;
|
||||||
}
|
}
|
||||||
|
|
||||||
IFileItem* FileSystemModule::getFileItemFromPath(const base::string& path)
|
IFileItem* FileSystemModule::getFileItemFromPath(const std::string& path)
|
||||||
{
|
{
|
||||||
IFileItem* fileitem = NULL;
|
IFileItem* fileitem = NULL;
|
||||||
|
|
||||||
@ -348,7 +348,7 @@ IFileItem* FileSystemModule::getFileItemFromPath(const base::string& path)
|
|||||||
}
|
}
|
||||||
#else
|
#else
|
||||||
{
|
{
|
||||||
base::string buf = remove_backslash_if_needed(path);
|
std::string buf = remove_backslash_if_needed(path);
|
||||||
fileitem = get_fileitem_by_path(buf, true);
|
fileitem = get_fileitem_by_path(buf, true);
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
@ -358,11 +358,11 @@ IFileItem* FileSystemModule::getFileItemFromPath(const base::string& path)
|
|||||||
return fileitem;
|
return fileitem;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool FileSystemModule::dirExists(const base::string& path)
|
bool FileSystemModule::dirExists(const std::string& path)
|
||||||
{
|
{
|
||||||
struct al_ffblk info;
|
struct al_ffblk info;
|
||||||
int ret;
|
int ret;
|
||||||
base::string path2 = base::join_path(path, "*.*");
|
std::string path2 = base::join_path(path, "*.*");
|
||||||
|
|
||||||
ret = al_findfirst(path2.c_str(), &info, FA_ALL);
|
ret = al_findfirst(path2.c_str(), &info, FA_ALL);
|
||||||
al_findclose(&info);
|
al_findclose(&info);
|
||||||
@ -393,21 +393,21 @@ bool FileItem::isBrowsable() const
|
|||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
base::string FileItem::getKeyName() const
|
std::string FileItem::getKeyName() const
|
||||||
{
|
{
|
||||||
ASSERT(this->keyname != NOTINITIALIZED);
|
ASSERT(this->keyname != NOTINITIALIZED);
|
||||||
|
|
||||||
return this->keyname;
|
return this->keyname;
|
||||||
}
|
}
|
||||||
|
|
||||||
base::string FileItem::getFileName() const
|
std::string FileItem::getFileName() const
|
||||||
{
|
{
|
||||||
ASSERT(this->filename != NOTINITIALIZED);
|
ASSERT(this->filename != NOTINITIALIZED);
|
||||||
|
|
||||||
return this->filename;
|
return this->filename;
|
||||||
}
|
}
|
||||||
|
|
||||||
base::string FileItem::getDisplayName() const
|
std::string FileItem::getDisplayName() const
|
||||||
{
|
{
|
||||||
ASSERT(this->displayname != NOTINITIALIZED);
|
ASSERT(this->displayname != NOTINITIALIZED);
|
||||||
|
|
||||||
@ -560,7 +560,7 @@ const FileItemList& FileItem::getChildren()
|
|||||||
return this->children;
|
return this->children;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool FileItem::hasExtension(const base::string& csv_extensions)
|
bool FileItem::hasExtension(const std::string& csv_extensions)
|
||||||
{
|
{
|
||||||
ASSERT(this->filename != NOTINITIALIZED);
|
ASSERT(this->filename != NOTINITIALIZED);
|
||||||
|
|
||||||
@ -873,7 +873,7 @@ static void free_pidl(LPITEMIDLIST pidl)
|
|||||||
shl_imalloc->Free(pidl);
|
shl_imalloc->Free(pidl);
|
||||||
}
|
}
|
||||||
|
|
||||||
static base::string get_key_for_pidl(LPITEMIDLIST pidl)
|
static std::string get_key_for_pidl(LPITEMIDLIST pidl)
|
||||||
{
|
{
|
||||||
#if 0
|
#if 0
|
||||||
char *key = base_malloc(get_pidl_size(pidl)+1);
|
char *key = base_malloc(get_pidl_size(pidl)+1);
|
||||||
@ -995,7 +995,7 @@ static void put_fileitem(FileItem* fileitem)
|
|||||||
// Allegro for_each_file: Portable
|
// Allegro for_each_file: Portable
|
||||||
//////////////////////////////////////////////////////////////////////
|
//////////////////////////////////////////////////////////////////////
|
||||||
|
|
||||||
static FileItem* get_fileitem_by_path(const base::string& path, bool create_if_not)
|
static FileItem* get_fileitem_by_path(const std::string& path, bool create_if_not)
|
||||||
{
|
{
|
||||||
if (path.empty())
|
if (path.empty())
|
||||||
return rootitem;
|
return rootitem;
|
||||||
@ -1024,7 +1024,7 @@ static FileItem* get_fileitem_by_path(const base::string& path, bool create_if_n
|
|||||||
|
|
||||||
// get the parent
|
// get the parent
|
||||||
{
|
{
|
||||||
base::string parent_path = remove_backslash_if_needed(base::join_path(base::get_file_path(path), ""));
|
std::string parent_path = remove_backslash_if_needed(base::join_path(base::get_file_path(path), ""));
|
||||||
fileitem->parent = get_fileitem_by_path(parent_path, true);
|
fileitem->parent = get_fileitem_by_path(parent_path, true);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1066,7 +1066,7 @@ static void for_each_child_callback(const char *filename, int attrib, int param)
|
|||||||
fileitem->insertChildSorted(child);
|
fileitem->insertChildSorted(child);
|
||||||
}
|
}
|
||||||
|
|
||||||
static base::string remove_backslash_if_needed(const base::string& filename)
|
static std::string remove_backslash_if_needed(const std::string& filename)
|
||||||
{
|
{
|
||||||
if (!filename.empty() && base::is_path_separator(*(filename.end()-1))) {
|
if (!filename.empty() && base::is_path_separator(*(filename.end()-1))) {
|
||||||
int len = filename.size();
|
int len = filename.size();
|
||||||
@ -1085,9 +1085,9 @@ static base::string remove_backslash_if_needed(const base::string& filename)
|
|||||||
return filename;
|
return filename;
|
||||||
}
|
}
|
||||||
|
|
||||||
static base::string get_key_for_filename(const base::string& filename)
|
static std::string get_key_for_filename(const std::string& filename)
|
||||||
{
|
{
|
||||||
base::string buf(filename);
|
std::string buf(filename);
|
||||||
|
|
||||||
#if !defined CASE_SENSITIVE
|
#if !defined CASE_SENSITIVE
|
||||||
buf.tolower();
|
buf.tolower();
|
||||||
|
@ -20,8 +20,7 @@
|
|||||||
#define APP_FILE_SYSTEM_H_INCLUDED
|
#define APP_FILE_SYSTEM_H_INCLUDED
|
||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
#include "base/string.h"
|
#include <string>
|
||||||
|
|
||||||
#include <vector>
|
#include <vector>
|
||||||
|
|
||||||
struct BITMAP;
|
struct BITMAP;
|
||||||
@ -49,9 +48,9 @@ namespace app {
|
|||||||
|
|
||||||
// Returns the FileItem through the specified "path".
|
// Returns the FileItem through the specified "path".
|
||||||
// Warning: You have to call path.fix_separators() before.
|
// Warning: You have to call path.fix_separators() before.
|
||||||
IFileItem* getFileItemFromPath(const base::string& path);
|
IFileItem* getFileItemFromPath(const std::string& path);
|
||||||
|
|
||||||
bool dirExists(const base::string& path);
|
bool dirExists(const std::string& path);
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
@ -62,14 +61,14 @@ namespace app {
|
|||||||
virtual bool isFolder() const = 0;
|
virtual bool isFolder() const = 0;
|
||||||
virtual bool isBrowsable() const = 0;
|
virtual bool isBrowsable() const = 0;
|
||||||
|
|
||||||
virtual base::string getKeyName() const = 0;
|
virtual std::string getKeyName() const = 0;
|
||||||
virtual base::string getFileName() const = 0;
|
virtual std::string getFileName() const = 0;
|
||||||
virtual base::string getDisplayName() const = 0;
|
virtual std::string getDisplayName() const = 0;
|
||||||
|
|
||||||
virtual IFileItem* getParent() const = 0;
|
virtual IFileItem* getParent() const = 0;
|
||||||
virtual const FileItemList& getChildren() = 0;
|
virtual const FileItemList& getChildren() = 0;
|
||||||
|
|
||||||
virtual bool hasExtension(const base::string& csv_extensions) = 0;
|
virtual bool hasExtension(const std::string& csv_extensions) = 0;
|
||||||
|
|
||||||
virtual BITMAP* getThumbnail() = 0;
|
virtual BITMAP* getThumbnail() = 0;
|
||||||
virtual void setThumbnail(BITMAP* thumbnail) = 0;
|
virtual void setThumbnail(BITMAP* thumbnail) = 0;
|
||||||
|
@ -52,7 +52,7 @@ GuiXml::GuiXml()
|
|||||||
m_doc = app::open_xml(rf.filename());
|
m_doc = app::open_xml(rf.filename());
|
||||||
}
|
}
|
||||||
|
|
||||||
base::string GuiXml::version()
|
std::string GuiXml::version()
|
||||||
{
|
{
|
||||||
TiXmlHandle handle(m_doc);
|
TiXmlHandle handle(m_doc);
|
||||||
TiXmlElement* xmlKey = handle.FirstChild("gui").ToElement();
|
TiXmlElement* xmlKey = handle.FirstChild("gui").ToElement();
|
||||||
|
@ -21,7 +21,8 @@
|
|||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
#include "app/xml_document.h"
|
#include "app/xml_document.h"
|
||||||
#include "base/string.h"
|
|
||||||
|
#include <string>
|
||||||
|
|
||||||
namespace app {
|
namespace app {
|
||||||
|
|
||||||
@ -43,7 +44,7 @@ namespace app {
|
|||||||
return m_doc->Value();
|
return m_doc->Value();
|
||||||
}
|
}
|
||||||
|
|
||||||
base::string version();
|
std::string version();
|
||||||
|
|
||||||
private:
|
private:
|
||||||
GuiXml();
|
GuiXml();
|
||||||
|
@ -64,7 +64,7 @@ RecentFiles::RecentFiles()
|
|||||||
const_iterator it = files_begin();
|
const_iterator it = files_begin();
|
||||||
const_iterator end = files_end();
|
const_iterator end = files_end();
|
||||||
for (; it != end; ++it) {
|
for (; it != end; ++it) {
|
||||||
base::string path = base::get_file_path(*it);
|
std::string path = base::get_file_path(*it);
|
||||||
|
|
||||||
// Check if the path was not already included in the list
|
// Check if the path was not already included in the list
|
||||||
if (included.find(path) == included.end()) {
|
if (included.find(path) == included.end()) {
|
||||||
|
@ -21,13 +21,14 @@
|
|||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
#include "base/recent_items.h"
|
#include "base/recent_items.h"
|
||||||
#include "base/string.h"
|
|
||||||
|
#include <string>
|
||||||
|
|
||||||
namespace app {
|
namespace app {
|
||||||
|
|
||||||
class RecentFiles {
|
class RecentFiles {
|
||||||
public:
|
public:
|
||||||
typedef base::RecentItems<base::string> List;
|
typedef base::RecentItems<std::string> List;
|
||||||
typedef List::iterator iterator;
|
typedef List::iterator iterator;
|
||||||
typedef List::const_iterator const_iterator;
|
typedef List::const_iterator const_iterator;
|
||||||
|
|
||||||
|
@ -23,10 +23,11 @@
|
|||||||
#include "app/file_system.h"
|
#include "app/file_system.h"
|
||||||
#include "base/compiler_specific.h"
|
#include "base/compiler_specific.h"
|
||||||
#include "base/signal.h"
|
#include "base/signal.h"
|
||||||
#include "base/string.h"
|
|
||||||
#include "ui/timer.h"
|
#include "ui/timer.h"
|
||||||
#include "ui/widget.h"
|
#include "ui/widget.h"
|
||||||
|
|
||||||
|
#include <string>
|
||||||
|
|
||||||
namespace app {
|
namespace app {
|
||||||
|
|
||||||
class FileList : public ui::Widget {
|
class FileList : public ui::Widget {
|
||||||
@ -71,7 +72,7 @@ namespace app {
|
|||||||
bool m_req_valid;
|
bool m_req_valid;
|
||||||
int m_req_w, m_req_h;
|
int m_req_w, m_req_h;
|
||||||
IFileItem* m_selected;
|
IFileItem* m_selected;
|
||||||
base::string m_exts;
|
std::string m_exts;
|
||||||
|
|
||||||
// Incremental-search
|
// Incremental-search
|
||||||
std::string m_isearch;
|
std::string m_isearch;
|
||||||
|
@ -119,7 +119,7 @@ protected:
|
|||||||
}
|
}
|
||||||
|
|
||||||
// String to be autocompleted
|
// String to be autocompleted
|
||||||
base::string left_part = getText();
|
std::string left_part = getText();
|
||||||
if (left_part.empty())
|
if (left_part.empty())
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
@ -128,9 +128,9 @@ protected:
|
|||||||
for (FileItemList::const_iterator
|
for (FileItemList::const_iterator
|
||||||
it=children.begin(); it!=children.end(); ++it) {
|
it=children.begin(); it!=children.end(); ++it) {
|
||||||
IFileItem* child = *it;
|
IFileItem* child = *it;
|
||||||
base::string child_name = child->getDisplayName();
|
std::string child_name = child->getDisplayName();
|
||||||
|
|
||||||
base::string::iterator it1, it2;
|
std::string::iterator it1, it2;
|
||||||
|
|
||||||
for (it1 = child_name.begin(), it2 = left_part.begin();
|
for (it1 = child_name.begin(), it2 = left_part.begin();
|
||||||
it1!=child_name.end() && it2!=left_part.end();
|
it1!=child_name.end() && it2!=left_part.end();
|
||||||
@ -247,11 +247,11 @@ FileSelector::FileSelector()
|
|||||||
m_fileList->CurrentFolderChanged.connect(Bind<void>(&FileSelector::onFileListCurrentFolderChanged, this));
|
m_fileList->CurrentFolderChanged.connect(Bind<void>(&FileSelector::onFileListCurrentFolderChanged, this));
|
||||||
}
|
}
|
||||||
|
|
||||||
base::string FileSelector::show(const base::string& title,
|
std::string FileSelector::show(const std::string& title,
|
||||||
const base::string& initialPath,
|
const std::string& initialPath,
|
||||||
const base::string& showExtensions)
|
const std::string& showExtensions)
|
||||||
{
|
{
|
||||||
base::string result;
|
std::string result;
|
||||||
|
|
||||||
FileSystemModule::instance()->refresh();
|
FileSystemModule::instance()->refresh();
|
||||||
|
|
||||||
@ -261,13 +261,13 @@ base::string FileSelector::show(const base::string& title,
|
|||||||
}
|
}
|
||||||
|
|
||||||
// we have to find where the user should begin to browse files (start_folder)
|
// we have to find where the user should begin to browse files (start_folder)
|
||||||
base::string start_folder_path;
|
std::string start_folder_path;
|
||||||
IFileItem* start_folder = NULL;
|
IFileItem* start_folder = NULL;
|
||||||
|
|
||||||
// If initialPath doesn't contain a path.
|
// If initialPath doesn't contain a path.
|
||||||
if (base::get_file_path(initialPath).empty()) {
|
if (base::get_file_path(initialPath).empty()) {
|
||||||
// Get the saved `path' in the configuration file.
|
// Get the saved `path' in the configuration file.
|
||||||
base::string path = get_config_string("FileSelect", "CurrentDirectory", "");
|
std::string path = get_config_string("FileSelect", "CurrentDirectory", "");
|
||||||
start_folder = FileSystemModule::instance()->getFileItemFromPath(path);
|
start_folder = FileSystemModule::instance()->getFileItemFromPath(path);
|
||||||
|
|
||||||
// Is the folder find?
|
// Is the folder find?
|
||||||
@ -318,8 +318,8 @@ base::string FileSelector::show(const base::string& title,
|
|||||||
// fill file-type combo-box
|
// fill file-type combo-box
|
||||||
m_fileType->removeAllItems();
|
m_fileType->removeAllItems();
|
||||||
|
|
||||||
std::vector<base::string> tokens;
|
std::vector<std::string> tokens;
|
||||||
std::vector<base::string>::iterator tok;
|
std::vector<std::string>::iterator tok;
|
||||||
|
|
||||||
base::split_string(showExtensions, tokens, ",");
|
base::split_string(showExtensions, tokens, ",");
|
||||||
for (tok=tokens.begin(); tok!=tokens.end(); ++tok)
|
for (tok=tokens.begin(); tok!=tokens.end(); ++tok)
|
||||||
@ -348,8 +348,8 @@ again:
|
|||||||
IFileItem* folder = m_fileList->getCurrentFolder();
|
IFileItem* folder = m_fileList->getCurrentFolder();
|
||||||
ASSERT(folder);
|
ASSERT(folder);
|
||||||
|
|
||||||
base::string fn = m_fileName->getText();
|
std::string fn = m_fileName->getText();
|
||||||
base::string buf;
|
std::string buf;
|
||||||
IFileItem* enter_folder = NULL;
|
IFileItem* enter_folder = NULL;
|
||||||
|
|
||||||
// up a level?
|
// up a level?
|
||||||
@ -362,7 +362,7 @@ again:
|
|||||||
// check if the user specified in "fn" a item of "fileview"
|
// check if the user specified in "fn" a item of "fileview"
|
||||||
const FileItemList& children = m_fileList->getFileList();
|
const FileItemList& children = m_fileList->getFileList();
|
||||||
|
|
||||||
base::string fn2 = fn;
|
std::string fn2 = fn;
|
||||||
#ifdef WIN32
|
#ifdef WIN32
|
||||||
fn2 = base::string_to_lower(fn2);
|
fn2 = base::string_to_lower(fn2);
|
||||||
#endif
|
#endif
|
||||||
@ -370,7 +370,7 @@ again:
|
|||||||
for (FileItemList::const_iterator
|
for (FileItemList::const_iterator
|
||||||
it=children.begin(); it!=children.end(); ++it) {
|
it=children.begin(); it!=children.end(); ++it) {
|
||||||
IFileItem* child = *it;
|
IFileItem* child = *it;
|
||||||
base::string child_name = child->getDisplayName();
|
std::string child_name = child->getDisplayName();
|
||||||
|
|
||||||
#ifdef WIN32
|
#ifdef WIN32
|
||||||
child_name = base::string_to_lower(child_name);
|
child_name = base::string_to_lower(child_name);
|
||||||
@ -387,7 +387,7 @@ again:
|
|||||||
if (base::is_path_separator(*fn.begin())) { // absolute path (UNIX style)
|
if (base::is_path_separator(*fn.begin())) { // absolute path (UNIX style)
|
||||||
#ifdef WIN32
|
#ifdef WIN32
|
||||||
// get the drive of the current folder
|
// get the drive of the current folder
|
||||||
base::string drive = folder->getFileName();
|
std::string drive = folder->getFileName();
|
||||||
if (drive.size() >= 2 && drive[1] == ':') {
|
if (drive.size() >= 2 && drive[1] == ':') {
|
||||||
buf += drive[0];
|
buf += drive[0];
|
||||||
buf += ':';
|
buf += ':';
|
||||||
@ -401,7 +401,7 @@ again:
|
|||||||
}
|
}
|
||||||
#ifdef WIN32
|
#ifdef WIN32
|
||||||
// does the file-name entry have colon?
|
// does the file-name entry have colon?
|
||||||
else if (fn.find(':') != base::string::npos) { // absolute path on Windows
|
else if (fn.find(':') != std::string::npos) { // absolute path on Windows
|
||||||
if (fn.size() == 2 && fn[1] == ':') {
|
if (fn.size() == 2 && fn[1] == ':') {
|
||||||
buf = base::join_path(fn, "");
|
buf = base::join_path(fn, "");
|
||||||
}
|
}
|
||||||
@ -453,7 +453,7 @@ again:
|
|||||||
result = buf;
|
result = buf;
|
||||||
|
|
||||||
// save the path in the configuration file
|
// save the path in the configuration file
|
||||||
base::string lastpath = folder->getKeyName();
|
std::string lastpath = folder->getKeyName();
|
||||||
set_config_string("FileSelect", "CurrentDirectory",
|
set_config_string("FileSelect", "CurrentDirectory",
|
||||||
lastpath.c_str());
|
lastpath.c_str());
|
||||||
}
|
}
|
||||||
@ -486,7 +486,7 @@ void FileSelector::updateLocation()
|
|||||||
fileItem = *it;
|
fileItem = *it;
|
||||||
|
|
||||||
// Indentation
|
// Indentation
|
||||||
base::string buf;
|
std::string buf;
|
||||||
for (int c=0; c<level; ++c)
|
for (int c=0; c<level; ++c)
|
||||||
buf += " ";
|
buf += " ";
|
||||||
|
|
||||||
@ -565,7 +565,7 @@ void FileSelector::addInNavigationHistory(IFileItem* folder)
|
|||||||
|
|
||||||
void FileSelector::selectFileTypeFromFileName()
|
void FileSelector::selectFileTypeFromFileName()
|
||||||
{
|
{
|
||||||
base::string ext = base::get_file_extension(m_fileName->getText());
|
std::string ext = base::get_file_extension(m_fileName->getText());
|
||||||
|
|
||||||
if (!ext.empty()) {
|
if (!ext.empty()) {
|
||||||
ext = base::string_to_lower(ext);
|
ext = base::string_to_lower(ext);
|
||||||
@ -625,7 +625,7 @@ void FileSelector::onLocationCloseListBox()
|
|||||||
dynamic_cast<CustomFolderNameItem*>(m_location->getSelectedItem());
|
dynamic_cast<CustomFolderNameItem*>(m_location->getSelectedItem());
|
||||||
|
|
||||||
if (comboFolderItem != NULL) {
|
if (comboFolderItem != NULL) {
|
||||||
base::string path = comboFolderItem->getText();
|
std::string path = comboFolderItem->getText();
|
||||||
fileItem = FileSystemModule::instance()->getFileItemFromPath(path);
|
fileItem = FileSystemModule::instance()->getFileItemFromPath(path);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -658,7 +658,7 @@ void FileSelector::onFileListFileSelected()
|
|||||||
IFileItem* fileitem = m_fileList->getSelectedFileItem();
|
IFileItem* fileitem = m_fileList->getSelectedFileItem();
|
||||||
|
|
||||||
if (!fileitem->isFolder()) {
|
if (!fileitem->isFolder()) {
|
||||||
base::string filename = base::get_file_name(fileitem->getFileName());
|
std::string filename = base::get_file_name(fileitem->getFileName());
|
||||||
|
|
||||||
m_fileName->setText(filename.c_str());
|
m_fileName->setText(filename.c_str());
|
||||||
m_fileName->selectText(0, -1);
|
m_fileName->selectText(0, -1);
|
||||||
|
@ -20,10 +20,11 @@
|
|||||||
#define APP_UI_FILE_SELECTOR_H_INCLUDED
|
#define APP_UI_FILE_SELECTOR_H_INCLUDED
|
||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
#include "base/string.h"
|
|
||||||
#include "base/unique_ptr.h"
|
#include "base/unique_ptr.h"
|
||||||
#include "ui/window.h"
|
#include "ui/window.h"
|
||||||
|
|
||||||
|
#include <string>
|
||||||
|
|
||||||
namespace ui {
|
namespace ui {
|
||||||
class Button;
|
class Button;
|
||||||
class ComboBox;
|
class ComboBox;
|
||||||
@ -40,9 +41,9 @@ namespace app {
|
|||||||
FileSelector();
|
FileSelector();
|
||||||
|
|
||||||
// Shows the dialog to select a file in the program.
|
// Shows the dialog to select a file in the program.
|
||||||
base::string show(const base::string& title,
|
std::string show(const std::string& title,
|
||||||
const base::string& initialPath,
|
const std::string& initialPath,
|
||||||
const base::string& showExtensions);
|
const std::string& showExtensions);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
void updateLocation();
|
void updateLocation();
|
||||||
|
@ -38,7 +38,7 @@ namespace app {
|
|||||||
using namespace app::skin;
|
using namespace app::skin;
|
||||||
using namespace ui;
|
using namespace ui;
|
||||||
|
|
||||||
PopupWindowPin::PopupWindowPin(const base::string& text, ClickBehavior clickBehavior)
|
PopupWindowPin::PopupWindowPin(const std::string& text, ClickBehavior clickBehavior)
|
||||||
: PopupWindow(text, clickBehavior)
|
: PopupWindow(text, clickBehavior)
|
||||||
, m_pin("")
|
, m_pin("")
|
||||||
{
|
{
|
||||||
|
@ -27,7 +27,7 @@ namespace app {
|
|||||||
|
|
||||||
class PopupWindowPin : public ui::PopupWindow {
|
class PopupWindowPin : public ui::PopupWindow {
|
||||||
public:
|
public:
|
||||||
PopupWindowPin(const base::string& text, ClickBehavior clickBehavior);
|
PopupWindowPin(const std::string& text, ClickBehavior clickBehavior);
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
virtual bool onProcessMessage(ui::Message* msg) OVERRIDE;
|
virtual bool onProcessMessage(ui::Message* msg) OVERRIDE;
|
||||||
|
@ -92,8 +92,8 @@ void UIContext::setActiveView(DocumentView* docView)
|
|||||||
app_refresh_screen();
|
app_refresh_screen();
|
||||||
|
|
||||||
// Change the main frame title.
|
// Change the main frame title.
|
||||||
base::string defaultTitle = PACKAGE " v" VERSION;
|
std::string defaultTitle = PACKAGE " v" VERSION;
|
||||||
base::string title;
|
std::string title;
|
||||||
if (docView) {
|
if (docView) {
|
||||||
// Prepend the document's filename.
|
// Prepend the document's filename.
|
||||||
title += base::get_file_name(docView->getDocument()->getFilename());
|
title += base::get_file_name(docView->getDocument()->getFilename());
|
||||||
|
@ -90,8 +90,8 @@ Widget* WidgetLoader::loadWidget(const char* fileName, const char* widgetId)
|
|||||||
return widget;
|
return widget;
|
||||||
}
|
}
|
||||||
|
|
||||||
Widget* WidgetLoader::loadWidgetFromXmlFile(const base::string& xmlFilename,
|
Widget* WidgetLoader::loadWidgetFromXmlFile(const std::string& xmlFilename,
|
||||||
const base::string& widgetId)
|
const std::string& widgetId)
|
||||||
{
|
{
|
||||||
Widget* widget = NULL;
|
Widget* widget = NULL;
|
||||||
m_tooltipManager = NULL;
|
m_tooltipManager = NULL;
|
||||||
|
@ -21,9 +21,9 @@
|
|||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
#include "app/widget_type_mismatch.h"
|
#include "app/widget_type_mismatch.h"
|
||||||
#include "base/string.h"
|
|
||||||
|
|
||||||
#include <map>
|
#include <map>
|
||||||
|
#include <string>
|
||||||
|
|
||||||
class TiXmlElement;
|
class TiXmlElement;
|
||||||
|
|
||||||
@ -70,11 +70,11 @@ namespace app {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private:
|
private:
|
||||||
ui::Widget* loadWidgetFromXmlFile(const base::string& xmlFilename,
|
ui::Widget* loadWidgetFromXmlFile(const std::string& xmlFilename,
|
||||||
const base::string& widgetId);
|
const std::string& widgetId);
|
||||||
ui::Widget* convertXmlElementToWidget(const TiXmlElement* elem, ui::Widget* root);
|
ui::Widget* convertXmlElementToWidget(const TiXmlElement* elem, ui::Widget* root);
|
||||||
|
|
||||||
typedef std::map<base::string, IWidgetTypeCreator*> TypeCreatorsMap;
|
typedef std::map<std::string, IWidgetTypeCreator*> TypeCreatorsMap;
|
||||||
|
|
||||||
TypeCreatorsMap m_typeCreators;
|
TypeCreatorsMap m_typeCreators;
|
||||||
ui::TooltipManager* m_tooltipManager;
|
ui::TooltipManager* m_tooltipManager;
|
||||||
|
@ -31,7 +31,7 @@ namespace app {
|
|||||||
|
|
||||||
using namespace base;
|
using namespace base;
|
||||||
|
|
||||||
XmlDocumentRef open_xml(const string& filename)
|
XmlDocumentRef open_xml(const std::string& filename)
|
||||||
{
|
{
|
||||||
FileHandle file(open_file(filename, "rb"));
|
FileHandle file(open_file(filename, "rb"));
|
||||||
if (!file)
|
if (!file)
|
||||||
|
@ -22,15 +22,16 @@
|
|||||||
|
|
||||||
#include "base/exception.h"
|
#include "base/exception.h"
|
||||||
#include "base/shared_ptr.h"
|
#include "base/shared_ptr.h"
|
||||||
#include "base/string.h"
|
|
||||||
|
|
||||||
#include "tinyxml.h"
|
#include "tinyxml.h"
|
||||||
|
|
||||||
|
#include <string>
|
||||||
|
|
||||||
namespace app {
|
namespace app {
|
||||||
|
|
||||||
typedef SharedPtr<TiXmlDocument> XmlDocumentRef;
|
typedef SharedPtr<TiXmlDocument> XmlDocumentRef;
|
||||||
|
|
||||||
XmlDocumentRef open_xml(const base::string& filename);
|
XmlDocumentRef open_xml(const std::string& filename);
|
||||||
|
|
||||||
} // namespace app
|
} // namespace app
|
||||||
|
|
||||||
|
@ -16,19 +16,19 @@
|
|||||||
|
|
||||||
namespace base {
|
namespace base {
|
||||||
|
|
||||||
template<> int convert_to(const string& from)
|
template<> int convert_to(const std::string& from)
|
||||||
{
|
{
|
||||||
return std::strtol(from.c_str(), NULL, 10);
|
return std::strtol(from.c_str(), NULL, 10);
|
||||||
}
|
}
|
||||||
|
|
||||||
template<> string convert_to(const int& from)
|
template<> std::string convert_to(const int& from)
|
||||||
{
|
{
|
||||||
char buf[32];
|
char buf[32];
|
||||||
std::sprintf(buf, "%d", from);
|
std::sprintf(buf, "%d", from);
|
||||||
return buf;
|
return buf;
|
||||||
}
|
}
|
||||||
|
|
||||||
template<> Sha1 convert_to(const string& from)
|
template<> Sha1 convert_to(const std::string& from)
|
||||||
{
|
{
|
||||||
std::vector<uint8_t> digest(Sha1::HashSize);
|
std::vector<uint8_t> digest(Sha1::HashSize);
|
||||||
|
|
||||||
@ -42,10 +42,10 @@ template<> Sha1 convert_to(const string& from)
|
|||||||
return Sha1(digest);
|
return Sha1(digest);
|
||||||
}
|
}
|
||||||
|
|
||||||
template<> string convert_to(const Sha1& from)
|
template<> std::string convert_to(const Sha1& from)
|
||||||
{
|
{
|
||||||
char buf[3];
|
char buf[3];
|
||||||
string res;
|
std::string res;
|
||||||
res.reserve(2*Sha1::HashSize);
|
res.reserve(2*Sha1::HashSize);
|
||||||
|
|
||||||
for(int c=0; c<Sha1::HashSize; ++c) {
|
for(int c=0; c<Sha1::HashSize; ++c) {
|
||||||
@ -56,14 +56,14 @@ template<> string convert_to(const Sha1& from)
|
|||||||
return res;
|
return res;
|
||||||
}
|
}
|
||||||
|
|
||||||
template<> Version convert_to(const string& from)
|
template<> Version convert_to(const std::string& from)
|
||||||
{
|
{
|
||||||
Version result;
|
Version result;
|
||||||
int i = 0;
|
int i = 0;
|
||||||
int j = 0;
|
int j = 0;
|
||||||
while (j != string::npos) {
|
while (j != std::string::npos) {
|
||||||
j = from.find('.', i);
|
j = from.find('.', i);
|
||||||
string digitString = from.substr(i, j - i);
|
std::string digitString = from.substr(i, j - i);
|
||||||
int digit = convert_to<int>(digitString);
|
int digit = convert_to<int>(digitString);
|
||||||
result.addDigit(digit);
|
result.addDigit(digit);
|
||||||
i = j+1;
|
i = j+1;
|
||||||
@ -71,13 +71,13 @@ template<> Version convert_to(const string& from)
|
|||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
template<> string convert_to(const Version& from)
|
template<> std::string convert_to(const Version& from)
|
||||||
{
|
{
|
||||||
string result;
|
std::string result;
|
||||||
result.reserve(3*from.size());
|
result.reserve(3*from.size());
|
||||||
|
|
||||||
for (size_t i=0; i<from.size(); ++i) {
|
for (size_t i=0; i<from.size(); ++i) {
|
||||||
result += convert_to<string>(from[i]);
|
result += convert_to<std::string>(from[i]);
|
||||||
if (i < from.size()-1)
|
if (i < from.size()-1)
|
||||||
result += ".";
|
result += ".";
|
||||||
}
|
}
|
||||||
|
@ -8,7 +8,7 @@
|
|||||||
#define BASE_CONVERT_TO_H_INCLUDED
|
#define BASE_CONVERT_TO_H_INCLUDED
|
||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
#include "base/string.h"
|
#include <string>
|
||||||
|
|
||||||
namespace base {
|
namespace base {
|
||||||
|
|
||||||
@ -25,14 +25,14 @@ namespace base {
|
|||||||
// TODO Use a static_assert(false)
|
// TODO Use a static_assert(false)
|
||||||
}
|
}
|
||||||
|
|
||||||
template<> int convert_to(const base::string& from);
|
template<> int convert_to(const std::string& from);
|
||||||
template<> base::string convert_to(const int& from);
|
template<> std::string convert_to(const int& from);
|
||||||
|
|
||||||
template<> Sha1 convert_to(const base::string& from);
|
template<> Sha1 convert_to(const std::string& from);
|
||||||
template<> base::string convert_to(const Sha1& from);
|
template<> std::string convert_to(const Sha1& from);
|
||||||
|
|
||||||
template<> Version convert_to(const base::string& from);
|
template<> Version convert_to(const std::string& from);
|
||||||
template<> base::string convert_to(const Version& from);
|
template<> std::string convert_to(const Version& from);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -9,18 +9,18 @@
|
|||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
#include "base/shared_ptr.h"
|
#include "base/shared_ptr.h"
|
||||||
#include "base/string.h"
|
|
||||||
|
|
||||||
#include <cstdio>
|
#include <cstdio>
|
||||||
|
#include <string>
|
||||||
|
|
||||||
namespace base {
|
namespace base {
|
||||||
|
|
||||||
typedef SharedPtr<FILE> FileHandle;
|
typedef SharedPtr<FILE> FileHandle;
|
||||||
|
|
||||||
FILE* open_file_raw(const string& filename, const string& mode);
|
FILE* open_file_raw(const std::string& filename, const std::string& mode);
|
||||||
FileHandle open_file(const string& filename, const string& mode);
|
FileHandle open_file(const std::string& filename, const std::string& mode);
|
||||||
FileHandle open_file_with_exception(const string& filename, const string& mode);
|
FileHandle open_file_with_exception(const std::string& filename, const std::string& mode);
|
||||||
int open_file_descriptor_with_exception(const string& filename, const string& mode);
|
int open_file_descriptor_with_exception(const std::string& filename, const std::string& mode);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -8,23 +8,23 @@
|
|||||||
#define BASE_FS_H_INCLUDED
|
#define BASE_FS_H_INCLUDED
|
||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
#include "base/string.h"
|
#include <string>
|
||||||
|
|
||||||
namespace base {
|
namespace base {
|
||||||
|
|
||||||
bool is_file(const string& path);
|
bool is_file(const std::string& path);
|
||||||
bool is_directory(const string& path);
|
bool is_directory(const std::string& path);
|
||||||
|
|
||||||
void delete_file(const string& path);
|
void delete_file(const std::string& path);
|
||||||
|
|
||||||
bool has_readonly_attr(const string& path);
|
bool has_readonly_attr(const std::string& path);
|
||||||
void remove_readonly_attr(const string& path);
|
void remove_readonly_attr(const std::string& path);
|
||||||
|
|
||||||
void make_directory(const string& path);
|
void make_directory(const std::string& path);
|
||||||
void remove_directory(const string& path);
|
void remove_directory(const std::string& path);
|
||||||
|
|
||||||
string get_app_path();
|
std::string get_app_path();
|
||||||
string get_temp_path();
|
std::string get_temp_path();
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -21,19 +21,19 @@
|
|||||||
|
|
||||||
namespace base {
|
namespace base {
|
||||||
|
|
||||||
bool is_file(const string& path)
|
bool is_file(const std::string& path)
|
||||||
{
|
{
|
||||||
struct stat sts;
|
struct stat sts;
|
||||||
return (stat(path.c_str(), &sts) == 0 && S_ISREG(sts.st_mode)) ? true: false;
|
return (stat(path.c_str(), &sts) == 0 && S_ISREG(sts.st_mode)) ? true: false;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool is_directory(const string& path)
|
bool is_directory(const std::string& path)
|
||||||
{
|
{
|
||||||
struct stat sts;
|
struct stat sts;
|
||||||
return (stat(path.c_str(), &sts) == 0 && S_ISDIR(sts.st_mode)) ? true: false;
|
return (stat(path.c_str(), &sts) == 0 && S_ISDIR(sts.st_mode)) ? true: false;
|
||||||
}
|
}
|
||||||
|
|
||||||
void make_directory(const string& path)
|
void make_directory(const std::string& path)
|
||||||
{
|
{
|
||||||
int result = mkdir(path.c_str(), 0777);
|
int result = mkdir(path.c_str(), 0777);
|
||||||
if (result < 0) {
|
if (result < 0) {
|
||||||
@ -42,7 +42,7 @@ void make_directory(const string& path)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void delete_file(const string& path)
|
void delete_file(const std::string& path)
|
||||||
{
|
{
|
||||||
int result = unlink(path.c_str());
|
int result = unlink(path.c_str());
|
||||||
if (result != 0)
|
if (result != 0)
|
||||||
@ -50,13 +50,13 @@ void delete_file(const string& path)
|
|||||||
throw std::runtime_error("Error deleting file");
|
throw std::runtime_error("Error deleting file");
|
||||||
}
|
}
|
||||||
|
|
||||||
bool has_readonly_attr(const string& path)
|
bool has_readonly_attr(const std::string& path)
|
||||||
{
|
{
|
||||||
struct stat sts;
|
struct stat sts;
|
||||||
return (stat(path.c_str(), &sts) == 0 && ((sts.st_mode & S_IWUSR) == 0));
|
return (stat(path.c_str(), &sts) == 0 && ((sts.st_mode & S_IWUSR) == 0));
|
||||||
}
|
}
|
||||||
|
|
||||||
void remove_readonly_attr(const string& path)
|
void remove_readonly_attr(const std::string& path)
|
||||||
{
|
{
|
||||||
struct stat sts;
|
struct stat sts;
|
||||||
int result = stat(path.c_str(), &sts);
|
int result = stat(path.c_str(), &sts);
|
||||||
@ -68,7 +68,7 @@ void remove_readonly_attr(const string& path)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void remove_directory(const string& path)
|
void remove_directory(const std::string& path)
|
||||||
{
|
{
|
||||||
int result = rmdir(path.c_str());
|
int result = rmdir(path.c_str());
|
||||||
if (result != 0) {
|
if (result != 0) {
|
||||||
@ -77,7 +77,7 @@ void remove_directory(const string& path)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
string get_app_path()
|
std::string get_app_path()
|
||||||
{
|
{
|
||||||
std::vector<char> path(MAXPATHLEN);
|
std::vector<char> path(MAXPATHLEN);
|
||||||
|
|
||||||
@ -97,7 +97,7 @@ string get_app_path()
|
|||||||
return std::string();
|
return std::string();
|
||||||
}
|
}
|
||||||
|
|
||||||
string get_temp_path()
|
std::string get_temp_path()
|
||||||
{
|
{
|
||||||
char* tmpdir = getenv("TMPDIR");
|
char* tmpdir = getenv("TMPDIR");
|
||||||
if (tmpdir)
|
if (tmpdir)
|
||||||
|
@ -12,7 +12,7 @@
|
|||||||
|
|
||||||
namespace base {
|
namespace base {
|
||||||
|
|
||||||
bool is_file(const string& path)
|
bool is_file(const std::string& path)
|
||||||
{
|
{
|
||||||
DWORD attr = ::GetFileAttributes(from_utf8(path).c_str());
|
DWORD attr = ::GetFileAttributes(from_utf8(path).c_str());
|
||||||
|
|
||||||
@ -22,7 +22,7 @@ bool is_file(const string& path)
|
|||||||
!(attr & FILE_ATTRIBUTE_DIRECTORY));
|
!(attr & FILE_ATTRIBUTE_DIRECTORY));
|
||||||
}
|
}
|
||||||
|
|
||||||
bool is_directory(const string& path)
|
bool is_directory(const std::string& path)
|
||||||
{
|
{
|
||||||
DWORD attr = ::GetFileAttributes(from_utf8(path).c_str());
|
DWORD attr = ::GetFileAttributes(from_utf8(path).c_str());
|
||||||
|
|
||||||
@ -30,21 +30,21 @@ bool is_directory(const string& path)
|
|||||||
((attr & FILE_ATTRIBUTE_DIRECTORY) == FILE_ATTRIBUTE_DIRECTORY));
|
((attr & FILE_ATTRIBUTE_DIRECTORY) == FILE_ATTRIBUTE_DIRECTORY));
|
||||||
}
|
}
|
||||||
|
|
||||||
void delete_file(const string& path)
|
void delete_file(const std::string& path)
|
||||||
{
|
{
|
||||||
BOOL result = ::DeleteFile(from_utf8(path).c_str());
|
BOOL result = ::DeleteFile(from_utf8(path).c_str());
|
||||||
if (result == 0)
|
if (result == 0)
|
||||||
throw Win32Exception("Error deleting file");
|
throw Win32Exception("Error deleting file");
|
||||||
}
|
}
|
||||||
|
|
||||||
bool has_readonly_attr(const string& path)
|
bool has_readonly_attr(const std::string& path)
|
||||||
{
|
{
|
||||||
std::wstring fn = from_utf8(path);
|
std::wstring fn = from_utf8(path);
|
||||||
DWORD attr = ::GetFileAttributes(fn.c_str());
|
DWORD attr = ::GetFileAttributes(fn.c_str());
|
||||||
return ((attr & FILE_ATTRIBUTE_READONLY) == FILE_ATTRIBUTE_READONLY);
|
return ((attr & FILE_ATTRIBUTE_READONLY) == FILE_ATTRIBUTE_READONLY);
|
||||||
}
|
}
|
||||||
|
|
||||||
void remove_readonly_attr(const string& path)
|
void remove_readonly_attr(const std::string& path)
|
||||||
{
|
{
|
||||||
std::wstring fn = from_utf8(path);
|
std::wstring fn = from_utf8(path);
|
||||||
DWORD attr = ::GetFileAttributes(fn.c_str());
|
DWORD attr = ::GetFileAttributes(fn.c_str());
|
||||||
@ -52,7 +52,7 @@ void remove_readonly_attr(const string& path)
|
|||||||
::SetFileAttributes(fn.c_str(), attr & ~FILE_ATTRIBUTE_READONLY);
|
::SetFileAttributes(fn.c_str(), attr & ~FILE_ATTRIBUTE_READONLY);
|
||||||
}
|
}
|
||||||
|
|
||||||
void make_directory(const string& path)
|
void make_directory(const std::string& path)
|
||||||
{
|
{
|
||||||
BOOL result = ::CreateDirectory(from_utf8(path).c_str(), NULL);
|
BOOL result = ::CreateDirectory(from_utf8(path).c_str(), NULL);
|
||||||
if (result == 0)
|
if (result == 0)
|
||||||
@ -60,14 +60,14 @@ void make_directory(const string& path)
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void remove_directory(const string& path)
|
void remove_directory(const std::string& path)
|
||||||
{
|
{
|
||||||
BOOL result = ::RemoveDirectory(from_utf8(path).c_str());
|
BOOL result = ::RemoveDirectory(from_utf8(path).c_str());
|
||||||
if (result == 0)
|
if (result == 0)
|
||||||
throw Win32Exception("Error removing directory");
|
throw Win32Exception("Error removing directory");
|
||||||
}
|
}
|
||||||
|
|
||||||
string get_app_path()
|
std::string get_app_path()
|
||||||
{
|
{
|
||||||
TCHAR buffer[MAX_PATH+1];
|
TCHAR buffer[MAX_PATH+1];
|
||||||
if (::GetModuleFileName(NULL, buffer, sizeof(buffer)/sizeof(TCHAR)))
|
if (::GetModuleFileName(NULL, buffer, sizeof(buffer)/sizeof(TCHAR)))
|
||||||
@ -76,7 +76,7 @@ string get_app_path()
|
|||||||
return "";
|
return "";
|
||||||
}
|
}
|
||||||
|
|
||||||
string get_temp_path()
|
std::string get_temp_path()
|
||||||
{
|
{
|
||||||
TCHAR buffer[MAX_PATH+1];
|
TCHAR buffer[MAX_PATH+1];
|
||||||
DWORD result = GetTempPath(sizeof(buffer)/sizeof(TCHAR), buffer);
|
DWORD result = GetTempPath(sizeof(buffer)/sizeof(TCHAR), buffer);
|
||||||
|
@ -9,26 +9,29 @@
|
|||||||
#endif
|
#endif
|
||||||
|
|
||||||
#include "base/path.h"
|
#include "base/path.h"
|
||||||
|
|
||||||
|
#include "base/string.h"
|
||||||
|
|
||||||
#include <algorithm>
|
#include <algorithm>
|
||||||
#include <iterator>
|
#include <iterator>
|
||||||
|
|
||||||
namespace base {
|
namespace base {
|
||||||
|
|
||||||
#ifdef WIN32
|
#ifdef WIN32
|
||||||
const string::value_type path_separator = '\\';
|
const std::string::value_type path_separator = '\\';
|
||||||
#else
|
#else
|
||||||
const string::value_type path_separator = '/';
|
const std::string::value_type path_separator = '/';
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
bool is_path_separator(string::value_type chr)
|
bool is_path_separator(std::string::value_type chr)
|
||||||
{
|
{
|
||||||
return (chr == '\\' || chr == '/');
|
return (chr == '\\' || chr == '/');
|
||||||
}
|
}
|
||||||
|
|
||||||
string get_file_path(const string& filename)
|
std::string get_file_path(const std::string& filename)
|
||||||
{
|
{
|
||||||
string::const_reverse_iterator rit;
|
std::string::const_reverse_iterator rit;
|
||||||
string res;
|
std::string res;
|
||||||
|
|
||||||
for (rit=filename.rbegin(); rit!=filename.rend(); ++rit)
|
for (rit=filename.rbegin(); rit!=filename.rend(); ++rit)
|
||||||
if (is_path_separator(*rit))
|
if (is_path_separator(*rit))
|
||||||
@ -36,32 +39,32 @@ string get_file_path(const string& filename)
|
|||||||
|
|
||||||
if (rit != filename.rend()) {
|
if (rit != filename.rend()) {
|
||||||
++rit;
|
++rit;
|
||||||
std::copy(filename.begin(), string::const_iterator(rit.base()),
|
std::copy(filename.begin(), std::string::const_iterator(rit.base()),
|
||||||
std::back_inserter(res));
|
std::back_inserter(res));
|
||||||
}
|
}
|
||||||
|
|
||||||
return res;
|
return res;
|
||||||
}
|
}
|
||||||
|
|
||||||
string get_file_name(const string& filename)
|
std::string get_file_name(const std::string& filename)
|
||||||
{
|
{
|
||||||
string::const_reverse_iterator rit;
|
std::string::const_reverse_iterator rit;
|
||||||
string result;
|
std::string result;
|
||||||
|
|
||||||
for (rit=filename.rbegin(); rit!=filename.rend(); ++rit)
|
for (rit=filename.rbegin(); rit!=filename.rend(); ++rit)
|
||||||
if (is_path_separator(*rit))
|
if (is_path_separator(*rit))
|
||||||
break;
|
break;
|
||||||
|
|
||||||
std::copy(string::const_iterator(rit.base()), filename.end(),
|
std::copy(std::string::const_iterator(rit.base()), filename.end(),
|
||||||
std::back_inserter(result));
|
std::back_inserter(result));
|
||||||
|
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
string get_file_extension(const string& filename)
|
std::string get_file_extension(const std::string& filename)
|
||||||
{
|
{
|
||||||
string::const_reverse_iterator rit;
|
std::string::const_reverse_iterator rit;
|
||||||
string result;
|
std::string result;
|
||||||
|
|
||||||
// search for the first dot from the end of the string
|
// search for the first dot from the end of the string
|
||||||
for (rit=filename.rbegin(); rit!=filename.rend(); ++rit) {
|
for (rit=filename.rbegin(); rit!=filename.rend(); ++rit) {
|
||||||
@ -72,18 +75,18 @@ string get_file_extension(const string& filename)
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (rit != filename.rend()) {
|
if (rit != filename.rend()) {
|
||||||
std::copy(string::const_iterator(rit.base()), filename.end(),
|
std::copy(std::string::const_iterator(rit.base()), filename.end(),
|
||||||
std::back_inserter(result));
|
std::back_inserter(result));
|
||||||
}
|
}
|
||||||
|
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
string get_file_title(const string& filename)
|
std::string get_file_title(const std::string& filename)
|
||||||
{
|
{
|
||||||
string::const_reverse_iterator rit;
|
std::string::const_reverse_iterator rit;
|
||||||
string::const_iterator last_dot = filename.end();
|
std::string::const_iterator last_dot = filename.end();
|
||||||
string result;
|
std::string result;
|
||||||
|
|
||||||
for (rit=filename.rbegin(); rit!=filename.rend(); ++rit) {
|
for (rit=filename.rbegin(); rit!=filename.rend(); ++rit) {
|
||||||
if (is_path_separator(*rit))
|
if (is_path_separator(*rit))
|
||||||
@ -92,7 +95,7 @@ string get_file_title(const string& filename)
|
|||||||
last_dot = rit.base()-1;
|
last_dot = rit.base()-1;
|
||||||
}
|
}
|
||||||
|
|
||||||
for (string::const_iterator it(rit.base()); it!=filename.end(); ++it) {
|
for (std::string::const_iterator it(rit.base()); it!=filename.end(); ++it) {
|
||||||
if (it == last_dot)
|
if (it == last_dot)
|
||||||
break;
|
break;
|
||||||
else
|
else
|
||||||
@ -102,9 +105,9 @@ string get_file_title(const string& filename)
|
|||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
string join_path(const string& path, const string& file)
|
std::string join_path(const std::string& path, const std::string& file)
|
||||||
{
|
{
|
||||||
string result(path);
|
std::string result(path);
|
||||||
|
|
||||||
// Add a separator at the end if it is necessay
|
// Add a separator at the end if it is necessay
|
||||||
if (!result.empty() && !is_path_separator(*(result.end()-1)))
|
if (!result.empty() && !is_path_separator(*(result.end()-1)))
|
||||||
@ -115,9 +118,9 @@ string join_path(const string& path, const string& file)
|
|||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
string remove_path_separator(const string& path)
|
std::string remove_path_separator(const std::string& path)
|
||||||
{
|
{
|
||||||
string result(path);
|
std::string result(path);
|
||||||
|
|
||||||
// Erase all trailing separators
|
// Erase all trailing separators
|
||||||
while (!result.empty() && is_path_separator(*(result.end()-1)))
|
while (!result.empty() && is_path_separator(*(result.end()-1)))
|
||||||
@ -126,9 +129,9 @@ string remove_path_separator(const string& path)
|
|||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
string fix_path_separators(const string& filename)
|
std::string fix_path_separators(const std::string& filename)
|
||||||
{
|
{
|
||||||
string result(filename);
|
std::string result(filename);
|
||||||
|
|
||||||
// Replace any separator with the system path separator.
|
// Replace any separator with the system path separator.
|
||||||
std::replace_if(result.begin(), result.end(),
|
std::replace_if(result.begin(), result.end(),
|
||||||
@ -137,13 +140,13 @@ string fix_path_separators(const string& filename)
|
|||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool has_file_extension(const string& filename, const string& csv_extensions)
|
bool has_file_extension(const std::string& filename, const std::string& csv_extensions)
|
||||||
{
|
{
|
||||||
if (!filename.empty()) {
|
if (!filename.empty()) {
|
||||||
string ext = string_to_lower(get_file_extension(filename));
|
std::string ext = base::string_to_lower(get_file_extension(filename));
|
||||||
|
|
||||||
int extsz = ext.size();
|
int extsz = ext.size();
|
||||||
string::const_iterator p =
|
std::string::const_iterator p =
|
||||||
std::search(csv_extensions.begin(),
|
std::search(csv_extensions.begin(),
|
||||||
csv_extensions.end(),
|
csv_extensions.end(),
|
||||||
ext.begin(), ext.end());
|
ext.begin(), ext.end());
|
||||||
|
@ -8,42 +8,42 @@
|
|||||||
#define BASE_PATH_H_INCLUDED
|
#define BASE_PATH_H_INCLUDED
|
||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
#include "base/string.h"
|
#include <string>
|
||||||
|
|
||||||
namespace base {
|
namespace base {
|
||||||
|
|
||||||
// Default path separator (on Windows it is '\' and on Unix-like systems it is '/').
|
// Default path separator (on Windows it is '\' and on Unix-like systems it is '/').
|
||||||
extern const string::value_type path_separator;
|
extern const std::string::value_type path_separator;
|
||||||
|
|
||||||
// Returns true if the given character is a valud path separator
|
// Returns true if the given character is a valud path separator
|
||||||
// (any of '\' or '/' characters).
|
// (any of '\' or '/' characters).
|
||||||
bool is_path_separator(string::value_type chr);
|
bool is_path_separator(std::string::value_type chr);
|
||||||
|
|
||||||
// Returns only the path (without the last trailing slash).
|
// Returns only the path (without the last trailing slash).
|
||||||
string get_file_path(const string& filename);
|
std::string get_file_path(const std::string& filename);
|
||||||
|
|
||||||
// Returns the file name with its extension, removing the path.
|
// Returns the file name with its extension, removing the path.
|
||||||
string get_file_name(const string& filename);
|
std::string get_file_name(const std::string& filename);
|
||||||
|
|
||||||
// Returns the extension of the file name (without the dot).
|
// Returns the extension of the file name (without the dot).
|
||||||
string get_file_extension(const string& filename);
|
std::string get_file_extension(const std::string& filename);
|
||||||
|
|
||||||
// Returns the file name without path and without extension.
|
// Returns the file name without path and without extension.
|
||||||
string get_file_title(const string& filename);
|
std::string get_file_title(const std::string& filename);
|
||||||
|
|
||||||
// Joins two paths or a path and a file name with a path-separator.
|
// Joins two paths or a path and a file name with a path-separator.
|
||||||
string join_path(const string& path, const string& file);
|
std::string join_path(const std::string& path, const std::string& file);
|
||||||
|
|
||||||
// Removes the trailing separator from the given path.
|
// Removes the trailing separator from the given path.
|
||||||
string remove_path_separator(const string& path);
|
std::string remove_path_separator(const std::string& path);
|
||||||
|
|
||||||
// Replaces all separators with the system separator.
|
// Replaces all separators with the system separator.
|
||||||
string fix_path_separators(const string& filename);
|
std::string fix_path_separators(const std::string& filename);
|
||||||
|
|
||||||
// Returns true if the filename contains one of the specified
|
// Returns true if the filename contains one of the specified
|
||||||
// extensions. The cvs_extensions parameter must be a set of
|
// extensions. The cvs_extensions parameter must be a set of
|
||||||
// possible extensions separated by comma.
|
// possible extensions separated by comma.
|
||||||
bool has_file_extension(const string& filename, const string& csv_extensions);
|
bool has_file_extension(const std::string& filename, const std::string& csv_extensions);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -89,7 +89,7 @@ TEST(Path, GetFileTitle)
|
|||||||
|
|
||||||
TEST(Path, JoinPath)
|
TEST(Path, JoinPath)
|
||||||
{
|
{
|
||||||
base::string sep;
|
std::string sep;
|
||||||
sep.push_back(path_separator);
|
sep.push_back(path_separator);
|
||||||
|
|
||||||
EXPECT_EQ("", join_path("", ""));
|
EXPECT_EQ("", join_path("", ""));
|
||||||
|
@ -15,14 +15,14 @@
|
|||||||
namespace {
|
namespace {
|
||||||
|
|
||||||
struct is_separator {
|
struct is_separator {
|
||||||
const base::string* separators;
|
const std::string* separators;
|
||||||
|
|
||||||
is_separator(const base::string* seps) : separators(seps) {
|
is_separator(const std::string* seps) : separators(seps) {
|
||||||
}
|
}
|
||||||
|
|
||||||
bool operator()(base::string::value_type chr)
|
bool operator()(std::string::value_type chr)
|
||||||
{
|
{
|
||||||
for (base::string::const_iterator
|
for (std::string::const_iterator
|
||||||
it = separators->begin(),
|
it = separators->begin(),
|
||||||
end = separators->end(); it != end; ++it) {
|
end = separators->end(); it != end; ++it) {
|
||||||
if (chr == *it)
|
if (chr == *it)
|
||||||
@ -34,9 +34,9 @@ namespace {
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void base::split_string(const base::string& string,
|
void base::split_string(const std::string& string,
|
||||||
std::vector<base::string>& parts,
|
std::vector<std::string>& parts,
|
||||||
const base::string& separators)
|
const std::string& separators)
|
||||||
{
|
{
|
||||||
size_t elements = 1 + std::count_if(string.begin(), string.end(), is_separator(&separators));
|
size_t elements = 1 + std::count_if(string.begin(), string.end(), is_separator(&separators));
|
||||||
parts.reserve(elements);
|
parts.reserve(elements);
|
||||||
@ -44,7 +44,7 @@ void base::split_string(const base::string& string,
|
|||||||
size_t beg = 0, end;
|
size_t beg = 0, end;
|
||||||
while (true) {
|
while (true) {
|
||||||
end = string.find_first_of(separators, beg);
|
end = string.find_first_of(separators, beg);
|
||||||
if (end != base::string::npos) {
|
if (end != std::string::npos) {
|
||||||
parts.push_back(string.substr(beg, end - beg));
|
parts.push_back(string.substr(beg, end - beg));
|
||||||
beg = end+1;
|
beg = end+1;
|
||||||
}
|
}
|
||||||
|
@ -8,14 +8,14 @@
|
|||||||
#define BASE_SPLIT_STRING_H_INCLUDED
|
#define BASE_SPLIT_STRING_H_INCLUDED
|
||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
#include "base/string.h"
|
#include <string>
|
||||||
#include <vector>
|
#include <vector>
|
||||||
|
|
||||||
namespace base {
|
namespace base {
|
||||||
|
|
||||||
void split_string(const base::string& string,
|
void split_string(const std::string& string,
|
||||||
std::vector<base::string>& parts,
|
std::vector<std::string>& parts,
|
||||||
const base::string& separators);
|
const std::string& separators);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -13,7 +13,7 @@
|
|||||||
|
|
||||||
TEST(SplitString, Empty)
|
TEST(SplitString, Empty)
|
||||||
{
|
{
|
||||||
std::vector<base::string> result;
|
std::vector<std::string> result;
|
||||||
base::split_string("", result, ",");
|
base::split_string("", result, ",");
|
||||||
ASSERT_EQ(1, result.size());
|
ASSERT_EQ(1, result.size());
|
||||||
EXPECT_EQ("", result[0]);
|
EXPECT_EQ("", result[0]);
|
||||||
@ -21,7 +21,7 @@ TEST(SplitString, Empty)
|
|||||||
|
|
||||||
TEST(SplitString, NoSeparator)
|
TEST(SplitString, NoSeparator)
|
||||||
{
|
{
|
||||||
std::vector<base::string> result;
|
std::vector<std::string> result;
|
||||||
base::split_string("Hello,World", result, "");
|
base::split_string("Hello,World", result, "");
|
||||||
ASSERT_EQ(1, result.size());
|
ASSERT_EQ(1, result.size());
|
||||||
EXPECT_EQ("Hello,World", result[0]);
|
EXPECT_EQ("Hello,World", result[0]);
|
||||||
@ -29,7 +29,7 @@ TEST(SplitString, NoSeparator)
|
|||||||
|
|
||||||
TEST(SplitString, OneSeparator)
|
TEST(SplitString, OneSeparator)
|
||||||
{
|
{
|
||||||
std::vector<base::string> result;
|
std::vector<std::string> result;
|
||||||
base::split_string("Hello,World", result, ",");
|
base::split_string("Hello,World", result, ",");
|
||||||
ASSERT_EQ(2, result.size());
|
ASSERT_EQ(2, result.size());
|
||||||
EXPECT_EQ("Hello", result[0]);
|
EXPECT_EQ("Hello", result[0]);
|
||||||
@ -38,7 +38,7 @@ TEST(SplitString, OneSeparator)
|
|||||||
|
|
||||||
TEST(SplitString, MultipleSeparators)
|
TEST(SplitString, MultipleSeparators)
|
||||||
{
|
{
|
||||||
std::vector<base::string> result;
|
std::vector<std::string> result;
|
||||||
base::split_string("Hello,World", result, ",r");
|
base::split_string("Hello,World", result, ",r");
|
||||||
ASSERT_EQ(3, result.size());
|
ASSERT_EQ(3, result.size());
|
||||||
EXPECT_EQ("Hello", result[0]);
|
EXPECT_EQ("Hello", result[0]);
|
||||||
|
@ -19,21 +19,21 @@
|
|||||||
|
|
||||||
namespace base {
|
namespace base {
|
||||||
|
|
||||||
string string_to_lower(const string& original)
|
std::string string_to_lower(const std::string& original)
|
||||||
{
|
{
|
||||||
string result(original);
|
std::string result(original);
|
||||||
|
|
||||||
for (string::iterator it=result.begin(); it!=result.end(); ++it)
|
for (std::string::iterator it=result.begin(); it!=result.end(); ++it)
|
||||||
*it = std::tolower(*it);
|
*it = std::tolower(*it);
|
||||||
|
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
string string_to_upper(const string& original)
|
std::string string_to_upper(const std::string& original)
|
||||||
{
|
{
|
||||||
string result(original);
|
std::string result(original);
|
||||||
|
|
||||||
for (string::iterator it=result.begin(); it!=result.end(); ++it)
|
for (std::string::iterator it=result.begin(); it!=result.end(); ++it)
|
||||||
*it = std::toupper(*it);
|
*it = std::toupper(*it);
|
||||||
|
|
||||||
return result;
|
return result;
|
||||||
@ -41,7 +41,7 @@ string string_to_upper(const string& original)
|
|||||||
|
|
||||||
#ifdef WIN32
|
#ifdef WIN32
|
||||||
|
|
||||||
string to_utf8(const std::wstring& src)
|
std::string to_utf8(const std::wstring& src)
|
||||||
{
|
{
|
||||||
int required_size =
|
int required_size =
|
||||||
::WideCharToMultiByte(CP_UTF8, 0,
|
::WideCharToMultiByte(CP_UTF8, 0,
|
||||||
@ -49,7 +49,7 @@ string to_utf8(const std::wstring& src)
|
|||||||
NULL, 0, NULL, NULL);
|
NULL, 0, NULL, NULL);
|
||||||
|
|
||||||
if (required_size == 0)
|
if (required_size == 0)
|
||||||
return string();
|
return std::string();
|
||||||
|
|
||||||
std::vector<char> buf(++required_size);
|
std::vector<char> buf(++required_size);
|
||||||
|
|
||||||
@ -58,10 +58,10 @@ string to_utf8(const std::wstring& src)
|
|||||||
&buf[0], required_size,
|
&buf[0], required_size,
|
||||||
NULL, NULL);
|
NULL, NULL);
|
||||||
|
|
||||||
return base::string(&buf[0]);
|
return std::string(&buf[0]);
|
||||||
}
|
}
|
||||||
|
|
||||||
std::wstring from_utf8(const string& src)
|
std::wstring from_utf8(const std::string& src)
|
||||||
{
|
{
|
||||||
int required_size =
|
int required_size =
|
||||||
MultiByteToWideChar(CP_UTF8, 0,
|
MultiByteToWideChar(CP_UTF8, 0,
|
||||||
@ -83,7 +83,7 @@ std::wstring from_utf8(const string& src)
|
|||||||
#else
|
#else
|
||||||
|
|
||||||
// Based on Allegro Unicode code (allegro/src/unicode.c)
|
// Based on Allegro Unicode code (allegro/src/unicode.c)
|
||||||
static size_t insert_utf8_char(string* result, wchar_t chr)
|
static size_t insert_utf8_char(std::string* result, wchar_t chr)
|
||||||
{
|
{
|
||||||
int size, bits, b, i;
|
int size, bits, b, i;
|
||||||
|
|
||||||
@ -122,7 +122,7 @@ static size_t insert_utf8_char(string* result, wchar_t chr)
|
|||||||
return size;
|
return size;
|
||||||
}
|
}
|
||||||
|
|
||||||
string to_utf8(const std::wstring& src)
|
std::string to_utf8(const std::wstring& src)
|
||||||
{
|
{
|
||||||
std::wstring::const_iterator it, begin = src.begin();
|
std::wstring::const_iterator it, begin = src.begin();
|
||||||
std::wstring::const_iterator end = src.end();
|
std::wstring::const_iterator end = src.end();
|
||||||
@ -135,14 +135,14 @@ string to_utf8(const std::wstring& src)
|
|||||||
if (!required_size)
|
if (!required_size)
|
||||||
return "";
|
return "";
|
||||||
|
|
||||||
string result;
|
std::string result;
|
||||||
result.reserve(++required_size);
|
result.reserve(++required_size);
|
||||||
for (it = begin; it != end; ++it)
|
for (it = begin; it != end; ++it)
|
||||||
insert_utf8_char(&result, *it);
|
insert_utf8_char(&result, *it);
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
std::wstring from_utf8(const string& src)
|
std::wstring from_utf8(const std::string& src)
|
||||||
{
|
{
|
||||||
int required_size = utf8_length(src);
|
int required_size = utf8_length(src);
|
||||||
std::vector<wchar_t> buf(++required_size);
|
std::vector<wchar_t> buf(++required_size);
|
||||||
@ -163,7 +163,7 @@ std::wstring from_utf8(const string& src)
|
|||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
int utf8_length(const string& utf8string)
|
int utf8_length(const std::string& utf8string)
|
||||||
{
|
{
|
||||||
utf8_const_iterator it(utf8string.begin());
|
utf8_const_iterator it(utf8string.begin());
|
||||||
utf8_const_iterator end(utf8string.end());
|
utf8_const_iterator end(utf8string.end());
|
||||||
|
@ -13,20 +13,18 @@
|
|||||||
|
|
||||||
namespace base {
|
namespace base {
|
||||||
|
|
||||||
typedef std::string string;
|
std::string string_to_lower(const std::string& original);
|
||||||
|
std::string string_to_upper(const std::string& original);
|
||||||
|
|
||||||
string string_to_lower(const string& original);
|
std::string to_utf8(const std::wstring& widestring);
|
||||||
string string_to_upper(const string& original);
|
std::wstring from_utf8(const std::string& utf8string);
|
||||||
|
|
||||||
string to_utf8(const std::wstring& widestring);
|
int utf8_length(const std::string& utf8string);
|
||||||
std::wstring from_utf8(const string& utf8string);
|
|
||||||
|
|
||||||
int utf8_length(const string& utf8string);
|
|
||||||
|
|
||||||
template<typename SubIterator>
|
template<typename SubIterator>
|
||||||
class utf8_iteratorT : public std::iterator<std::forward_iterator_tag,
|
class utf8_iteratorT : public std::iterator<std::forward_iterator_tag,
|
||||||
string::value_type,
|
std::string::value_type,
|
||||||
string::difference_type,
|
std::string::difference_type,
|
||||||
typename SubIterator::pointer,
|
typename SubIterator::pointer,
|
||||||
typename SubIterator::reference> {
|
typename SubIterator::reference> {
|
||||||
public:
|
public:
|
||||||
@ -118,23 +116,23 @@ namespace base {
|
|||||||
SubIterator m_internal;
|
SubIterator m_internal;
|
||||||
};
|
};
|
||||||
|
|
||||||
class utf8_iterator : public utf8_iteratorT<string::iterator> {
|
class utf8_iterator : public utf8_iteratorT<std::string::iterator> {
|
||||||
public:
|
public:
|
||||||
utf8_iterator(const utf8_iteratorT<string::iterator>& it)
|
utf8_iterator(const utf8_iteratorT<std::string::iterator>& it)
|
||||||
: utf8_iteratorT<string::iterator>(it) {
|
: utf8_iteratorT<std::string::iterator>(it) {
|
||||||
}
|
}
|
||||||
explicit utf8_iterator(const string::iterator& it)
|
explicit utf8_iterator(const std::string::iterator& it)
|
||||||
: utf8_iteratorT<string::iterator>(it) {
|
: utf8_iteratorT<std::string::iterator>(it) {
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
class utf8_const_iterator : public utf8_iteratorT<string::const_iterator> {
|
class utf8_const_iterator : public utf8_iteratorT<std::string::const_iterator> {
|
||||||
public:
|
public:
|
||||||
utf8_const_iterator(const utf8_iteratorT<string::const_iterator>& it)
|
utf8_const_iterator(const utf8_iteratorT<std::string::const_iterator>& it)
|
||||||
: utf8_iteratorT<string::const_iterator>(it) {
|
: utf8_iteratorT<std::string::const_iterator>(it) {
|
||||||
}
|
}
|
||||||
explicit utf8_const_iterator(const string::const_iterator& it)
|
explicit utf8_const_iterator(const std::string::const_iterator& it)
|
||||||
: utf8_iteratorT<string::const_iterator>(it) {
|
: utf8_iteratorT<std::string::const_iterator>(it) {
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -30,7 +30,7 @@ TEST(String, Utf8Conversion)
|
|||||||
|
|
||||||
TEST(String, Utf8Iterator)
|
TEST(String, Utf8Iterator)
|
||||||
{
|
{
|
||||||
string a = "Hello";
|
std::string a = "Hello";
|
||||||
int value = std::count_if(utf8_iterator(a.begin()),
|
int value = std::count_if(utf8_iterator(a.begin()),
|
||||||
utf8_iterator(a.end()), all);
|
utf8_iterator(a.end()), all);
|
||||||
ASSERT_EQ(5, value);
|
ASSERT_EQ(5, value);
|
||||||
@ -40,7 +40,7 @@ TEST(String, Utf8Iterator)
|
|||||||
ASSERT_EQ('l', *(utf8_iterator(a.begin())+3));
|
ASSERT_EQ('l', *(utf8_iterator(a.begin())+3));
|
||||||
ASSERT_EQ('o', *(utf8_iterator(a.begin())+4));
|
ASSERT_EQ('o', *(utf8_iterator(a.begin())+4));
|
||||||
|
|
||||||
string b = "Copyright \xC2\xA9";
|
std::string b = "Copyright \xC2\xA9";
|
||||||
value = std::count_if(utf8_iterator(b.begin()),
|
value = std::count_if(utf8_iterator(b.begin()),
|
||||||
utf8_iterator(b.end()), all);
|
utf8_iterator(b.end()), all);
|
||||||
ASSERT_EQ(11, value);
|
ASSERT_EQ(11, value);
|
||||||
@ -49,7 +49,7 @@ TEST(String, Utf8Iterator)
|
|||||||
ASSERT_EQ(0xA9, *(utf8_iterator(b.begin())+10));
|
ASSERT_EQ(0xA9, *(utf8_iterator(b.begin())+10));
|
||||||
ASSERT_TRUE((utf8_iterator(b.begin())+11) == utf8_iterator(b.end()));
|
ASSERT_TRUE((utf8_iterator(b.begin())+11) == utf8_iterator(b.end()));
|
||||||
|
|
||||||
string c = "\xf0\x90\x8d\x86\xe6\x97\xa5\xd1\x88";
|
std::string c = "\xf0\x90\x8d\x86\xe6\x97\xa5\xd1\x88";
|
||||||
value = std::count_if(utf8_iterator(c.begin()),
|
value = std::count_if(utf8_iterator(c.begin()),
|
||||||
utf8_iterator(c.end()), all);
|
utf8_iterator(c.end()), all);
|
||||||
ASSERT_EQ(3, value);
|
ASSERT_EQ(3, value);
|
||||||
@ -58,7 +58,7 @@ TEST(String, Utf8Iterator)
|
|||||||
ASSERT_EQ(0x448, *(utf8_iterator(c.begin())+2));
|
ASSERT_EQ(0x448, *(utf8_iterator(c.begin())+2));
|
||||||
ASSERT_TRUE((utf8_iterator(c.begin())+3) == utf8_iterator(c.end()));
|
ASSERT_TRUE((utf8_iterator(c.begin())+3) == utf8_iterator(c.end()));
|
||||||
|
|
||||||
string d = "\xf0\xa4\xad\xa2";
|
std::string d = "\xf0\xa4\xad\xa2";
|
||||||
value = std::count_if(utf8_iterator(d.begin()),
|
value = std::count_if(utf8_iterator(d.begin()),
|
||||||
utf8_iterator(d.end()), all);
|
utf8_iterator(d.end()), all);
|
||||||
ASSERT_EQ(1, value);
|
ASSERT_EQ(1, value);
|
||||||
|
@ -22,11 +22,11 @@ TempDir::TempDir()
|
|||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
TempDir::TempDir(const string& appName)
|
TempDir::TempDir(const std::string& appName)
|
||||||
{
|
{
|
||||||
for (int i=(std::rand()%0xffff); ; ++i) {
|
for (int i=(std::rand()%0xffff); ; ++i) {
|
||||||
m_path = join_path(get_temp_path(),
|
m_path = join_path(get_temp_path(),
|
||||||
appName + convert_to<string>(i));
|
appName + convert_to<std::string>(i));
|
||||||
|
|
||||||
if (!is_directory(m_path)) {
|
if (!is_directory(m_path)) {
|
||||||
make_directory(m_path);
|
make_directory(m_path);
|
||||||
@ -53,7 +53,7 @@ void TempDir::remove()
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void TempDir::attach(const string& path)
|
void TempDir::attach(const std::string& path)
|
||||||
{
|
{
|
||||||
remove();
|
remove();
|
||||||
|
|
||||||
|
@ -8,22 +8,22 @@
|
|||||||
#define BASE_TEMP_DIR_H_INCLUDED
|
#define BASE_TEMP_DIR_H_INCLUDED
|
||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
#include "base/string.h"
|
#include <string>
|
||||||
|
|
||||||
namespace base {
|
namespace base {
|
||||||
|
|
||||||
class TempDir {
|
class TempDir {
|
||||||
public:
|
public:
|
||||||
TempDir();
|
TempDir();
|
||||||
TempDir(const string& appName);
|
TempDir(const std::string& appName);
|
||||||
~TempDir();
|
~TempDir();
|
||||||
|
|
||||||
void remove();
|
void remove();
|
||||||
void attach(const string& path);
|
void attach(const std::string& path);
|
||||||
const string& path() const { return m_path; }
|
const std::string& path() const { return m_path; }
|
||||||
|
|
||||||
private:
|
private:
|
||||||
string m_path;
|
std::string m_path;
|
||||||
};
|
};
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -11,7 +11,7 @@
|
|||||||
#include "base/trim_string.h"
|
#include "base/trim_string.h"
|
||||||
#include <cctype>
|
#include <cctype>
|
||||||
|
|
||||||
void base::trim_string(const base::string& input, base::string& output)
|
void base::trim_string(const std::string& input, std::string& output)
|
||||||
{
|
{
|
||||||
int i, j;
|
int i, j;
|
||||||
|
|
||||||
|
@ -8,11 +8,11 @@
|
|||||||
#define BASE_TRIM_STRING_H_INCLUDED
|
#define BASE_TRIM_STRING_H_INCLUDED
|
||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
#include "base/string.h"
|
#include <string>
|
||||||
|
|
||||||
namespace base {
|
namespace base {
|
||||||
|
|
||||||
void trim_string(const base::string& input, base::string& output);
|
void trim_string(const std::string& input, std::string& output);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -13,7 +13,7 @@ using namespace base;
|
|||||||
|
|
||||||
std::ostream& operator<<(std::ostream& os, const Version& ver)
|
std::ostream& operator<<(std::ostream& os, const Version& ver)
|
||||||
{
|
{
|
||||||
return os << convert_to<string>(ver);
|
return os << convert_to<std::string>(ver);
|
||||||
}
|
}
|
||||||
|
|
||||||
TEST(Version, Ctor)
|
TEST(Version, Ctor)
|
||||||
@ -50,21 +50,21 @@ TEST(Version, Ctor)
|
|||||||
|
|
||||||
TEST(Version, StringToVersion)
|
TEST(Version, StringToVersion)
|
||||||
{
|
{
|
||||||
EXPECT_EQ(Version(), convert_to<Version>(string("")));
|
EXPECT_EQ(Version(), convert_to<Version>(std::string("")));
|
||||||
EXPECT_EQ(Version(1), convert_to<Version>(string("1")));
|
EXPECT_EQ(Version(1), convert_to<Version>(std::string("1")));
|
||||||
EXPECT_EQ(Version(1, 2), convert_to<Version>(string("1.2")));
|
EXPECT_EQ(Version(1, 2), convert_to<Version>(std::string("1.2")));
|
||||||
EXPECT_EQ(Version(1, 2, 3), convert_to<Version>(string("1.2.3")));
|
EXPECT_EQ(Version(1, 2, 3), convert_to<Version>(std::string("1.2.3")));
|
||||||
EXPECT_EQ(Version(1, 2, 3, 4), convert_to<Version>(string("1.2.3.4")));
|
EXPECT_EQ(Version(1, 2, 3, 4), convert_to<Version>(std::string("1.2.3.4")));
|
||||||
}
|
}
|
||||||
|
|
||||||
TEST(Version, VersionToString)
|
TEST(Version, VersionToString)
|
||||||
{
|
{
|
||||||
EXPECT_EQ("", convert_to<string>(Version()));
|
EXPECT_EQ("", convert_to<std::string>(Version()));
|
||||||
EXPECT_EQ("0", convert_to<string>(Version(0)));
|
EXPECT_EQ("0", convert_to<std::string>(Version(0)));
|
||||||
EXPECT_EQ("1", convert_to<string>(Version(1)));
|
EXPECT_EQ("1", convert_to<std::string>(Version(1)));
|
||||||
EXPECT_EQ("1.0", convert_to<string>(Version(1, 0)));
|
EXPECT_EQ("1.0", convert_to<std::string>(Version(1, 0)));
|
||||||
EXPECT_EQ("0.0", convert_to<string>(Version(0, 0)));
|
EXPECT_EQ("0.0", convert_to<std::string>(Version(0, 0)));
|
||||||
EXPECT_EQ("1.0.2", convert_to<string>(Version(1, 0, 2)));
|
EXPECT_EQ("1.0.2", convert_to<std::string>(Version(1, 0, 2)));
|
||||||
}
|
}
|
||||||
|
|
||||||
TEST(Version, Equal)
|
TEST(Version, Equal)
|
||||||
|
@ -23,6 +23,7 @@
|
|||||||
#include "raster/palette.h"
|
#include "raster/palette.h"
|
||||||
|
|
||||||
#include "base/path.h"
|
#include "base/path.h"
|
||||||
|
#include "base/string.h"
|
||||||
#include "gfx/hsv.h"
|
#include "gfx/hsv.h"
|
||||||
#include "gfx/rgb.h"
|
#include "gfx/rgb.h"
|
||||||
#include "raster/conversion_alleg.h"
|
#include "raster/conversion_alleg.h"
|
||||||
@ -406,7 +407,7 @@ void Palette::sort(int from, int to, SortPalette* sort_palette, std::vector<int>
|
|||||||
|
|
||||||
Palette* Palette::load(const char *filename)
|
Palette* Palette::load(const char *filename)
|
||||||
{
|
{
|
||||||
base::string ext = base::string_to_lower(base::get_file_extension(filename));
|
std::string ext = base::string_to_lower(base::get_file_extension(filename));
|
||||||
Palette* pal = NULL;
|
Palette* pal = NULL;
|
||||||
|
|
||||||
if (ext == "png" ||
|
if (ext == "png" ||
|
||||||
@ -440,7 +441,7 @@ Palette* Palette::load(const char *filename)
|
|||||||
|
|
||||||
bool Palette::save(const char *filename) const
|
bool Palette::save(const char *filename) const
|
||||||
{
|
{
|
||||||
base::string ext = base::string_to_lower(base::get_file_extension(filename));
|
std::string ext = base::string_to_lower(base::get_file_extension(filename));
|
||||||
bool success = false;
|
bool success = false;
|
||||||
|
|
||||||
if (ext == "png" ||
|
if (ext == "png" ||
|
||||||
|
@ -24,7 +24,7 @@
|
|||||||
|
|
||||||
namespace ui {
|
namespace ui {
|
||||||
|
|
||||||
ButtonBase::ButtonBase(const base::string& text,
|
ButtonBase::ButtonBase(const std::string& text,
|
||||||
WidgetType type,
|
WidgetType type,
|
||||||
WidgetType behaviorType,
|
WidgetType behaviorType,
|
||||||
WidgetType drawType)
|
WidgetType drawType)
|
||||||
@ -307,7 +307,7 @@ void ButtonBase::generateButtonSelectSignal()
|
|||||||
// Button class
|
// Button class
|
||||||
// ======================================================================
|
// ======================================================================
|
||||||
|
|
||||||
Button::Button(const base::string& text)
|
Button::Button(const std::string& text)
|
||||||
: ButtonBase(text, kButtonWidget, kButtonWidget, kButtonWidget)
|
: ButtonBase(text, kButtonWidget, kButtonWidget, kButtonWidget)
|
||||||
{
|
{
|
||||||
setAlign(JI_CENTER | JI_MIDDLE);
|
setAlign(JI_CENTER | JI_MIDDLE);
|
||||||
@ -317,7 +317,7 @@ Button::Button(const base::string& text)
|
|||||||
// CheckBox class
|
// CheckBox class
|
||||||
// ======================================================================
|
// ======================================================================
|
||||||
|
|
||||||
CheckBox::CheckBox(const base::string& text, WidgetType drawType)
|
CheckBox::CheckBox(const std::string& text, WidgetType drawType)
|
||||||
: ButtonBase(text, kCheckWidget, kCheckWidget, drawType)
|
: ButtonBase(text, kCheckWidget, kCheckWidget, drawType)
|
||||||
{
|
{
|
||||||
setAlign(JI_LEFT | JI_MIDDLE);
|
setAlign(JI_LEFT | JI_MIDDLE);
|
||||||
@ -327,7 +327,7 @@ CheckBox::CheckBox(const base::string& text, WidgetType drawType)
|
|||||||
// RadioButton class
|
// RadioButton class
|
||||||
// ======================================================================
|
// ======================================================================
|
||||||
|
|
||||||
RadioButton::RadioButton(const base::string& text, int radioGroup, WidgetType drawType)
|
RadioButton::RadioButton(const std::string& text, int radioGroup, WidgetType drawType)
|
||||||
: ButtonBase(text, kRadioWidget, kRadioWidget, drawType)
|
: ButtonBase(text, kRadioWidget, kRadioWidget, drawType)
|
||||||
{
|
{
|
||||||
setAlign(JI_LEFT | JI_MIDDLE);
|
setAlign(JI_LEFT | JI_MIDDLE);
|
||||||
|
@ -37,7 +37,7 @@ namespace ui {
|
|||||||
class ButtonBase : public Widget
|
class ButtonBase : public Widget
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
ButtonBase(const base::string& text,
|
ButtonBase(const std::string& text,
|
||||||
WidgetType type,
|
WidgetType type,
|
||||||
WidgetType behaviorType,
|
WidgetType behaviorType,
|
||||||
WidgetType drawType);
|
WidgetType drawType);
|
||||||
@ -81,21 +81,21 @@ namespace ui {
|
|||||||
class Button : public ButtonBase
|
class Button : public ButtonBase
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
Button(const base::string& text);
|
Button(const std::string& text);
|
||||||
};
|
};
|
||||||
|
|
||||||
// Check boxes
|
// Check boxes
|
||||||
class CheckBox : public ButtonBase
|
class CheckBox : public ButtonBase
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
CheckBox(const base::string& text, WidgetType drawType = kCheckWidget);
|
CheckBox(const std::string& text, WidgetType drawType = kCheckWidget);
|
||||||
};
|
};
|
||||||
|
|
||||||
// Radio buttons
|
// Radio buttons
|
||||||
class RadioButton : public ButtonBase
|
class RadioButton : public ButtonBase
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
RadioButton(const base::string& text, int radioGroup, WidgetType drawType = kRadioWidget);
|
RadioButton(const std::string& text, int radioGroup, WidgetType drawType = kRadioWidget);
|
||||||
|
|
||||||
int getRadioGroup() const;
|
int getRadioGroup() const;
|
||||||
void setRadioGroup(int radioGroup);
|
void setRadioGroup(int radioGroup);
|
||||||
|
@ -163,7 +163,7 @@ int ComboBox::addItem(ListItem* item)
|
|||||||
return m_items.size()-1;
|
return m_items.size()-1;
|
||||||
}
|
}
|
||||||
|
|
||||||
int ComboBox::addItem(const base::string& text)
|
int ComboBox::addItem(const std::string& text)
|
||||||
{
|
{
|
||||||
return addItem(new ListItem(text));
|
return addItem(new ListItem(text));
|
||||||
}
|
}
|
||||||
@ -178,7 +178,7 @@ void ComboBox::insertItem(int itemIndex, ListItem* item)
|
|||||||
setSelectedItemIndex(0);
|
setSelectedItemIndex(0);
|
||||||
}
|
}
|
||||||
|
|
||||||
void ComboBox::insertItem(int itemIndex, const base::string& text)
|
void ComboBox::insertItem(int itemIndex, const std::string& text)
|
||||||
{
|
{
|
||||||
insertItem(itemIndex, new ListItem(text));
|
insertItem(itemIndex, new ListItem(text));
|
||||||
}
|
}
|
||||||
@ -228,7 +228,7 @@ ListItem* ComboBox::getItem(int itemIndex)
|
|||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
const base::string& ComboBox::getItemText(int itemIndex) const
|
const std::string& ComboBox::getItemText(int itemIndex) const
|
||||||
{
|
{
|
||||||
if (itemIndex >= 0 && (size_t)itemIndex < m_items.size()) {
|
if (itemIndex >= 0 && (size_t)itemIndex < m_items.size()) {
|
||||||
ListItem* item = m_items[itemIndex];
|
ListItem* item = m_items[itemIndex];
|
||||||
@ -241,7 +241,7 @@ const base::string& ComboBox::getItemText(int itemIndex) const
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void ComboBox::setItemText(int itemIndex, const base::string& text)
|
void ComboBox::setItemText(int itemIndex, const std::string& text)
|
||||||
{
|
{
|
||||||
ASSERT(itemIndex >= 0 && (size_t)itemIndex < m_items.size());
|
ASSERT(itemIndex >= 0 && (size_t)itemIndex < m_items.size());
|
||||||
|
|
||||||
@ -249,7 +249,7 @@ void ComboBox::setItemText(int itemIndex, const base::string& text)
|
|||||||
item->setText(text);
|
item->setText(text);
|
||||||
}
|
}
|
||||||
|
|
||||||
int ComboBox::findItemIndex(const base::string& text)
|
int ComboBox::findItemIndex(const std::string& text)
|
||||||
{
|
{
|
||||||
int itemIndex = 0;
|
int itemIndex = 0;
|
||||||
|
|
||||||
|
@ -49,9 +49,9 @@ namespace ui {
|
|||||||
bool isCaseSensitive();
|
bool isCaseSensitive();
|
||||||
|
|
||||||
int addItem(ListItem* item);
|
int addItem(ListItem* item);
|
||||||
int addItem(const base::string& text);
|
int addItem(const std::string& text);
|
||||||
void insertItem(int itemIndex, ListItem* item);
|
void insertItem(int itemIndex, ListItem* item);
|
||||||
void insertItem(int itemIndex, const base::string& text);
|
void insertItem(int itemIndex, const std::string& text);
|
||||||
|
|
||||||
// Removes the given item (you must delete it).
|
// Removes the given item (you must delete it).
|
||||||
void removeItem(ListItem* item);
|
void removeItem(ListItem* item);
|
||||||
@ -64,9 +64,9 @@ namespace ui {
|
|||||||
int getItemCount() const;
|
int getItemCount() const;
|
||||||
|
|
||||||
ListItem* getItem(int itemIndex);
|
ListItem* getItem(int itemIndex);
|
||||||
const base::string& getItemText(int itemIndex) const;
|
const std::string& getItemText(int itemIndex) const;
|
||||||
void setItemText(int itemIndex, const base::string& text);
|
void setItemText(int itemIndex, const std::string& text);
|
||||||
int findItemIndex(const base::string& text);
|
int findItemIndex(const std::string& text);
|
||||||
|
|
||||||
ListItem* getSelectedItem() const;
|
ListItem* getSelectedItem() const;
|
||||||
void setSelectedItem(ListItem* item);
|
void setSelectedItem(ListItem* item);
|
||||||
|
@ -22,7 +22,7 @@ Component::~Component()
|
|||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
PropertyPtr Component::getProperty(const base::string& name)
|
PropertyPtr Component::getProperty(const std::string& name)
|
||||||
{
|
{
|
||||||
Properties::iterator it = m_properties.find(name);
|
Properties::iterator it = m_properties.find(name);
|
||||||
if (it != m_properties.end())
|
if (it != m_properties.end())
|
||||||
@ -36,13 +36,13 @@ void Component::setProperty(PropertyPtr property)
|
|||||||
m_properties[property->getName()] = property;
|
m_properties[property->getName()] = property;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool Component::hasProperty(const base::string& name)
|
bool Component::hasProperty(const std::string& name)
|
||||||
{
|
{
|
||||||
Properties::iterator it = m_properties.find(name);
|
Properties::iterator it = m_properties.find(name);
|
||||||
return it != m_properties.end();
|
return it != m_properties.end();
|
||||||
}
|
}
|
||||||
|
|
||||||
void Component::removeProperty(const base::string& name)
|
void Component::removeProperty(const std::string& name)
|
||||||
{
|
{
|
||||||
Properties::iterator it = m_properties.find(name);
|
Properties::iterator it = m_properties.find(name);
|
||||||
if (it != m_properties.end())
|
if (it != m_properties.end())
|
||||||
|
@ -8,12 +8,12 @@
|
|||||||
#define UI_COMPONENT_H_INCLUDED
|
#define UI_COMPONENT_H_INCLUDED
|
||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
#include <map>
|
|
||||||
|
|
||||||
#include "base/disable_copying.h"
|
#include "base/disable_copying.h"
|
||||||
#include "base/string.h"
|
|
||||||
#include "ui/property.h"
|
#include "ui/property.h"
|
||||||
|
|
||||||
|
#include <map>
|
||||||
|
#include <string>
|
||||||
|
|
||||||
namespace ui {
|
namespace ui {
|
||||||
|
|
||||||
// A component is a visual object, such as widgets or menus.
|
// A component is a visual object, such as widgets or menus.
|
||||||
@ -22,16 +22,16 @@ namespace ui {
|
|||||||
class Component
|
class Component
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
typedef std::map<base::string, PropertyPtr> Properties;
|
typedef std::map<std::string, PropertyPtr> Properties;
|
||||||
|
|
||||||
Component();
|
Component();
|
||||||
virtual ~Component();
|
virtual ~Component();
|
||||||
|
|
||||||
PropertyPtr getProperty(const base::string& name);
|
PropertyPtr getProperty(const std::string& name);
|
||||||
void setProperty(PropertyPtr property);
|
void setProperty(PropertyPtr property);
|
||||||
|
|
||||||
bool hasProperty(const base::string& name);
|
bool hasProperty(const std::string& name);
|
||||||
void removeProperty(const base::string& name);
|
void removeProperty(const std::string& name);
|
||||||
|
|
||||||
const Properties& getProperties() const;
|
const Properties& getProperties() const;
|
||||||
|
|
||||||
|
@ -12,7 +12,7 @@
|
|||||||
|
|
||||||
namespace ui {
|
namespace ui {
|
||||||
|
|
||||||
CustomLabel::CustomLabel(const base::string& text)
|
CustomLabel::CustomLabel(const std::string& text)
|
||||||
: Label(text)
|
: Label(text)
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
@ -16,7 +16,7 @@ namespace ui {
|
|||||||
class CustomLabel : public Label
|
class CustomLabel : public Label
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
CustomLabel(const base::string& text);
|
CustomLabel(const std::string& text);
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
bool onProcessMessage(Message* msg) OVERRIDE;
|
bool onProcessMessage(Message* msg) OVERRIDE;
|
||||||
|
@ -581,7 +581,7 @@ void Entry::executeCmd(EntryCmd::Type cmd, int unicodeChar, bool shift_pressed)
|
|||||||
const char* clipboard_str;
|
const char* clipboard_str;
|
||||||
|
|
||||||
if ((clipboard_str = clipboard::get_text())) {
|
if ((clipboard_str = clipboard::get_text())) {
|
||||||
base::string clipboard(clipboard_str);
|
std::string clipboard(clipboard_str);
|
||||||
|
|
||||||
// delete the entire selection
|
// delete the entire selection
|
||||||
if (selbeg >= 0) {
|
if (selbeg >= 0) {
|
||||||
@ -629,7 +629,7 @@ void Entry::executeCmd(EntryCmd::Type cmd, int unicodeChar, bool shift_pressed)
|
|||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
base::string newText = base::to_utf8(text);
|
std::string newText = base::to_utf8(text);
|
||||||
if (newText != getText()) {
|
if (newText != getText()) {
|
||||||
setText(newText.c_str());
|
setText(newText.c_str());
|
||||||
onEntryChange();
|
onEntryChange();
|
||||||
|
@ -15,7 +15,7 @@
|
|||||||
|
|
||||||
namespace ui {
|
namespace ui {
|
||||||
|
|
||||||
Label::Label(const base::string& text)
|
Label::Label(const std::string& text)
|
||||||
: Widget(kLabelWidget)
|
: Widget(kLabelWidget)
|
||||||
{
|
{
|
||||||
setAlign(JI_LEFT | JI_MIDDLE);
|
setAlign(JI_LEFT | JI_MIDDLE);
|
||||||
|
@ -17,7 +17,7 @@ namespace ui {
|
|||||||
class Label : public Widget
|
class Label : public Widget
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
Label(const base::string& text);
|
Label(const std::string& text);
|
||||||
|
|
||||||
Color getTextColor() const;
|
Color getTextColor() const;
|
||||||
void setTextColor(Color color);
|
void setTextColor(Color color);
|
||||||
|
@ -18,19 +18,19 @@
|
|||||||
|
|
||||||
namespace ui {
|
namespace ui {
|
||||||
|
|
||||||
LinkLabel::LinkLabel(const base::string& urlOrText)
|
LinkLabel::LinkLabel(const std::string& urlOrText)
|
||||||
: CustomLabel(urlOrText)
|
: CustomLabel(urlOrText)
|
||||||
, m_url(urlOrText)
|
, m_url(urlOrText)
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
LinkLabel::LinkLabel(const base::string& url, const base::string& text)
|
LinkLabel::LinkLabel(const std::string& url, const std::string& text)
|
||||||
: CustomLabel(text)
|
: CustomLabel(text)
|
||||||
, m_url(url)
|
, m_url(url)
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
void LinkLabel::setUrl(const base::string& url)
|
void LinkLabel::setUrl(const std::string& url)
|
||||||
{
|
{
|
||||||
m_url = url;
|
m_url = url;
|
||||||
}
|
}
|
||||||
|
@ -16,14 +16,13 @@
|
|||||||
|
|
||||||
namespace ui {
|
namespace ui {
|
||||||
|
|
||||||
class LinkLabel : public CustomLabel
|
class LinkLabel : public CustomLabel {
|
||||||
{
|
|
||||||
public:
|
public:
|
||||||
LinkLabel(const base::string& urlOrText);
|
LinkLabel(const std::string& urlOrText);
|
||||||
LinkLabel(const base::string& url, const base::string& text);
|
LinkLabel(const std::string& url, const std::string& text);
|
||||||
|
|
||||||
const base::string& getUrl() const { return m_url; }
|
const std::string& getUrl() const { return m_url; }
|
||||||
void setUrl(const base::string& url);
|
void setUrl(const std::string& url);
|
||||||
|
|
||||||
Signal0<void> Click;
|
Signal0<void> Click;
|
||||||
|
|
||||||
@ -31,7 +30,7 @@ namespace ui {
|
|||||||
bool onProcessMessage(Message* msg) OVERRIDE;
|
bool onProcessMessage(Message* msg) OVERRIDE;
|
||||||
void onPaint(PaintEvent& ev) OVERRIDE;
|
void onPaint(PaintEvent& ev) OVERRIDE;
|
||||||
|
|
||||||
base::string m_url;
|
std::string m_url;
|
||||||
};
|
};
|
||||||
|
|
||||||
} // namespace ui
|
} // namespace ui
|
||||||
|
@ -20,7 +20,7 @@ namespace ui {
|
|||||||
|
|
||||||
using namespace gfx;
|
using namespace gfx;
|
||||||
|
|
||||||
ListItem::ListItem(const base::string& text)
|
ListItem::ListItem(const std::string& text)
|
||||||
: Widget(kListItemWidget)
|
: Widget(kListItemWidget)
|
||||||
{
|
{
|
||||||
setDoubleBuffered(true);
|
setDoubleBuffered(true);
|
||||||
|
@ -16,7 +16,7 @@ namespace ui {
|
|||||||
class ListItem : public Widget
|
class ListItem : public Widget
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
ListItem(const base::string& text);
|
ListItem(const std::string& text);
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
void onPaint(PaintEvent& ev) OVERRIDE;
|
void onPaint(PaintEvent& ev) OVERRIDE;
|
||||||
|
@ -165,7 +165,7 @@ MenuBar::MenuBar()
|
|||||||
createBase();
|
createBase();
|
||||||
}
|
}
|
||||||
|
|
||||||
MenuItem::MenuItem(const base::string& text)
|
MenuItem::MenuItem(const std::string& text)
|
||||||
: Widget(kMenuItemWidget)
|
: Widget(kMenuItemWidget)
|
||||||
{
|
{
|
||||||
m_accel = NULL;
|
m_accel = NULL;
|
||||||
|
@ -96,7 +96,7 @@ namespace ui {
|
|||||||
class MenuItem : public Widget
|
class MenuItem : public Widget
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
MenuItem(const base::string& text);
|
MenuItem(const std::string& text);
|
||||||
~MenuItem();
|
~MenuItem();
|
||||||
|
|
||||||
Menu* getSubmenu();
|
Menu* getSubmenu();
|
||||||
|
@ -21,7 +21,7 @@ namespace ui {
|
|||||||
|
|
||||||
using namespace gfx;
|
using namespace gfx;
|
||||||
|
|
||||||
PopupWindow::PopupWindow(const base::string& text, ClickBehavior clickBehavior)
|
PopupWindow::PopupWindow(const std::string& text, ClickBehavior clickBehavior)
|
||||||
: Window(WithTitleBar, text)
|
: Window(WithTitleBar, text)
|
||||||
, m_clickBehavior(clickBehavior)
|
, m_clickBehavior(clickBehavior)
|
||||||
, m_filtering(false)
|
, m_filtering(false)
|
||||||
|
@ -22,7 +22,7 @@ namespace ui {
|
|||||||
kCloseOnClickOutsideHotRegion
|
kCloseOnClickOutsideHotRegion
|
||||||
};
|
};
|
||||||
|
|
||||||
PopupWindow(const base::string& text, ClickBehavior clickBehavior);
|
PopupWindow(const std::string& text, ClickBehavior clickBehavior);
|
||||||
~PopupWindow();
|
~PopupWindow();
|
||||||
|
|
||||||
void setHotRegion(const gfx::Region& region);
|
void setHotRegion(const gfx::Region& region);
|
||||||
|
@ -8,7 +8,7 @@
|
|||||||
|
|
||||||
namespace ui {
|
namespace ui {
|
||||||
|
|
||||||
Property::Property(const base::string& name)
|
Property::Property(const std::string& name)
|
||||||
: m_name(name)
|
: m_name(name)
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
@ -17,7 +17,7 @@ Property::~Property()
|
|||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
base::string Property::getName() const
|
std::string Property::getName() const
|
||||||
{
|
{
|
||||||
return m_name;
|
return m_name;
|
||||||
}
|
}
|
||||||
|
@ -8,23 +8,23 @@
|
|||||||
#define UI_PROPERTY_H_INCLUDED
|
#define UI_PROPERTY_H_INCLUDED
|
||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
#include "base/string.h"
|
|
||||||
#include "base/disable_copying.h"
|
#include "base/disable_copying.h"
|
||||||
#include "base/shared_ptr.h"
|
#include "base/shared_ptr.h"
|
||||||
|
|
||||||
|
#include <string>
|
||||||
|
|
||||||
namespace ui {
|
namespace ui {
|
||||||
|
|
||||||
class Property
|
class Property {
|
||||||
{
|
|
||||||
base::string m_name;
|
|
||||||
|
|
||||||
public:
|
public:
|
||||||
Property(const base::string& name);
|
Property(const std::string& name);
|
||||||
virtual ~Property();
|
virtual ~Property();
|
||||||
|
|
||||||
base::string getName() const;
|
std::string getName() const;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
std::string m_name;
|
||||||
|
|
||||||
DISABLE_COPYING(Property);
|
DISABLE_COPYING(Property);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -19,7 +19,7 @@ namespace ui {
|
|||||||
|
|
||||||
using namespace gfx;
|
using namespace gfx;
|
||||||
|
|
||||||
Separator::Separator(const base::string& text, int align)
|
Separator::Separator(const std::string& text, int align)
|
||||||
: Widget(kSeparatorWidget)
|
: Widget(kSeparatorWidget)
|
||||||
{
|
{
|
||||||
setAlign(align);
|
setAlign(align);
|
||||||
|
@ -16,7 +16,7 @@ namespace ui {
|
|||||||
class Separator : public Widget
|
class Separator : public Widget
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
Separator(const base::string& text, int align);
|
Separator(const std::string& text, int align);
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
void onPaint(PaintEvent& ev) OVERRIDE;
|
void onPaint(PaintEvent& ev) OVERRIDE;
|
||||||
|
@ -22,7 +22,7 @@
|
|||||||
|
|
||||||
namespace ui {
|
namespace ui {
|
||||||
|
|
||||||
TextBox::TextBox(const base::string& text, int align)
|
TextBox::TextBox(const std::string& text, int align)
|
||||||
: Widget(kTextBoxWidget)
|
: Widget(kTextBoxWidget)
|
||||||
{
|
{
|
||||||
setFocusStop(true);
|
setFocusStop(true);
|
||||||
|
@ -16,7 +16,7 @@ namespace ui {
|
|||||||
class TextBox : public Widget
|
class TextBox : public Widget
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
TextBox(const base::string& text, int align);
|
TextBox(const std::string& text, int align);
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
bool onProcessMessage(Message* msg) OVERRIDE;
|
bool onProcessMessage(Message* msg) OVERRIDE;
|
||||||
|
@ -43,7 +43,7 @@ TooltipManager::~TooltipManager()
|
|||||||
manager->removeMessageFilterFor(this);
|
manager->removeMessageFilterFor(this);
|
||||||
}
|
}
|
||||||
|
|
||||||
void TooltipManager::addTooltipFor(Widget* widget, const base::string& text, int arrowAlign)
|
void TooltipManager::addTooltipFor(Widget* widget, const std::string& text, int arrowAlign)
|
||||||
{
|
{
|
||||||
m_tips[widget] = TipInfo(text, arrowAlign);
|
m_tips[widget] = TipInfo(text, arrowAlign);
|
||||||
}
|
}
|
||||||
|
@ -25,7 +25,7 @@ namespace ui {
|
|||||||
TooltipManager();
|
TooltipManager();
|
||||||
~TooltipManager();
|
~TooltipManager();
|
||||||
|
|
||||||
void addTooltipFor(Widget* widget, const base::string& text, int arrowAlign = 0);
|
void addTooltipFor(Widget* widget, const std::string& text, int arrowAlign = 0);
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
bool onProcessMessage(Message* msg) OVERRIDE;
|
bool onProcessMessage(Message* msg) OVERRIDE;
|
||||||
@ -38,7 +38,7 @@ namespace ui {
|
|||||||
int arrowAlign;
|
int arrowAlign;
|
||||||
|
|
||||||
TipInfo() { }
|
TipInfo() { }
|
||||||
TipInfo(const base::string& text, int arrowAlign)
|
TipInfo(const std::string& text, int arrowAlign)
|
||||||
: text(text), arrowAlign(arrowAlign) {
|
: text(text), arrowAlign(arrowAlign) {
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
@ -126,7 +126,7 @@ double Widget::getTextDouble() const
|
|||||||
return strtod(m_text.c_str(), NULL);
|
return strtod(m_text.c_str(), NULL);
|
||||||
}
|
}
|
||||||
|
|
||||||
void Widget::setText(const base::string& text)
|
void Widget::setText(const std::string& text)
|
||||||
{
|
{
|
||||||
setTextQuiet(text);
|
setTextQuiet(text);
|
||||||
onSetText();
|
onSetText();
|
||||||
@ -151,7 +151,7 @@ void Widget::setTextf(const char *format, ...)
|
|||||||
setText(buf);
|
setText(buf);
|
||||||
}
|
}
|
||||||
|
|
||||||
void Widget::setTextQuiet(const base::string& text)
|
void Widget::setTextQuiet(const std::string& text)
|
||||||
{
|
{
|
||||||
m_text = text;
|
m_text = text;
|
||||||
flags |= JI_HASTEXT;
|
flags |= JI_HASTEXT;
|
||||||
|
@ -8,9 +8,6 @@
|
|||||||
#define UI_WIDGET_H_INCLUDED
|
#define UI_WIDGET_H_INCLUDED
|
||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
#include <string>
|
|
||||||
|
|
||||||
#include "base/string.h"
|
|
||||||
#include "gfx/border.h"
|
#include "gfx/border.h"
|
||||||
#include "gfx/point.h"
|
#include "gfx/point.h"
|
||||||
#include "gfx/rect.h"
|
#include "gfx/rect.h"
|
||||||
@ -23,6 +20,8 @@
|
|||||||
#include "ui/widget_type.h"
|
#include "ui/widget_type.h"
|
||||||
#include "ui/widgets_list.h"
|
#include "ui/widgets_list.h"
|
||||||
|
|
||||||
|
#include <string>
|
||||||
|
|
||||||
#define ASSERT_VALID_WIDGET(widget) ASSERT((widget) != NULL)
|
#define ASSERT_VALID_WIDGET(widget) ASSERT((widget) != NULL)
|
||||||
|
|
||||||
struct FONT;
|
struct FONT;
|
||||||
@ -88,7 +87,7 @@ namespace ui {
|
|||||||
|
|
||||||
WidgetType getType() const { return this->type; }
|
WidgetType getType() const { return this->type; }
|
||||||
|
|
||||||
const base::string& getId() const { return m_id; }
|
const std::string& getId() const { return m_id; }
|
||||||
void setId(const char* id) { m_id = id; }
|
void setId(const char* id) { m_id = id; }
|
||||||
|
|
||||||
int getAlign() const { return m_align; }
|
int getAlign() const { return m_align; }
|
||||||
@ -98,13 +97,13 @@ namespace ui {
|
|||||||
|
|
||||||
bool hasText() const { return (flags & JI_HASTEXT) == JI_HASTEXT; }
|
bool hasText() const { return (flags & JI_HASTEXT) == JI_HASTEXT; }
|
||||||
|
|
||||||
const base::string& getText() const { return m_text; }
|
const std::string& getText() const { return m_text; }
|
||||||
int getTextInt() const;
|
int getTextInt() const;
|
||||||
double getTextDouble() const;
|
double getTextDouble() const;
|
||||||
size_t getTextLength() const { return m_text.size(); }
|
size_t getTextLength() const { return m_text.size(); }
|
||||||
void setText(const base::string& text);
|
void setText(const std::string& text);
|
||||||
void setTextf(const char* text, ...);
|
void setTextf(const char* text, ...);
|
||||||
void setTextQuiet(const base::string& text);
|
void setTextQuiet(const std::string& text);
|
||||||
|
|
||||||
int getTextWidth() const;
|
int getTextWidth() const;
|
||||||
int getTextHeight() const;
|
int getTextHeight() const;
|
||||||
@ -382,10 +381,10 @@ namespace ui {
|
|||||||
void paint(Graphics* graphics, const gfx::Region& drawRegion);
|
void paint(Graphics* graphics, const gfx::Region& drawRegion);
|
||||||
bool paintEvent(Graphics* graphics);
|
bool paintEvent(Graphics* graphics);
|
||||||
|
|
||||||
base::string m_id; // Widget's id
|
std::string m_id; // Widget's id
|
||||||
Theme* m_theme; // Widget's theme
|
Theme* m_theme; // Widget's theme
|
||||||
int m_align; // Widget alignment
|
int m_align; // Widget alignment
|
||||||
base::string m_text; // Widget text
|
std::string m_text; // Widget text
|
||||||
struct FONT *m_font; // Text font type
|
struct FONT *m_font; // Text font type
|
||||||
ui::Color m_bgColor; // Background color
|
ui::Color m_bgColor; // Background color
|
||||||
gfx::Rect m_bounds;
|
gfx::Rect m_bounds;
|
||||||
|
@ -33,7 +33,7 @@ enum {
|
|||||||
static gfx::Point clickedMousePos;
|
static gfx::Point clickedMousePos;
|
||||||
static gfx::Rect* clickedWindowPos = NULL;
|
static gfx::Rect* clickedWindowPos = NULL;
|
||||||
|
|
||||||
Window::Window(Type type, const base::string& text)
|
Window::Window(Type type, const std::string& text)
|
||||||
: Widget(kWindowWidget)
|
: Widget(kWindowWidget)
|
||||||
{
|
{
|
||||||
m_killer = NULL;
|
m_killer = NULL;
|
||||||
|
@ -23,7 +23,7 @@ namespace ui {
|
|||||||
public:
|
public:
|
||||||
enum Type { DesktopWindow, WithTitleBar, WithoutTitleBar };
|
enum Type { DesktopWindow, WithTitleBar, WithoutTitleBar };
|
||||||
|
|
||||||
explicit Window(Type type, const base::string& text = "");
|
explicit Window(Type type, const std::string& text = "");
|
||||||
~Window();
|
~Window();
|
||||||
|
|
||||||
Widget* getKiller();
|
Widget* getKiller();
|
||||||
|
Loading…
Reference in New Issue
Block a user