Restructure zlcore include files and add libzlcore-tqt-dev package

Signed-off-by: Michele Calgaro <michele.calgaro@yahoo.it>
pull/1/head
Michele Calgaro 6 months ago
parent 5e5423ec5d
commit e58b237d51
Signed by: MicheleC
GPG Key ID: 2A75B7CA8ADED5CF

@ -0,0 +1,2 @@
/usr/include/zlibrary-tqt/core
/usr/lib/libzlcore-tqt.so

@ -1 +1 @@
/usr/lib
/usr/lib/libzlcore-tqt.so.*

@ -23,7 +23,7 @@
#include <ZLDialogManager.h>
#include <ZLDialog.h>
#include <ZLOptionsDialog.h>
#include <optionEntries/ZLSimpleOptionEntry.h>
#include <ZLSimpleOptionEntry.h>
#include <ZLibrary.h>
#include <ZLBlockTreeView.h>

@ -22,7 +22,7 @@
#include <ZLInputStream.h>
#include <ZLOptions.h>
#include <optionEntries/ZLSimpleOptionEntry.h>
#include <ZLSimpleOptionEntry.h>
#include <ZLResource.h>
#include "../FormatPlugin.h"

@ -22,7 +22,7 @@
#include <ZLOptionsDialog.h>
#include <ZLOptionEntry.h>
#include <optionEntries/ZLSimpleOptionEntry.h>
#include <ZLSimpleOptionEntry.h>
#include "../network/NetworkLink.h"
#include "AuthenticationDialog.h"

@ -23,8 +23,8 @@
#include <ZLOptionsDialog.h>
#include <ZLOptionEntry.h>
#include <optionEntries/ZLSimpleOptionEntry.h>
#include <optionEntries/ZLStringEditOptionEntry.h>
#include <ZLSimpleOptionEntry.h>
#include <ZLStringEditOptionEntry.h>
#include "PasswordRecoveryDialog.h"
#include "NetworkOperationRunnable.h"

@ -22,8 +22,8 @@
#include <ZLOptionsDialog.h>
#include <ZLOptionEntry.h>
#include <optionEntries/ZLSimpleOptionEntry.h>
#include <optionEntries/ZLStringEditOptionEntry.h>
#include <ZLSimpleOptionEntry.h>
#include <ZLStringEditOptionEntry.h>
#include "RegisterUserDialog.h"

@ -21,8 +21,8 @@
#include <ZLOptionEntry.h>
#include <ZLStringUtil.h>
#include <optionEntries/ZLToggleBooleanOptionEntry.h>
#include <optionEntries/ZLSimpleOptionEntry.h>
#include <ZLToggleBooleanOptionEntry.h>
#include <ZLSimpleOptionEntry.h>
#include "AbstractOptionsDialog.h"

@ -26,9 +26,9 @@
#include <ZLLanguageList.h>
#include <ZLStringUtil.h>
#include <optionEntries/ZLStringInfoEntry.h>
#include <optionEntries/ZLSimpleOptionEntry.h>
#include <optionEntries/ZLLanguageOptionEntry.h>
#include <ZLStringInfoEntry.h>
#include <ZLSimpleOptionEntry.h>
#include <ZLLanguageOptionEntry.h>
#include "BookInfoDialog.h"

@ -19,7 +19,7 @@
#include <ZLOptionsDialog.h>
#include <optionEntries/ZLSimpleOptionEntry.h>
#include <ZLSimpleOptionEntry.h>
#include <ZLTextStyle.h>
#include <ZLTextStyleCollection.h>

@ -21,8 +21,8 @@
#include <ZLOptionsDialog.h>
#include <ZLPaintContext.h>
#include <optionEntries/ZLSimpleOptionEntry.h>
#include <optionEntries/ZLColorOptionBuilder.h>
#include <ZLSimpleOptionEntry.h>
#include <ZLColorOptionBuilder.h>
#include <ZLTextStyleCollection.h>

@ -20,7 +20,7 @@
#include <ZLOptionsDialog.h>
#include <ZLPaintContext.h>
#include <optionEntries/ZLSimpleOptionEntry.h>
#include <ZLSimpleOptionEntry.h>
#include <ZLTextView.h>
#include <ZLTextStyle.h>

@ -26,8 +26,8 @@
#include <ZLOptionEntry.h>
#include <ZLOptionsDialog.h>
#include <ZLNetworkManager.h>
#include <optionEntries/ZLSimpleOptionEntry.h>
#include <optionEntries/ZLToggleBooleanOptionEntry.h>
#include <ZLSimpleOptionEntry.h>
#include <ZLToggleBooleanOptionEntry.h>
#include "../../fbreader/FBReader.h"

@ -19,7 +19,7 @@
#include <ZLOptionsDialog.h>
#include <optionEntries/ZLToggleBooleanOptionEntry.h>
#include <ZLToggleBooleanOptionEntry.h>
#include <ZLTextStyleOptions.h>

@ -21,8 +21,8 @@
#include <ZLApplication.h>
#include <ZLOptionEntry.h>
#include <optionEntries/ZLSimpleOptionEntry.h>
#include <optionEntries/ZLSimpleKeyOptionEntry.h>
#include <ZLSimpleOptionEntry.h>
#include <ZLSimpleKeyOptionEntry.h>
#include "ReadingOptionsDialog.h"

@ -20,8 +20,8 @@
#include <ZLDialogManager.h>
#include <ZLOptionsDialog.h>
#include <optionEntries/ZLSimpleOptionEntry.h>
#include <optionEntries/ZLToggleBooleanOptionEntry.h>
#include <ZLSimpleOptionEntry.h>
#include <ZLToggleBooleanOptionEntry.h>
#include "ReadingOptionsDialog.h"

@ -22,9 +22,9 @@
#include <ZLLanguageList.h>
#include <ZLOptionEntry.h>
#include <optionEntries/ZLSimpleOptionEntry.h>
#include <optionEntries/ZLLanguageOptionEntry.h>
#include <optionEntries/ZLToggleBooleanOptionEntry.h>
#include <ZLSimpleOptionEntry.h>
#include <ZLLanguageOptionEntry.h>
#include <ZLToggleBooleanOptionEntry.h>
#include "SystemOptionsDialog.h"

@ -6,6 +6,11 @@ _tde_internal_setup_path(
"Base directory for zlibrary-tqt files which go to share"
)
_tde_internal_setup_path(
ZL_INCLUDE_INSTALL_DIR "${CMAKE_ZLIBRARY_INSTALL_PREFIX}/include/zlibrary-tqt"
"The subdirectory to the header prefix"
)
_tde_internal_setup_path(
ZL_LIB_INSTALL_DIR "${CMAKE_ZLIBRARY_INSTALL_PREFIX}/lib${LIB_SUFFIX}"
"Base directory for zlibrary-tqt lib files"

@ -38,3 +38,12 @@ install(
FILES ${_resources_files}
DESTINATION ${ZL_SHARE_INSTALL_PREFIX}/resources
)
##### install header files
file( GLOB_RECURSE _zlcore_h_files RELATIVE ${CMAKE_CURRENT_SOURCE_DIR} ${CMAKE_CURRENT_SOURCE_DIR}/include/*.h )
install(
FILES ${_zlcore_h_files}
DESTINATION ${ZL_INCLUDE_INSTALL_DIR}/core
)

@ -21,7 +21,7 @@
#define __ICONVENCODINGCONVERTERS_H__
#include <ZLEncodingConverter.h>
#include "../../encoding/ZLEncodingConverterProvider.h"
#include "ZLEncodingConverterProvider.h"
class IConvEncodingConverterProvider : public ZLEncodingConverterProvider {

@ -27,7 +27,7 @@
#include <shared_ptr.h>
#include <ZLRunnable.h>
#include "../../options/ZLConfig.h"
#include "ZLConfig.h"
#include "XMLConfigValue.h"

@ -1 +0,0 @@
../src/application/ZLApplication.h

@ -0,0 +1,201 @@
/*
* Copyright (C) 2004-2012 Geometer Plus <contact@geometerplus.com>
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
* 02110-1301, USA.
*/
#ifndef __ZLAPPLICATION_H__
#define __ZLAPPLICATION_H__
#include <string>
#include <vector>
#include <map>
#include <set>
#include <shared_ptr.h>
#include <ZLOptions.h>
#include <ZLTime.h>
#include <ZLResource.h>
#include <ZLMessage.h>
#include <ZLView.h>
class ZLApplicationWindow;
class ZLViewWidget;
class ZLPaintContext;
class ZLKeyBindings;
class ZLToolbar;
class ZLPopupData;
class ZLMenubar;
class ZLFile;
class ZLApplicationBase {
protected:
ZLApplicationBase(const std::string &name);
~ZLApplicationBase();
};
class ZLApplication : public ZLApplicationBase {
public:
static ZLApplication &Instance();
static void deleteInstance();
private:
static ZLApplication *ourInstance;
public:
static const std::string MouseScrollUpKey;
static const std::string MouseScrollDownKey;
static const std::string NoAction;
public:
ZLIntegerOption RotationAngleOption;
ZLIntegerOption AngleStateOption;
ZLBooleanOption KeyboardControlOption;
ZLBooleanOption ConfigAutoSavingOption;
ZLIntegerRangeOption ConfigAutoSaveTimeoutOption;
ZLIntegerRangeOption KeyDelayOption;
public:
class Action {
public:
virtual ~Action();
virtual bool isVisible() const;
virtual bool isEnabled() const;
void checkAndRun();
virtual bool useKeyDelay() const;
protected:
virtual void run() = 0;
};
protected:
class RotationAction : public Action {
public:
bool isVisible() const;
void run();
};
friend class RotationAction;
public:
class FullscreenAction : public Action {
public:
void run();
};
friend class FullscreenAction;
class PresentWindowHandler : public ZLMessageHandler {
public:
void onMessageReceived(const std::vector<std::string> &arguments);
const std::string &lastCaller() const;
void resetLastCaller();
private:
std::string myLastCaller;
};
protected:
ZLApplication(const std::string &name);
void addAction(const std::string &actionId, shared_ptr<Action> action);
void registerPopupData(const std::string &actionId, shared_ptr<ZLPopupData> popupData);
void setView(shared_ptr<ZLView> view);
ZLView::Angle rotation() const;
void setFullscreen(bool fullscreen);
bool isFullscreen() const;
public:
virtual ~ZLApplication();
virtual void initWindow();
shared_ptr<ZLView> currentView() const;
shared_ptr<ZLPaintContext> context();
void grabAllKeys(bool grab);
void trackStylus(bool track);
void resetWindowCaption();
void setHyperlinkCursor(bool hyperlink);
shared_ptr<Action> action(const std::string &actionId) const;
bool isActionVisible(const std::string &actionId) const;
bool isActionEnabled(const std::string &actionId) const;
void doAction(const std::string &actionId);
virtual shared_ptr<ZLKeyBindings> keyBindings();
void doActionByKey(const std::string &key);
void quit();
virtual bool closeView();
virtual void openFile(const ZLFile &file);
virtual bool canDragFiles(const std::vector<std::string> &filePaths) const;
virtual void dragFiles(const std::vector<std::string> &filePaths);
virtual bool isViewFinal() const;
virtual void refreshWindow();
void presentWindow();
const std::string &lastCaller() const;
void resetLastCaller();
void setVisualParameter(const std::string &id, const std::string &value);
void setParameterValueList(const std::string &id, const std::vector<std::string> &values);
const std::string &visualParameter(const std::string &id);
public:
virtual bool showAuthDialog(const std::string &siteName, std::string &userName, std::string &password, const ZLResourceKey &errorKey) = 0;
virtual void saveUserName(const std::string &siteName, std::string &userName) = 0;
private:
void createToolbar(int index);
// TODO: change access rights to private
public:
const ZLToolbar &toolbar(int index) const;
private:
void createMenubar();
const ZLMenubar &menubar() const;
private:
shared_ptr<ZLViewWidget> myViewWidget;
shared_ptr<ZLView> myInitialView;
std::map<std::string,shared_ptr<Action> > myActionMap;
mutable shared_ptr<ZLToolbar> myToolbar;
mutable shared_ptr<ZLToolbar> myFullscreenToolbar;
mutable shared_ptr<ZLMenubar> myMenubar;
shared_ptr<ZLPaintContext> myContext;
shared_ptr <ZLApplicationWindow> myWindow;
ZLTime myLastKeyActionTime;
shared_ptr<ZLMessageHandler> myPresentWindowHandler;
friend class ZLApplicationWindow;
friend class ZLMenuVisitor;
};
#endif /* __ZLAPPLICATION_H__ */

@ -1 +0,0 @@
../src/network/ZLAsynchronousInputStream.h

@ -0,0 +1,72 @@
/*
* Copyright (C) 2009-2012 Geometer Plus <contact@geometerplus.com>
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
* 02110-1301, USA.
*/
#ifndef __ZLASYNCHRONOUSINPUTSTREAM_H__
#define __ZLASYNCHRONOUSINPUTSTREAM_H__
#include <string>
class ZLAsynchronousInputStream {
public:
class Handler {
public:
virtual ~Handler();
virtual void initialize(const char *encoding) = 0;
virtual void shutdown() = 0;
virtual bool handleBuffer(const char *data, std::size_t len) = 0;
};
public:
ZLAsynchronousInputStream(const char *encoding = 0);
virtual ~ZLAsynchronousInputStream();
void setEof();
void setBuffer(const char *data, std::size_t len);
bool eof() const;
bool initialized() const;
bool processInput(Handler &handler);
protected:
virtual bool processInputInternal(Handler &handler) = 0;
protected:
const char *myData;
std::size_t myDataLen;
private:
std::string myEncoding;
bool myInitialized;
bool myEof;
private:
// disable copying
ZLAsynchronousInputStream(const ZLAsynchronousInputStream &);
const ZLAsynchronousInputStream &operator = (const ZLAsynchronousInputStream &);
};
inline void ZLAsynchronousInputStream::setEof() { myEof = true; myData = 0; myDataLen = 0; }
inline void ZLAsynchronousInputStream::setBuffer(const char *data, std::size_t len) { myData = data; myDataLen = len; }
inline bool ZLAsynchronousInputStream::eof() const { return myEof; }
inline bool ZLAsynchronousInputStream::initialized() const { return myInitialized; }
#endif /* __ZLASYNCHRONOUSINPUTSTREAM_H__ */

@ -1 +0,0 @@
../src/image/ZLBase64EncodedImage.h

@ -0,0 +1,47 @@
/*
* Copyright (C) 2004-2012 Geometer Plus <contact@geometerplus.com>
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
* 02110-1301, USA.
*/
#ifndef __ZLBASE64ENCODEDIMAGE_H__
#define __ZLBASE64ENCODEDIMAGE_H__
#include <vector>
#include <ZLImage.h>
class ZLBase64EncodedImage : public ZLSingleImage {
public:
ZLBase64EncodedImage(shared_ptr<ZLMimeType> mimeType);
~ZLBase64EncodedImage();
void addData(const std::string &text, std::size_t offset, std::size_t len);
void addData(const std::vector<std::string> &text);
const shared_ptr<std::string> stringData() const;
private:
void decode() const;
private:
mutable std::string myEncodedData;
mutable shared_ptr<std::string> myData;
};
inline ZLBase64EncodedImage::ZLBase64EncodedImage(shared_ptr<ZLMimeType> mimeType) : ZLSingleImage(mimeType) {}
inline ZLBase64EncodedImage::~ZLBase64EncodedImage() {}
#endif /* __ZLBASE64ENCODEDIMAGE_H__ */

@ -1 +0,0 @@
../src/util/ZLBase64InputStream.h

@ -0,0 +1,54 @@
/*
* Copyright (C) 2009-2012 Geometer Plus <contact@geometerplus.com>
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
* 02110-1301, USA.
*/
#ifndef __ZLBASE64INPUTSTREAM_H__
#define __ZLBASE64INPUTSTREAM_H__
#include <ZLInputStream.h>
class ZLBase64InputStream : public ZLInputStream {
public:
ZLBase64InputStream(shared_ptr<ZLInputStream> base);
~ZLBase64InputStream();
bool open();
int read();
std::size_t read(char *buffer, std::size_t maxSize);
void close();
void seek(int offset, bool absoluteOffset);
std::size_t offset() const;
std::size_t sizeOfOpened();
private:
void fillDecodedBuffer();
bool fillBuffer();
static int decode(char b);
private:
shared_ptr<ZLInputStream> myBaseStream;
int myDecoded0;
int myDecoded1;
int myDecoded2;
char* myBuffer;
int myBufferOffset;
int myBufferLength;
};
#endif /* __ZLBASE64INPUTSTREAM_H__ */

@ -1 +0,0 @@
../src/blockTreeView/ZLBlockTreeNode.h

@ -0,0 +1,104 @@
/*
* Copyright (C) 2009-2012 Geometer Plus <contact@geometerplus.com>
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
* 02110-1301, USA.
*/
#ifndef __ZLBLOCKTREENODE_H__
#define __ZLBLOCKTREENODE_H__
#include <map>
#include <vector>
#include <shared_ptr.h>
#include <ZLTypeId.h>
#include <ZLRunnable.h>
#include <ZLPaintContext.h>
class ZLBlockTreeView;
class ZLBlockTreeNode : public ZLObjectWithRTTI {
public:
typedef std::vector<ZLBlockTreeNode*> List;
protected:
struct Rectangle {
const std::size_t Left;
const std::size_t Top;
const std::size_t Right;
const std::size_t Bottom;
Rectangle(std::size_t left, std::size_t vOffset, std::size_t right, std::size_t bottom);
bool contains(std::size_t x, std::size_t y) const;
bool operator < (const Rectangle &r) const;
};
public:
static const ZLTypeId TYPE_ID;
protected:
ZLBlockTreeNode(ZLBlockTreeView &view);
ZLBlockTreeNode(ZLBlockTreeNode *parent, std::size_t atPosition = -1);
public:
virtual ~ZLBlockTreeNode();
void clear();
public:
ZLBlockTreeNode *parent() const;
ZLBlockTreeNode *previous() const;
ZLBlockTreeNode *next() const;
const List &children() const;
void open(bool openNotClose);
bool isOpen() const;
protected:
std::size_t level() const;
ZLBlockTreeView &view();
public:
virtual void paint(ZLPaintContext &context, int vOffset) = 0;
virtual int height(ZLPaintContext &context) const = 0;
void onStylusPress(std::size_t x, std::size_t y);
bool isOverHyperlink(std::size_t x, std::size_t y);
protected:
void addHyperlink(std::size_t left, std::size_t top, std::size_t right, std::size_t bottom, shared_ptr<ZLRunnableWithKey> action);
void removeAllHyperlinks();
private:
ZLBlockTreeView &myView;
ZLBlockTreeNode *myParent;
std::size_t myChildIndex;
List myChildren;
bool myIsOpen;
typedef std::map<Rectangle,shared_ptr<ZLRunnableWithKey> > LinkMap;
LinkMap myHyperlinks;
private:
ZLBlockTreeNode(const ZLBlockTreeNode&);
const ZLBlockTreeNode &operator = (const ZLBlockTreeNode&);
};
#endif /* __ZLBLOCKTREENODE_H__ */

@ -1 +0,0 @@
../src/blockTreeView/ZLBlockTreeView.h

@ -0,0 +1,97 @@
/*
* Copyright (C) 2009-2012 Geometer Plus <contact@geometerplus.com>
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
* 02110-1301, USA.
*/
#ifndef __ZLBLOCKTREEVIEW_H__
#define __ZLBLOCKTREEVIEW_H__
#include <ZLView.h>
#include <ZLBlockTreeNode.h>
class ZLBlockTreeView : public ZLView {
public:
class RootNode : public ZLBlockTreeNode {
public:
static const ZLTypeId TYPE_ID;
public:
RootNode(ZLBlockTreeView &view);
private:
const ZLTypeId &typeId() const;
void paint(ZLPaintContext &context, int vOffset);
int height(ZLPaintContext &context) const;
};
public:
static const ZLTypeId TYPE_ID;
protected:
ZLBlockTreeView(ZLPaintContext &context);
const ZLTypeId &typeId() const;
RootNode &rootNode();
void clear();
public:
ZLBlockTreeNode *firstVisibleNode() const;
void setFirstVisibleNode(ZLBlockTreeNode *node);
enum VisibilityMode {
INVISIBLE,
VISIBLE,
VISIBLE_PARTIAL_AT_TOP,
VISIBLE_PARTIAL_AT_BOTTOM
};
VisibilityMode visibilityMode(ZLBlockTreeNode *node) const;
void ensureVisible(ZLBlockTreeNode *node);
enum ScrollingMode {
NONE,
PAGE,
ITEM,
};
void scroll(ScrollingMode mode, bool back);
protected:
void paint();
private:
bool onStylusPress(int x, int y);
bool onStylusMove(int x, int y);
void onScrollbarMoved(Direction direction, std::size_t full, std::size_t from, std::size_t to);
void onScrollbarStep(Direction direction, int steps);
void onScrollbarPageStep(Direction direction, int steps);
private:
ZLBlockTreeNode *findNode(int &y);
private:
RootNode myRootNode;
ZLBlockTreeNode *myFirstVisibleNode;
std::size_t myNodePartToSkip;
bool myCanScrollForward;
};
#endif /* __ZLBLOCKTREEVIEW_H__ */

@ -1 +0,0 @@
../src/util/ZLBoolean3.h

@ -0,0 +1,29 @@
/*
* Copyright (C) 2004-2012 Geometer Plus <contact@geometerplus.com>
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
* 02110-1301, USA.
*/
#ifndef __ZLBOOLEAN3_H__
#define __ZLBOOLEAN3_H__
enum ZLBoolean3 {
B3_FALSE = 0,
B3_TRUE = 1,
B3_UNDEFINED = 2
};
#endif /* __ZLBOOLEAN3_H__ */

@ -29,7 +29,7 @@
#include <shared_ptr.h>
#include "../ZLInputStream.h"
#include "ZLInputStream.h"
class ZLFSCompressorBzip2;

@ -1 +0,0 @@
../src/util/ZLColor.h

@ -0,0 +1,42 @@
/*
* Copyright (C) 2004-2012 Geometer Plus <contact@geometerplus.com>
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
* 02110-1301, USA.
*/
#ifndef __ZLCOLOR_H__
#define __ZLCOLOR_H__
struct ZLColor {
unsigned char Red;
unsigned char Green;
unsigned char Blue;
ZLColor(unsigned char r, unsigned char g, unsigned char b);
ZLColor(long longValue = 0);
long intValue();
bool operator == (const ZLColor &color) const;
bool operator != (const ZLColor &color) const;
};
inline ZLColor::ZLColor(unsigned char r, unsigned char g, unsigned char b) : Red(r), Green(g), Blue(b) {}
inline ZLColor::ZLColor(long longValue) : Red((unsigned char)(longValue >> 16)), Green((unsigned char)(longValue >> 8)), Blue((unsigned char)longValue) {}
inline long ZLColor::intValue() { return (((long)Red) << 16) + (((long)Green) << 8) + Blue; }
inline bool ZLColor::operator == (const ZLColor &color) const { return (Red == color.Red) && (Green == color.Green) && (Blue == color.Blue); }
inline bool ZLColor::operator != (const ZLColor &color) const { return !operator==(color); }
#endif /* __ZLCOLOR_H__ */

@ -22,7 +22,7 @@
#include <ZLOptions.h>
#include "../../application/ZLApplicationWindow.h"
#include "ZLApplicationWindow.h"
class ZLDesktopApplicationWindow : public ZLApplicationWindow {

@ -1 +0,0 @@
../src/dialogs/ZLDialog.h

@ -0,0 +1,51 @@
/*
* Copyright (C) 2004-2012 Geometer Plus <contact@geometerplus.com>
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
* 02110-1301, USA.
*/
#ifndef __ZLDIALOG_H__
#define __ZLDIALOG_H__
#include <string>
#include <ZLDialogContent.h>
#include <ZLResource.h>
class ZLDialog {
protected:
ZLDialog();
public:
virtual ~ZLDialog();
virtual void addButton(const ZLResourceKey &key, bool accept) = 0;
void addOption(const std::string &name, const std::string &tooltip, ZLOptionEntry *option);
void addOption(const ZLResourceKey &key, ZLOptionEntry *option);
void addOption(const ZLResourceKey &key, ZLSimpleOption &option);
const ZLResource &resource(const ZLResourceKey &key) const;
// TODO: change return type to int (or std::string?)
virtual bool run() = 0;
void acceptValues();
protected:
ZLDialogContent *myTab;
};
#endif /* __ZLDIALOG_H__ */

@ -1 +0,0 @@
../src/dialogs/ZLDialogContent.h

@ -0,0 +1,65 @@
/*
* Copyright (C) 2004-2012 Geometer Plus <contact@geometerplus.com>
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
* 02110-1301, USA.
*/
#ifndef __ZLDIALOGCONTENT_H__
#define __ZLDIALOGCONTENT_H__
#include <string>
#include <vector>
#include <ZLOptions.h>
#include <ZLResource.h>
class ZLOptionEntry;
class ZLOptionView;
class ZLDialogContent {
protected:
ZLDialogContent(const ZLResource &resource);
public:
virtual ~ZLDialogContent();
const std::string &key() const;
const std::string &displayName() const;
const std::string &value(const ZLResourceKey &key) const;
const ZLResource &resource(const ZLResourceKey &key) const;
virtual void addOption(const std::string &name, const std::string &tooltip, ZLOptionEntry *option) = 0;
void addOption(const ZLResourceKey &key, ZLOptionEntry *option);
void addOption(const ZLResourceKey &key, ZLSimpleOption &option);
virtual void addOptions(const std::string &name0, const std::string &tooltip0, ZLOptionEntry *option0,
const std::string &name1, const std::string &tooltip1, ZLOptionEntry *option1) = 0;
void addOptions(const ZLResourceKey &key0, ZLOptionEntry *option0,
const ZLResourceKey &key1, ZLOptionEntry *option1);
void addOptions(const ZLResourceKey &key0, ZLSimpleOption &option0,
const ZLResourceKey &key1, ZLSimpleOption &option1);
void accept();
protected:
void addView(ZLOptionView *view);
private:
const ZLResource &myResource;
std::vector<ZLOptionView*> myViews;
};
#endif /* __ZLDIALOGCONTENT_H__ */

@ -1 +0,0 @@
../src/dialogs/ZLDialogManager.h

@ -0,0 +1,101 @@
/*
* Copyright (C) 2004-2012 Geometer Plus <contact@geometerplus.com>
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
* 02110-1301, USA.
*/
#ifndef __ZLDIALOGMANAGER_H__
#define __ZLDIALOGMANAGER_H__
#include <string>
#include <shared_ptr.h>
#include <ZLRunnable.h>
#include <ZLResource.h>
#include <ZLOpenFileDialog.h>
#include <ZLTreeDialog.h>
class ZLDialog;
class ZLOptionsDialog;
class ZLTreeHandler;
class ZLApplication;
class ZLImageData;
class ZLProgressDialog;
class ZLDialogManager {
public:
static const ZLResourceKey OK_BUTTON;
static const ZLResourceKey CANCEL_BUTTON;
static const ZLResourceKey YES_BUTTON;
static const ZLResourceKey NO_BUTTON;
static const ZLResourceKey APPLY_BUTTON;
static const ZLResourceKey COLOR_KEY;
static const ZLResourceKey DIALOG_TITLE;
static const std::string &dialogTitle(const ZLResourceKey &key);
static const std::string &dialogMessage(const ZLResourceKey &key);
static const std::string &buttonName(const ZLResourceKey &key);
static const std::string &waitMessageText(const ZLResourceKey &key);
protected:
static const ZLResource &resource();
public:
static bool isInitialized();
static ZLDialogManager &Instance();
static void deleteInstance();
protected:
static ZLDialogManager *ourInstance;
protected:
ZLDialogManager();
virtual ~ZLDialogManager();
public:
virtual void createApplicationWindow(ZLApplication *application) const = 0;
virtual shared_ptr<ZLDialog> createDialog(const ZLResourceKey &key) const = 0;
virtual shared_ptr<ZLOptionsDialog> createOptionsDialog(const ZLResourceKey &key, shared_ptr<ZLRunnable> applyAction = 0, bool showApplyButton = false) const = 0;
virtual shared_ptr<ZLOpenFileDialog> createOpenFileDialog(const ZLResourceKey &key, const std::string &directoryPath, const std::string &filePath, const ZLOpenFileDialog::Filter &filter) const = 0;
virtual shared_ptr<ZLTreeDialog> createTreeDialog(const ZLResource &resource) const = 0;
void informationBox(const ZLResourceKey &key) const;
void informationBox(const ZLResourceKey &key, const std::string &message) const;
virtual void informationBox(const std::string &title, const std::string &message) const = 0;
void errorBox(const ZLResourceKey &key) const;
virtual void errorBox(const ZLResourceKey &key, const std::string &message) const = 0;
int questionBox(const ZLResourceKey &key, const ZLResourceKey &button0, const ZLResourceKey &button1, const ZLResourceKey &button2 = ZLResourceKey()) const;
virtual int questionBox(const ZLResourceKey &key, const std::string &message, const ZLResourceKey &button0, const ZLResourceKey &button1, const ZLResourceKey &button2 = ZLResourceKey()) const = 0;
virtual shared_ptr<ZLProgressDialog> createProgressDialog(const ZLResourceKey &key, bool network) const = 0;
void wait(const ZLResourceKey &key, ZLRunnable &runnable) const;
enum ClipboardType {
CLIPBOARD_MAIN,
CLIPBOARD_SELECTION
};
virtual bool isClipboardSupported(ClipboardType type) const = 0;
virtual void setClipboardText(const std::string &text, ClipboardType type) const = 0;
virtual void setClipboardImage(const ZLImageData &imageData, ClipboardType type) const = 0;
};
#endif /* __ZLDIALOGMANAGER_H__ */

@ -1 +0,0 @@
../src/filesystem/ZLDir.h

@ -0,0 +1,58 @@
/*
* Copyright (C) 2004-2012 Geometer Plus <contact@geometerplus.com>
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
* 02110-1301, USA.
*/
#ifndef __ZLDIR_H__
#define __ZLDIR_H__
#include <string>
#include <vector>
#include <shared_ptr.h>
class ZLDir {
public:
static shared_ptr<ZLDir> root();
protected:
ZLDir(const std::string &path);
public:
virtual ~ZLDir();
const std::string &path() const;
std::string name() const;
std::string parentPath() const;
std::string itemPath(const std::string &name) const;
bool isRoot() const;
virtual void collectSubDirs(std::vector<std::string> &names, bool includeSymlinks) = 0;
virtual void collectFiles(std::vector<std::string> &names, bool includeSymlinks) = 0;
protected:
virtual std::string delimiter() const = 0;
private:
std::string myPath;
private:
ZLDir(const ZLDir&);
const ZLDir &operator = (const ZLDir&);
};
#endif /* __ZLDIR_H__ */

@ -1 +0,0 @@
../src/encoding/ZLEncodingConverter.h

@ -0,0 +1,130 @@
/*
* Copyright (C) 2004-2012 Geometer Plus <contact@geometerplus.com>
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
* 02110-1301, USA.
*/
#ifndef __ZLENCODINGCONVERTER_H__
#define __ZLENCODINGCONVERTER_H__
#include <string>
#include <vector>
#include <map>
#include <shared_ptr.h>
class ZLEncodingConverter {
public:
static const std::string ASCII;
static const std::string UTF8;
static const std::string UTF16;
static const std::string UTF16BE;
protected:
ZLEncodingConverter();
public:
virtual ~ZLEncodingConverter();
virtual void convert(std::string &dst, const char *srcStart, const char *srcEnd) = 0;
void convert(std::string &dst, const std::string &src);
virtual void reset() = 0;
virtual bool fillTable(int *map) = 0;
private:
ZLEncodingConverter(const ZLEncodingConverter&);
ZLEncodingConverter &operator = (const ZLEncodingConverter&);
};
class ZLEncodingConverterInfo {
public:
ZLEncodingConverterInfo(const std::string &name, const std::string &region);
void addAlias(const std::string &alias);
const std::string &name() const;
const std::string &visibleName() const;
const std::vector<std::string> &aliases() const;
shared_ptr<ZLEncodingConverter> createConverter() const;
bool canCreateConverter() const;
private:
const std::string myName;
const std::string myVisibleName;
std::vector<std::string> myAliases;
private:
ZLEncodingConverterInfo(const ZLEncodingConverterInfo&);
ZLEncodingConverterInfo &operator = (const ZLEncodingConverterInfo&);
};
typedef shared_ptr<ZLEncodingConverterInfo> ZLEncodingConverterInfoPtr;
class ZLEncodingSet {
public:
ZLEncodingSet(const std::string &name);
void addInfo(ZLEncodingConverterInfoPtr info);
const std::string &name() const;
const std::vector<ZLEncodingConverterInfoPtr> &infos() const;
private:
const std::string myName;
std::vector<ZLEncodingConverterInfoPtr> myInfos;
private:
ZLEncodingSet(const ZLEncodingSet&);
ZLEncodingSet &operator = (const ZLEncodingSet&);
};
class ZLEncodingConverterProvider;
class ZLEncodingCollection {
public:
static ZLEncodingCollection &Instance();
static std::string encodingDescriptionPath();
private:
static ZLEncodingCollection *ourInstance;
public:
const std::vector<shared_ptr<ZLEncodingSet> > &sets();
ZLEncodingConverterInfoPtr info(const std::string &name);
ZLEncodingConverterInfoPtr info(int code);
shared_ptr<ZLEncodingConverter> defaultConverter();
void registerProvider(shared_ptr<ZLEncodingConverterProvider> provider);
private:
void addInfo(ZLEncodingConverterInfoPtr info);
const std::vector<shared_ptr<ZLEncodingConverterProvider> > &providers() const;
private:
std::vector<shared_ptr<ZLEncodingSet> > mySets;
std::map<std::string,ZLEncodingConverterInfoPtr> myInfosByName;
std::vector<shared_ptr<ZLEncodingConverterProvider> > myProviders;
private:
ZLEncodingCollection();
~ZLEncodingCollection();
void init();
friend class ZLEncodingConverterInfo;
friend class ZLEncodingCollectionReader;
};
#endif /* __ZLENCODINGCONVERTER_H__ */

@ -1 +0,0 @@
../src/runnable/ZLExecutionUtil.h

@ -0,0 +1,77 @@
/*
* Copyright (C) 2004-2012 Geometer Plus <contact@geometerplus.com>
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
* 02110-1301, USA.
*/
#ifndef __ZLEXECUTIONUTIL_H__
#define __ZLEXECUTIONUTIL_H__
#include <ZLUserData.h>
#include "ZLNetworkRequest.h"
class ZLExecutionUtil {
//code for convenient async syntax createListener method:
public:
template <typename T, typename Method>
static shared_ptr<ZLNetworkRequest::Listener> createListener(shared_ptr<ZLUserDataHolder> data, T object, Method method) {
data->addUserData(ourHandlerId, new HandlerHelper<T, Method>(object, method));
return createListener(data);
}
template <typename T, typename Method>
static shared_ptr<ZLNetworkRequest::Listener> createListener(T object, Method method) {
return createListener(new ZLUserDataHolder, object, method);
}
template <typename T, typename Method>
static shared_ptr<ZLNetworkRequest::Listener> createListener(ZLUserData *scope, T object, Method method) {
shared_ptr<ZLUserDataHolder> scopeData = new ZLUserDataHolder;
scopeData->addUserData("scope", scope);
return createListener(scopeData, object, method);
}
private:
typedef void (*Handler)(ZLUserDataHolder &data, const std::string &error);
class AbstractHandlerHelper : public ZLUserData {
public:
virtual void handle(ZLUserDataHolder &data, const std::string &error) = 0;
};
template <typename T, typename Method>
class HandlerHelper : public AbstractHandlerHelper {
public:
HandlerHelper(T object, Method method) : myObject(object), myMethod(method) {
}
void handle(ZLUserDataHolder &data, const std::string &error) {
(myObject->*myMethod)(data, error);
}
private:
T myObject;
Method myMethod;
};
static void handleHelper(ZLUserDataHolder &data, const std::string &error);
static shared_ptr<ZLNetworkRequest::Listener> createListener(shared_ptr<ZLUserDataHolder> data);
static std::string ourHandlerId;
friend class ZLExecutionHandler;
};
#endif /* __ZLEXECUTIONUTIL_H__ */

@ -20,7 +20,7 @@
#ifndef __ZLFSARCHIVERTAR_H__
#define __ZLFSARCHIVERTAR_H__
#include "../ZLFSPlugin.h"
#include "ZLFSPlugin.h"
class ZLFSArchiverTar : public ZLFSArchiver {

@ -20,7 +20,7 @@
#ifndef __ZLFSARCHIVERZIP_H__
#define __ZLFSARCHIVERZIP_H__
#include "../ZLFSPlugin.h"
#include "ZLFSPlugin.h"
class ZLFSArchiverZip : public ZLFSArchiver {

@ -20,7 +20,7 @@
#ifndef __ZLFSCOMPRESSORBZIP2_H__
#define __ZLFSCOMPRESSORBZIP2_H__
#include "../ZLFSPlugin.h"
#include "ZLFSPlugin.h"
class ZLFSCompressorBzip2 : public ZLFSCompressor {

@ -20,7 +20,7 @@
#ifndef __ZLFSCOMPRESSORGZIP_H__
#define __ZLFSCOMPRESSORGZIP_H__
#include "../ZLFSPlugin.h"
#include "ZLFSPlugin.h"
class ZLFSCompressorGzip : public ZLFSCompressor {

@ -1 +0,0 @@
../src/filesystem/ZLFile.h

@ -0,0 +1,129 @@
/*
* Copyright (C) 2004-2012 Geometer Plus <contact@geometerplus.com>
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
* 02110-1301, USA.
*/
#ifndef __ZLFILE_H__
#define __ZLFILE_H__
#include <string>
#include <map>
#include <shared_ptr.h>
#include <ZLFileInfo.h>
#include <ZLMimeType.h>
class ZLDir;
class ZLInputStream;
class ZLOutputStream;
class ZLFSCompressor;
class ZLFSArchiver;
class ZLFSPluginManager;
class ZLFile {
friend class ZLFSPluginManager;
friend class ZLFSArchiver;
public:
static const ZLFile NO_FILE;
private:
static std::map<std::string,weak_ptr<ZLInputStream> > ourPlainStreamCache;
public:
static std::string fileNameToUtf8(const std::string &fileName);
static std::string replaceIllegalCharacters(const std::string &fileName, char replaceWith);
public:
static const std::string ZIP; // = "zip"
typedef std::string ArchiveType; //ArchiveType is a string like "tag.gz", that describes sequence of compressors/archivers need to be used
ArchiveType archiveType() const;
private:
void setArchiveType(const ArchiveType type);
void setCompressed(bool compressed);
void setArchived(bool archived);
private:
ZLFile();
public:
explicit ZLFile(const std::string &path, shared_ptr<ZLMimeType> mimeType = ZLMimeType::EMPTY);
~ZLFile();
bool exists() const;
std::size_t size() const;
void forceArchiveType(const std::string & type) const;
bool isCompressed() const;
bool isDirectory() const;
bool isArchive() const;
bool remove() const;
bool canRemove() const;
const std::string &path() const;
const std::string &name(bool hideExtension) const;
const std::string &extension() const;
shared_ptr<ZLMimeType> mimeType() const;
std::string physicalFilePath() const;
std::string resolvedPath() const;
shared_ptr<ZLInputStream> inputStream() const;
shared_ptr<ZLOutputStream> outputStream(bool writeThrough = false) const;
shared_ptr<ZLDir> directory(bool createUnexisting = false) const;
bool operator == (const ZLFile &other) const;
bool operator != (const ZLFile &other) const;
bool operator < (const ZLFile &other) const;
private:
void fillInfo() const;
shared_ptr<ZLInputStream> envelopeCompressedStream(shared_ptr<ZLInputStream> &base) const;
private:
std::string myPath;
std::string myNameWithExtension;
std::string myNameWithoutExtension;
std::string myExtension;
mutable shared_ptr<ZLMimeType> myMimeType;
mutable bool myMimeTypeIsUpToDate;
mutable ArchiveType myArchiveType;
bool myIsCompressed;
bool myIsArchive;
mutable ZLFileInfo myInfo;
mutable bool myInfoIsFilled;
};
inline ZLFile::~ZLFile() {}
inline bool ZLFile::isCompressed() const { return myIsCompressed; }
inline bool ZLFile::isArchive() const { return myIsArchive; }
inline ZLFile::ArchiveType ZLFile::archiveType() const { return myArchiveType; }
inline void ZLFile::setCompressed(bool compressed) { myIsCompressed = compressed; }
inline void ZLFile::setArchived(bool archived) { myIsArchive = archived; }
inline const std::string &ZLFile::path() const { return myPath; }
inline const std::string &ZLFile::name(bool hideExtension) const { return hideExtension ? myNameWithoutExtension : myNameWithExtension; }
inline const std::string &ZLFile::extension() const { return myExtension; }
inline bool ZLFile::operator == (const ZLFile &other) const { return myPath == other.myPath; }
inline bool ZLFile::operator != (const ZLFile &other) const { return myPath != other.myPath; }
inline bool ZLFile::operator < (const ZLFile &other) const { return myPath < other.myPath; }
#endif /* __ZLFILE_H__ */

@ -1 +0,0 @@
../src/image/ZLFileImage.h

@ -0,0 +1,61 @@
/*
* Copyright (C) 2004-2012 Geometer Plus <contact@geometerplus.com>
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
* 02110-1301, USA.
*/
#ifndef __ZLFILEIMAGE_H__
#define __ZLFILEIMAGE_H__
#include <string>
#include <vector>
#include <ZLFile.h>
#include <ZLImage.h>
class ZLFileImage : public ZLSingleImage {
public:
struct Block {
unsigned int offset;
unsigned int size;
Block(unsigned int off, unsigned int s);
};
typedef std::vector<Block> Blocks;
public:
static const std::string ENCODING_NONE;
static const std::string ENCODING_HEX;
static const std::string ENCODING_BASE64;
public:
ZLFileImage(const ZLFile &file, std::size_t offset, std::size_t size = 0, const std::string &encoding = ZLFileImage::ENCODING_NONE);
ZLFileImage(const ZLFile &file, const Blocks &blocks, const std::string &encoding = ZLFileImage::ENCODING_NONE);
const shared_ptr<std::string> stringData() const;
protected:
//shared_ptr<ZLInputStream> inputStream() const;
private:
const ZLFile myFile;
const std::string myEncoding;
Blocks myBlocks;
};
inline ZLFileImage::Block::Block(unsigned int off, unsigned int s) : offset(off), size(s) {}
#endif /* __ZLFILEIMAGE_H__ */

@ -1 +0,0 @@
../src/filesystem/ZLFileInfo.h

@ -0,0 +1,34 @@
/*
* Copyright (C) 2004-2012 Geometer Plus <contact@geometerplus.com>
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
* 02110-1301, USA.
*/
#ifndef __ZLFILEINFO_H__
#define __ZLFILEINFO_H__
struct ZLFileInfo {
bool Exists;
bool IsDirectory;
std::size_t Size;
ZLFileInfo();
};
inline ZLFileInfo::ZLFileInfo() : Exists(false), IsDirectory(false), Size(0) {
}
#endif /* __ZLFILEINFO_H__ */

@ -1 +0,0 @@
../src/util/ZLFileUtil.h

@ -0,0 +1,34 @@
/*
* Copyright (C) 2010-2012 Geometer Plus <contact@geometerplus.com>
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
* 02110-1301, USA.
*/
#ifndef __ZLFILEUTIL_H__
#define __ZLFILEUTIL_H__
#include <string>
class ZLFileUtil {
public:
static std::string normalizeUnixPath(const std::string &path);
private:
ZLFileUtil();
};
#endif /* __ZLFILEUTIL_H__ */

@ -1 +0,0 @@
../src/util/ZLHexInputStream.h

@ -0,0 +1,50 @@
/*
* Copyright (C) 2009-2012 Geometer Plus <contact@geometerplus.com>
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
* 02110-1301, USA.
*/
#ifndef __ZLHEXINPUTSTREAM_H__
#define __ZLHEXINPUTSTREAM_H__
#include <ZLInputStream.h>
class ZLHexInputStream : public ZLInputStream {
public:
ZLHexInputStream(shared_ptr<ZLInputStream> base);
~ZLHexInputStream();
bool open();
int read();
std::size_t read(char *buffer, std::size_t maxSize);
void close();
void seek(int offset, bool absoluteOffset);
std::size_t offset() const;
std::size_t sizeOfOpened();
private:
bool fillBuffer();
static int decode(char b);
private:
shared_ptr<ZLInputStream> myBaseStream;
char* myBuffer;
int myBufferOffset;
int myBufferLength;
};
#endif /* __ZLHEXINPUTSTREAM_H__ */

@ -1 +0,0 @@
../src/image/ZLImage.h

@ -0,0 +1,83 @@
/*
* Copyright (C) 2004-2012 Geometer Plus <contact@geometerplus.com>
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
* 02110-1301, USA.
*/
#ifndef __ZLIMAGE_H__
#define __ZLIMAGE_H__
#include <string>
#include <shared_ptr.h>
#include <ZLMimeType.h>
class ZLNetworkRequest;
class ZLImage {
protected:
ZLImage();
public:
virtual ~ZLImage();
virtual bool isSingle() const = 0;
virtual shared_ptr<ZLNetworkRequest> synchronizationData() const;
virtual bool good() const = 0;
};
class ZLSingleImage : public ZLImage {
protected:
ZLSingleImage(shared_ptr<ZLMimeType> mimeType);
virtual ~ZLSingleImage();
public:
bool isSingle() const { return true; }
shared_ptr<ZLMimeType> mimeType() const;
bool good() const;
virtual const shared_ptr<std::string> stringData() const = 0;
private:
shared_ptr<ZLMimeType> myMimeType;
};
class ZLMultiImage : public ZLImage {
protected:
ZLMultiImage();
virtual ~ZLMultiImage();
public:
bool isSingle() const { return false; }
bool good() const;
virtual unsigned int rows() const = 0;
virtual unsigned int columns() const = 0;
virtual shared_ptr<const ZLImage> subImage(unsigned int row, unsigned int column) const = 0;
};
inline ZLImage::ZLImage() {}
inline ZLImage::~ZLImage() {}
inline ZLSingleImage::ZLSingleImage(shared_ptr<ZLMimeType> mimeType) : myMimeType(mimeType) {}
inline ZLSingleImage::~ZLSingleImage() {}
inline shared_ptr<ZLMimeType> ZLSingleImage::mimeType() const { return myMimeType; }
inline ZLMultiImage::ZLMultiImage() : ZLImage() {}
inline ZLMultiImage::~ZLMultiImage() {}
#endif /* __ZLIMAGE_H__ */

@ -1 +0,0 @@
../src/image/ZLImageManager.h

@ -0,0 +1,83 @@
/*
* Copyright (C) 2004-2012 Geometer Plus <contact@geometerplus.com>
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
* 02110-1301, USA.
*/
#ifndef __ZLIMAGEMANAGER_H__
#define __ZLIMAGEMANAGER_H__
#include <string>
#include <vector>
#include <shared_ptr.h>
class ZLImage;
class ZLMultiImage;
class ZLImageData {
protected:
ZLImageData() {}
public:
virtual ~ZLImageData() {}
virtual unsigned int width() const = 0;
virtual unsigned int height() const = 0;
virtual void init(unsigned int width, unsigned int height) = 0;
virtual void setPosition(unsigned int x, unsigned int y) = 0;
virtual void moveX(int delta) = 0;
virtual void moveY(int delta) = 0;
virtual void setPixel(unsigned char r, unsigned char g, unsigned char b) = 0;
void setGrayPixel(unsigned char c);
virtual void copyFrom(const ZLImageData &source, unsigned int targetX, unsigned int targetY) = 0;
};
class ZLImageManager {
public:
static const ZLImageManager &Instance();
static void deleteInstance();
protected:
static ZLImageManager *ourInstance;
public:
shared_ptr<ZLImageData> imageData(const ZLImage &image) const;
public:
virtual shared_ptr<const ZLImage> makeBatchImage(const std::vector<shared_ptr<const ZLImage> > &images, shared_ptr<const ZLImage> defaultImage) const = 0;
protected:
ZLImageManager() {}
virtual ~ZLImageManager() {}
virtual shared_ptr<ZLImageData> createData() const = 0;
virtual bool convertImageDirect(const std::string &stringData, ZLImageData &imageData) const = 0;
private:
bool convertMultiImage(const ZLMultiImage &multiImage, ZLImageData &imageData) const;
bool convertFromPalmImageFormat(const std::string &imageString, ZLImageData &imageData) const;
};
inline void ZLImageData::setGrayPixel(unsigned char c) { setPixel(c, c, c); }
inline const ZLImageManager &ZLImageManager::Instance() { return *ourInstance; }
#endif /* __IMAGEMANAGER_H__ */

@ -1 +0,0 @@
../src/filesystem/ZLInputStream.h

@ -0,0 +1,71 @@
/*
* Copyright (C) 2004-2012 Geometer Plus <contact@geometerplus.com>
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
* 02110-1301, USA.
*/
#ifndef __ZLINPUTSTREAM_H__
#define __ZLINPUTSTREAM_H__
#include <string>
#include <shared_ptr.h>
#include <ZLUserData.h>
class ZLInputStream : public ZLUserDataHolder {
protected:
ZLInputStream();
public:
virtual ~ZLInputStream();
virtual bool open() = 0;
virtual std::size_t read(char *buffer, std::size_t maxSize) = 0;
virtual void close() = 0;
virtual void seek(int offset, bool absoluteOffset) = 0;
virtual std::size_t offset() const = 0;
virtual std::size_t sizeOfOpened() = 0;
private:
// disable copying
ZLInputStream(const ZLInputStream&);
const ZLInputStream &operator = (const ZLInputStream&);
};
class ZLInputStreamDecorator : public ZLInputStream {
public:
ZLInputStreamDecorator(shared_ptr<ZLInputStream> decoratee);
private:
bool open();
std::size_t read(char *buffer, std::size_t maxSize);
void close();
void seek(int offset, bool absoluteOffset);
std::size_t offset() const;
std::size_t sizeOfOpened();
private:
shared_ptr<ZLInputStream> myBaseStream;
std::size_t myBaseOffset;
};
inline ZLInputStream::ZLInputStream() {}
inline ZLInputStream::~ZLInputStream() {}
#endif /* __ZLINPUTSTREAM_H__ */

@ -1 +0,0 @@
../src/application/ZLKeyBindings.h

@ -0,0 +1,48 @@
/*
* Copyright (C) 2004-2012 Geometer Plus <contact@geometerplus.com>
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
* 02110-1301, USA.
*/
#ifndef __ZLKEYBINDINGS_H__
#define __ZLKEYBINDINGS_H__
#include <map>
#include <string>
class ZLKeyBindings {
public:
ZLKeyBindings(const std::string &name);
~ZLKeyBindings();
void bindKey(const std::string &key, const std::string &code);
const std::string &getBinding(const std::string &key);
private:
void loadDefaultBindings();
void loadCustomBindings();
public:
void saveCustomBindings();
private:
const std::string myName;
std::map<std::string,std::string> myBindingsMap;
bool myIsChanged;
};
#endif /* __KEYBINDINGS_H__ */

@ -1 +0,0 @@
../src/language/ZLLanguageDetector.h

@ -0,0 +1,51 @@
/*
* Copyright (C) 2007-2012 Geometer Plus <contact@geometerplus.com>
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
* 02110-1301, USA.
*/
#ifndef __ZLLANGUAGEDETECTOR_H__
#define __ZLLANGUAGEDETECTOR_H__
#include <vector>
#include <string>
//#include <shared_ptr.h>
class ZLStatisticsBasedMatcher;
class ZLLanguageDetector {
public:
struct LanguageInfo {
LanguageInfo(const std::string &language, const std::string &encoding);
const std::string Language;
const std::string Encoding;
};
public:
ZLLanguageDetector();
~ZLLanguageDetector();
shared_ptr<LanguageInfo> findInfo(const char *buffer, std::size_t length, int matchingCriterion = 0);
shared_ptr<LanguageInfo> findInfoForEncoding(const std::string &encoding, const char *buffer, std::size_t length, int matchingCriterion = 0);
private:
typedef std::vector<shared_ptr<ZLStatisticsBasedMatcher> > SBVector;
SBVector myMatchers;
};
#endif /* __ZLLANGUAGEDETECTOR_H__ */

@ -1 +0,0 @@
../src/language/ZLLanguageList.h

@ -0,0 +1,41 @@
/*
* Copyright (C) 2007-2012 Geometer Plus <contact@geometerplus.com>
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
* 02110-1301, USA.
*/
#ifndef __ZLLANGUAGELIST_H__
#define __ZLLANGUAGELIST_H__
#include <vector>
#include <ZLDir.h>
class ZLLanguageList {
public:
static std::string patternsDirectoryPath();
static const std::vector<std::string> &languageCodes();
static std::string languageName(const std::string &code);
private:
static std::vector<std::string> ourLanguageCodes;
private:
ZLLanguageList();
};
#endif /* __ZLLANGUAGELIST_H__ */

@ -1 +0,0 @@
../src/util/ZLLanguageUtil.h

@ -0,0 +1,38 @@
/*
* Copyright (C) 2008-2012 Geometer Plus <contact@geometerplus.com>
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
* 02110-1301, USA.
*/
#ifndef __ZLLANGUAGEUTIL_H__
#define __ZLLANGUAGEUTIL_H__
#include <string>
class ZLLanguageUtil {
public:
static const std::string OtherLanguageCode;
public:
static std::string languageByCode(unsigned char languageCode, unsigned char subLanguageCode);
static bool isRTLLanguage(const std::string &languageCode);
private:
ZLLanguageUtil();
};
#endif /* __ZLLANGUAGEUTIL_H__ */

@ -1 +0,0 @@
../src/logger/ZLLogger.h

@ -0,0 +1,48 @@
/*
* Copyright (C) 2009-2012 Geometer Plus <contact@geometerplus.com>
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
* 02110-1301, USA.
*/
#ifndef __ZLLOGGER_H__
#define __ZLLOGGER_H__
#include <string>
#include <set>
class ZLLogger {
public:
static const std::string DEFAULT_CLASS;
static ZLLogger &Instance();
private:
static ZLLogger *ourInstance;
private:
ZLLogger();
public:
void registerClass(const std::string &className);
void print(const std::string &className, const std::string &message) const;
void println(const std::string &className, const std::string &message) const;
private:
std::set<std::string> myRegisteredClasses;
};
#endif /* __ZLLOGGER_H__ */

@ -1 +0,0 @@
../src/message/ZLMessage.h

@ -0,0 +1,92 @@
/*
* Copyright (C) 2004-2012 Geometer Plus <contact@geometerplus.com>
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
* 02110-1301, USA.
*/
#ifndef __ZLMESSAGE_H__
#define __ZLMESSAGE_H__
#include <vector>
#include <map>
#include <string>
#include <shared_ptr.h>
class ZLMessageOutputChannel;
class ZLMessageSender;
class ZLMessageHandler;
class ZLCommunicationManager {
public:
static ZLCommunicationManager &Instance();
static void deleteInstance();
protected:
static ZLCommunicationManager *ourInstance;
public:
typedef std::map<std::string,std::string> Data;
protected:
ZLCommunicationManager();
virtual ~ZLCommunicationManager();
void init();
void onMessageReceived(const std::string &command, const std::vector<std::string> &arguments);
public:
virtual shared_ptr<ZLMessageOutputChannel> createMessageOutputChannel(const std::string &protocol, const std::string &testFile) = 0;
virtual void addInputMessageDescription(const std::string &command, const std::string &protocol, const Data &data) = 0;
void registerHandler(const std::string &command, shared_ptr<ZLMessageHandler> receiver);
private:
shared_ptr<ZLMessageHandler> handler(const std::string &command);
private:
std::map<std::string,weak_ptr<ZLMessageHandler> > myRegisteredHandlers;
bool myInitialized;
private:
ZLCommunicationManager(const ZLCommunicationManager&);
const ZLCommunicationManager &operator = (const ZLCommunicationManager&);
};
class ZLMessageOutputChannel {
public:
virtual ~ZLMessageOutputChannel();
virtual shared_ptr<ZLMessageSender> createSender(const ZLCommunicationManager::Data &data) = 0;
};
class ZLMessageSender {
public:
virtual ~ZLMessageSender();
virtual void sendStringMessage(const std::string &message) = 0;
};
class ZLMessageHandler {
public:
virtual ~ZLMessageHandler();
virtual void onMessageReceived(const std::vector<std::string> &arguments) = 0;
};
#endif /* __ZLMESSAGE_H__ */

@ -1 +0,0 @@
../src/constants/ZLMimeType.h

@ -0,0 +1,93 @@
/*
* Copyright (C) 2010-2012 Geometer Plus <contact@geometerplus.com>
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
* 02110-1301, USA.
*/
#ifndef __ZLMIMETYPE_H__
#define __ZLMIMETYPE_H__
#include <string>
#include <shared_ptr.h>
#include <map>
class ZLMimeType {
private:
ZLMimeType(std::string& name, std::map<std::string,std::string>& parameters);
private:
static std::map<std::string,shared_ptr<ZLMimeType> > ourSimpleTypesMap;
public:
static shared_ptr<ZLMimeType> get(const char *text);
static shared_ptr<ZLMimeType> get(std::string text);
static bool isImage(shared_ptr<ZLMimeType> mimeType);
private:
const std::map<std::string,std::string> myParameters;
const std::string myName;
public:
const std::string& getName() const;
const std::string& getParameter(const std::string &key) const;
bool weakEquals(const ZLMimeType& t) const;
bool operator ==(const ZLMimeType& t) const;
bool operator !=(const ZLMimeType& t) const;
static const shared_ptr<ZLMimeType> APPLICATION_XML;
static const shared_ptr<ZLMimeType> APPLICATION_ZIP;
static const shared_ptr<ZLMimeType> APPLICATION_EPUB_ZIP;
static const shared_ptr<ZLMimeType> APPLICATION_FB2_ZIP;
static const shared_ptr<ZLMimeType> APPLICATION_MOBIPOCKET_EBOOK;
static const shared_ptr<ZLMimeType> APPLICATION_PDF;
static const shared_ptr<ZLMimeType> APPLICATION_CHM;
static const shared_ptr<ZLMimeType> APPLICATION_PALM_DB;
static const shared_ptr<ZLMimeType> APPLICATION_ATOM_XML;
static const shared_ptr<ZLMimeType> APPLICATION_LITRES_XML;
static const shared_ptr<ZLMimeType> APPLICATION_LITRES_XML_BOOKS;
static const shared_ptr<ZLMimeType> APPLICATION_LITRES_XML_AUTHORS;
static const shared_ptr<ZLMimeType> APPLICATION_LITRES_XML_GENRES;
static const shared_ptr<ZLMimeType> APPLICATION_OPENSEARCH_XML;
static const shared_ptr<ZLMimeType> APPLICATION_OR_XML;
static const shared_ptr<ZLMimeType> APPLICATION_GZIP;
static const shared_ptr<ZLMimeType> APPLICATION_BZIP2;
static const shared_ptr<ZLMimeType> APPLICATION_TAR;
static const shared_ptr<ZLMimeType> APPLICATION_TAR_GZIP;
static const shared_ptr<ZLMimeType> APPLICATION_TAR_BZIP2;
static const shared_ptr<ZLMimeType> APPLICATION_TAR_7Z;
static const shared_ptr<ZLMimeType> IMAGE_PNG;
static const shared_ptr<ZLMimeType> IMAGE_JPEG;
static const shared_ptr<ZLMimeType> IMAGE_SVG;
static const shared_ptr<ZLMimeType> IMAGE_PALM;
static const shared_ptr<ZLMimeType> IMAGE_AUTO;
static const shared_ptr<ZLMimeType> TEXT_HTML;
static const shared_ptr<ZLMimeType> TEXT_PLAIN;
static const shared_ptr<ZLMimeType> TEXT_XML;
static const shared_ptr<ZLMimeType> EMPTY;
};
#endif /* __ZLMIMETYPE_H__ */

@ -1 +0,0 @@
../src/view/ZLMirroredPaintContext.h

@ -0,0 +1,72 @@
/*
* Copyright (C) 2004-2012 Geometer Plus <contact@geometerplus.com>
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
* 02110-1301, USA.
*/
#ifndef __ZLMIRROREDPAINTCONTEXT_H__
#define __ZLMIRROREDPAINTCONTEXT_H__
#include <vector>
#include <string>
#include <ZLColor.h>
#include <ZLPaintContext.h>
class ZLMirroredPaintContext : public ZLPaintContext {
public:
ZLMirroredPaintContext(ZLPaintContext &base);
public:
int mirroredX(int x) const;
private:
void clear(ZLColor color);
void setFont(const std::string &family, int size, bool bold, bool italic);
void setColor(ZLColor color, LineStyle style);
void setFillColor(ZLColor color, FillStyle style);
int width() const;
int height() const;
int stringWidth(const char *str, int len, bool rtl) const;
int spaceWidth() const;
int stringHeight() const;
int descent() const;
void drawString(int x, int y, const char *str, int len, bool rtl);
void drawImage(int x, int y, const ZLImageData &image);
void drawImage(int x, int y, const ZLImageData &image, int width, int height, ScalingType type);
void drawLine(int x0, int y0, int x1, int y1);
void fillRectangle(int x0, int y0, int x1, int y1);
void drawFilledCircle(int x, int y, int r);
const std::string realFontFamilyName(std::string &fontFamily) const;
void fillFamiliesList(std::vector<std::string> &families) const;
private:
ZLPaintContext &myBase;
};
inline int ZLMirroredPaintContext::mirroredX(int x) const {
return myBase.width() - x - 1;
}
#endif /* __ZLMIRROREDPAINTCONTEXT_H__ */

@ -20,7 +20,7 @@
#ifndef __ZLNETWORKDOWNLOADREQUEST_H__
#define __ZLNETWORKDOWNLOADREQUEST_H__
#include "../ZLNetworkRequest.h"
#include "ZLNetworkRequest.h"
class ZLOutputStream;

@ -1 +0,0 @@
../src/image/ZLNetworkImage.h

@ -0,0 +1,43 @@
/*
* Copyright (C) 2009-2012 Geometer Plus <contact@geometerplus.com>
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
* 02110-1301, USA.
*/
#ifndef __ZLNETWORKIMAGE_H__
#define __ZLNETWORKIMAGE_H__
#include <ZLImage.h>
class ZLFileImage;
class ZLNetworkImage : public ZLSingleImage {
public:
ZLNetworkImage(shared_ptr<ZLMimeType> mimeType, const std::string &url);
const shared_ptr<std::string> stringData() const;
private:
shared_ptr<ZLNetworkRequest> synchronizationData() const;
private:
const std::string myURL;
std::string myFileName;
mutable bool myIsSynchronized;
mutable shared_ptr<ZLFileImage> myCachedImage;
};
#endif /* __ZLNETWORKIMAGE_H__ */

@ -1 +0,0 @@
../src/network/ZLNetworkManager.h

@ -0,0 +1,103 @@
/*
* Copyright (C) 2008-2012 Geometer Plus <contact@geometerplus.com>
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
* 02110-1301, USA.
*/
#ifndef __ZLNETWORKMANAGER_H__
#define __ZLNETWORKMANAGER_H__
#include <string>
#include <shared_ptr.h>
#include <ZLOptions.h>
#include <ZLNetworkRequest.h>
#include <ZLRunnable.h>
class ZLNetworkData;
class ZLOutputStream;
class ZLXMLReader;
class ZLNetworkManager {
public:
static void deleteInstance();
static ZLNetworkManager &Instance();
static std::string CacheDirectory();
static std::string CookiesPath();
protected:
static ZLNetworkManager *ourInstance;
public:
ZLIntegerRangeOption &ConnectTimeoutOption() const;
ZLIntegerRangeOption &TimeoutOption() const;
ZLBooleanOption &UseProxyOption() const;
ZLStringOption &ProxyHostOption() const;
ZLStringOption &ProxyPortOption() const;
protected:
ZLNetworkManager();
virtual ~ZLNetworkManager();
public:
virtual std::string perform(const ZLNetworkRequest::Vector &requests) const = 0;
virtual std::string performAsync(const ZLNetworkRequest::Vector &requests) const = 0;
std::string perform(shared_ptr<ZLNetworkRequest> request) const;
std::string performAsync(shared_ptr<ZLNetworkRequest> request) const;
public:
virtual bool connect() const;
virtual void release() const;
virtual bool providesProxyInfo() const;
protected:
virtual bool useProxy() const;
virtual std::string proxyHost() const;
virtual std::string proxyPort() const;
public:
// returns error message
std::string downloadFile(const std::string &url, const std::string &fileName, shared_ptr<ZLNetworkRequest::Listener> listener = 0) const;
public:
shared_ptr<ZLNetworkRequest> createDownloadRequest(const std::string &url, const std::string &fileName) const;
shared_ptr<ZLNetworkRequest> createDownloadRequest(const std::string &url, shared_ptr<ZLOutputStream> stream) const;
shared_ptr<ZLNetworkRequest> createNoActionRequest(const std::string &url) const;
shared_ptr<ZLNetworkRequest> createReadToStringRequest(const std::string &url, std::string &buffer) const;
shared_ptr<ZLNetworkRequest> createXMLParserRequest(const std::string &url, shared_ptr<ZLXMLReader> reader, shared_ptr<ZLRunnable> runnable = 0) const;
public:
void setUserAgent(const std::string &userAgent);
const std::string &userAgent() const;
private:
mutable shared_ptr<ZLIntegerRangeOption> myConnectTimeoutOption;
mutable shared_ptr<ZLIntegerRangeOption> myTimeoutOption;
mutable shared_ptr<ZLBooleanOption> myUseProxyOption;
mutable shared_ptr<ZLStringOption> myProxyHostOption;
mutable shared_ptr<ZLStringOption> myProxyPortOption;
std::string myUserAgent;
};
inline void ZLNetworkManager::setUserAgent(const std::string &userAgent) { myUserAgent = userAgent; }
inline const std::string &ZLNetworkManager::userAgent() const { return myUserAgent; }
#endif /* __ZLNETWORKMANAGER_H__ */

@ -20,7 +20,7 @@
#ifndef __ZLNETWORKNOACTIONREQUEST_H__
#define __ZLNETWORKNOACTIONREQUEST_H__
#include "../ZLNetworkRequest.h"
#include "ZLNetworkRequest.h"
class ZLNetworkNoActionRequest : public ZLNetworkRequest {

@ -20,7 +20,7 @@
#ifndef __ZLNETWORKREADTOSTRINGREQUEST_H__
#define __ZLNETWORKREADTOSTRINGREQUEST_H__
#include "../ZLNetworkRequest.h"
#include "ZLNetworkRequest.h"
class ZLNetworkReadToStringRequest : public ZLNetworkRequest {

@ -1 +0,0 @@
../src/network/ZLNetworkRequest.h

@ -0,0 +1,120 @@
/*
* Copyright (C) 2010-2012 Geometer Plus <contact@geometerplus.com>
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
* 02110-1301, USA.
*/
#ifndef __ZLNETWORKREQUEST_H__
#define __ZLNETWORKREQUEST_H__
#include <string>
#include <vector>
#include <shared_ptr.h>
class ZLNetworkRequest {
public:
typedef std::vector<shared_ptr<ZLNetworkRequest> > Vector;
public:
class Listener {
protected:
Listener();
public:
virtual ~Listener();
virtual void finished(const std::string &error = std::string()) = 0;
virtual void showPercent(int ready, int full);
virtual void setUIStatus(bool enabled);
friend class ZLNetworkRequest;
};
protected:
ZLNetworkRequest(const std::string &url);
public:
virtual bool handleHeader(void *ptr, std::size_t size);
virtual bool handleContent(void *ptr, std::size_t size) = 0;
virtual bool doBefore() = 0;
// When error is empty return false MUST make request fail; when error is not empty return value MUST be ignored
virtual bool doAfter(const std::string &error) = 0;
protected:
void setErrorMessage(const std::string &message);
public:
const std::string &errorMessage() const;
const std::string &url() const;
public: // HTTP parameters
void setupAuthentication(const std::string &userName, const std::string &password);
const std::string &userName() const;
const std::string &password() const;
void setRedirectionSupported(bool supported);
bool isRedirectionSupported() const;
const std::vector<std::pair<std::string, std::string> > &postParameters() const;
void setPostParameters(const std::vector<std::pair<std::string, std::string> > &parameters);
public: //listeners methods
bool hasListener() const;
void setListener(shared_ptr<Listener> listener);
void setPercent(int ready, int full);
void setUIStatus(bool enabled);
protected:
void finished(const std::string &error);
shared_ptr<Listener> listener() const;
private:
const std::string myURL;
std::string myErrorMessage;
std::string myUserName;
std::string myPassword;
bool myRedirectionSupported;
std::vector<std::pair<std::string, std::string> > myPostParameters;
shared_ptr<Listener> myListener;
private: // disable copying
ZLNetworkRequest(const ZLNetworkRequest &);
const ZLNetworkRequest &operator = (const ZLNetworkRequest &);
};
inline void ZLNetworkRequest::setupAuthentication(const std::string &userName, const std::string &password) {
myUserName = userName;
myPassword = password;
}
inline const std::string &ZLNetworkRequest::userName() const { return myUserName; }
inline const std::string &ZLNetworkRequest::password() const { return myPassword; }
inline void ZLNetworkRequest::setRedirectionSupported(bool supported) { myRedirectionSupported = supported; }
inline bool ZLNetworkRequest::isRedirectionSupported() const { return myRedirectionSupported; }
inline const std::vector<std::pair<std::string, std::string> > &ZLNetworkRequest::postParameters() const { return myPostParameters; }
inline shared_ptr<ZLNetworkRequest::Listener> ZLNetworkRequest::listener() const { return myListener; }
#endif /* __ZLNETWORKREQUEST_H__ */

@ -1 +0,0 @@
../src/network/ZLNetworkUtil.h

@ -0,0 +1,42 @@
/*
* Copyright (C) 2008-2012 Geometer Plus <contact@geometerplus.com>
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
* 02110-1301, USA.
*/
#ifndef __ZLNETWORKUTIL_H__
#define __ZLNETWORKUTIL_H__
#include <string>
class ZLNetworkUtil {
public:
static std::string htmlEncode(const std::string &stringToEncode);
static std::string hostFromUrl(const std::string &url);
static std::string url(const std::string &baseUrl, const std::string &relativePath);
static std::string &appendParameter(std::string &url, const std::string &name, const std::string &value);
static bool hasParameter(const std::string &url, const std::string &name);
private:
static bool isNonRelativeUrl(const std::string &url);
private:
ZLNetworkUtil();
};
#endif /* __ZLNETWORKUTIL_H__ */

@ -22,7 +22,7 @@
#include <ZLRunnable.h>
#include "../ZLNetworkRequest.h"
#include "ZLNetworkRequest.h"
class ZLXMLReader;
class ZLAsynchronousInputStream;

@ -1 +0,0 @@
../src/dialogs/ZLOpenFileDialog.h

@ -0,0 +1,43 @@
/*
* Copyright (C) 2010-2012 Geometer Plus <contact@geometerplus.com>
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
* 02110-1301, USA.
*/
#ifndef __ZLOPENFILEDIALOG_H__
#define __ZLOPENFILEDIALOG_H__
#include <string>
class ZLFile;
class ZLOpenFileDialog {
public:
class Filter {
public:
virtual ~Filter();
virtual bool accepts(const ZLFile &file) const = 0;
};
public:
virtual bool run() = 0;
virtual std::string filePath() const = 0;
virtual std::string directoryPath() const = 0;
};
#endif /* __ZLOPENFILEDIALOG_H__ */

@ -1 +0,0 @@
../src/dialogs/ZLOptionEntry.h

@ -0,0 +1,294 @@
/*
* Copyright (C) 2004-2012 Geometer Plus <contact@geometerplus.com>
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
* 02110-1301, USA.
*/
#ifndef __ZLOPTIONENTRY_H__
#define __ZLOPTIONENTRY_H__
#include <vector>
#include <string>
#include <ZLOptions.h>
class ZLOptionView;
class ZLOptionEntry {
public:
enum ZLOptionKind {
CHOICE,
BOOLEAN,
BOOLEAN3,
STRING,
PASSWORD,
SPIN,
COMBO,
COLOR,
KEY,
ORDER,
MULTILINE,
STATIC,
};
public:
ZLOptionEntry();
virtual ~ZLOptionEntry();
virtual ZLOptionKind kind() const = 0;
void setView(ZLOptionView *view);
void resetView();
virtual void setVisible(bool visible);
bool isVisible() const;
virtual void setActive(bool active);
bool isActive() const;
private:
ZLOptionView *myView;
bool myIsVisible;
bool myIsActive;
};
class ZLChoiceOptionEntry : public ZLOptionEntry {
protected:
ZLChoiceOptionEntry();
public:
ZLOptionKind kind() const;
virtual const std::string &text(int index) const = 0;
virtual int choiceNumber() const = 0;
virtual int initialCheckedIndex() const = 0;
virtual void onAccept(int index) = 0;
};
class ZLTextOptionEntry : public ZLOptionEntry {
public:
virtual const std::string &initialValue() const = 0;
void onAccept(const char *value);
virtual void onAccept(const std::string &value) = 0;
virtual bool useOnValueEdited() const;
void onValueEdited(const char *value);
virtual void onValueEdited(const std::string &value);
};
class ZLStringOptionEntry : public ZLTextOptionEntry {
protected:
ZLStringOptionEntry();
public:
ZLOptionKind kind() const;
};
class ZLPasswordOptionEntry : public ZLTextOptionEntry {
protected:
ZLPasswordOptionEntry();
public:
ZLOptionKind kind() const;
};
class ZLMultilineOptionEntry : public ZLTextOptionEntry {
protected:
ZLMultilineOptionEntry();
public:
ZLOptionKind kind() const;
};
class ZLBooleanOptionEntry : public ZLOptionEntry {
protected:
ZLBooleanOptionEntry();
public:
ZLOptionKind kind() const;
virtual bool initialState() const = 0;
virtual void onStateChanged(bool state);
virtual void onAccept(bool state) = 0;
};
class ZLBoolean3OptionEntry : public ZLOptionEntry {
protected:
ZLBoolean3OptionEntry();
public:
ZLOptionKind kind() const;
virtual ZLBoolean3 initialState() const = 0;
virtual void onStateChanged(ZLBoolean3 state);
virtual void onAccept(ZLBoolean3 state) = 0;
};
class ZLSpinOptionEntry : public ZLOptionEntry {
protected:
ZLSpinOptionEntry();
public:
ZLOptionKind kind() const;
virtual int initialValue() const = 0;
virtual int minValue() const = 0;
virtual int maxValue() const = 0;
virtual int step() const = 0;
virtual void onAccept(int value) = 0;
};
class ZLComboOptionEntry : public ZLOptionEntry {
protected:
ZLComboOptionEntry(bool editable = false);
public:
ZLOptionKind kind() const;
virtual const std::string &initialValue() const = 0;
virtual const std::vector<std::string> &values() const = 0;
virtual void onValueSelected(int index);
void onStringValueSelected(const char *value);
void onStringValueSelected(const std::string &value);
virtual bool useOnValueEdited() const;
void onValueEdited(const char *value);
virtual void onValueEdited(const std::string &value);
void onAccept(const char *value);
virtual void onAccept(const std::string &value) = 0;
bool isEditable() const;
private:
const bool myEditable;
};
class ZLColorOptionEntry : public ZLOptionEntry {
protected:
ZLColorOptionEntry();
public:
ZLOptionKind kind() const;
virtual const ZLColor initialColor() const = 0;
virtual const ZLColor color() const = 0;
virtual void onAccept(ZLColor color) = 0;
virtual void onReset(ZLColor color);
};
class ZLKeyOptionEntry : public ZLOptionEntry {
public:
ZLKeyOptionEntry();
void addActionName(const std::string &actionName);
const std::vector<std::string> &actionNames() const;
virtual void onAccept() = 0;
virtual int actionIndex(const std::string &key) = 0;
virtual void onValueChanged(const std::string &key, int index) = 0;
virtual void onKeySelected(const std::string &key) = 0;
protected:
ZLOptionKind kind() const;
private:
std::vector<std::string> myActionNames;
};
class ZLOrderOptionEntry : public ZLOptionEntry {
public:
ZLOrderOptionEntry();
std::vector<std::string> &values();
protected:
ZLOptionKind kind() const;
private:
std::vector<std::string> myValues;
};
class ZLStaticTextOptionEntry : public ZLOptionEntry {
public:
virtual ZLOptionKind kind() const;
virtual const std::string &initialValue() const = 0;
};
inline ZLOptionEntry::ZLOptionEntry() : myView(0), myIsVisible(true), myIsActive(true) {}
inline ZLOptionEntry::~ZLOptionEntry() {}
inline void ZLOptionEntry::setView(ZLOptionView *view) { myView = view; }
inline bool ZLOptionEntry::isVisible() const { return myIsVisible; }
inline bool ZLOptionEntry::isActive() const { return myIsActive; }
inline ZLChoiceOptionEntry::ZLChoiceOptionEntry() {}
inline ZLOptionEntry::ZLOptionKind ZLChoiceOptionEntry::kind() const { return CHOICE; }
inline bool ZLTextOptionEntry::useOnValueEdited() const { return false; }
inline void ZLTextOptionEntry::onValueEdited(const std::string&) {}
inline ZLStringOptionEntry::ZLStringOptionEntry() {}
inline ZLOptionEntry::ZLOptionKind ZLStringOptionEntry::kind() const { return STRING; }
inline ZLPasswordOptionEntry::ZLPasswordOptionEntry() {}
inline ZLOptionEntry::ZLOptionKind ZLPasswordOptionEntry::kind() const { return PASSWORD; }
inline ZLMultilineOptionEntry::ZLMultilineOptionEntry() {}
inline ZLOptionEntry::ZLOptionKind ZLMultilineOptionEntry::kind() const { return MULTILINE; }
inline ZLBooleanOptionEntry::ZLBooleanOptionEntry() {}
inline ZLOptionEntry::ZLOptionKind ZLBooleanOptionEntry::kind() const { return BOOLEAN; }
inline void ZLBooleanOptionEntry::onStateChanged(bool) {}
inline ZLBoolean3OptionEntry::ZLBoolean3OptionEntry() {}
inline ZLOptionEntry::ZLOptionKind ZLBoolean3OptionEntry::kind() const { return BOOLEAN3; }
inline void ZLBoolean3OptionEntry::onStateChanged(ZLBoolean3) {}
inline ZLSpinOptionEntry::ZLSpinOptionEntry() {}
inline ZLOptionEntry::ZLOptionKind ZLSpinOptionEntry::kind() const { return SPIN; }
inline ZLComboOptionEntry::ZLComboOptionEntry(bool editable) : myEditable(editable) {}
inline ZLOptionEntry::ZLOptionKind ZLComboOptionEntry::kind() const { return COMBO; }
inline void ZLComboOptionEntry::onValueSelected(int) {}
inline bool ZLComboOptionEntry::useOnValueEdited() const { return false; }
inline void ZLComboOptionEntry::onValueEdited(const std::string&) {}
inline bool ZLComboOptionEntry::isEditable() const { return myEditable; }
inline ZLColorOptionEntry::ZLColorOptionEntry() {}
inline ZLOptionEntry::ZLOptionKind ZLColorOptionEntry::kind() const { return COLOR; }
inline void ZLColorOptionEntry::onReset(ZLColor) {}
inline ZLKeyOptionEntry::ZLKeyOptionEntry() {}
inline void ZLKeyOptionEntry::addActionName(const std::string &actionName) { myActionNames.push_back(actionName); }
inline const std::vector<std::string> &ZLKeyOptionEntry::actionNames() const { return myActionNames; }
inline ZLOptionEntry::ZLOptionKind ZLKeyOptionEntry::kind() const { return KEY; }
inline ZLOrderOptionEntry::ZLOrderOptionEntry() {}
inline ZLOptionEntry::ZLOptionKind ZLOrderOptionEntry::kind() const { return ORDER; }
inline std::vector<std::string> &ZLOrderOptionEntry::values() { return myValues; }
inline ZLOptionEntry::ZLOptionKind ZLStaticTextOptionEntry::kind() const { return STATIC; }
#endif /* __ZLOPTIONENTRY_H__ */

@ -1 +0,0 @@
../src/options/ZLOptions.h

@ -0,0 +1,217 @@
/*
* Copyright (C) 2004-2012 Geometer Plus <contact@geometerplus.com>
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
* 02110-1301, USA.
*/
#ifndef __ZLOPTIONS_H__
#define __ZLOPTIONS_H__
#include <vector>
#include <string>
#include <ZLColor.h>
#include <ZLBoolean3.h>
class ZLCategoryKey {
public:
static const ZLCategoryKey EMPTY;
static const ZLCategoryKey LOOK_AND_FEEL;
static const ZLCategoryKey CONFIG;
static const ZLCategoryKey STATE;
static const ZLCategoryKey SYSTEM;
static const ZLCategoryKey NETWORK;
protected:
explicit ZLCategoryKey(const std::string &name);
public:
bool operator == (const ZLCategoryKey &key) const;
bool operator != (const ZLCategoryKey &key) const;
const std::string Name;
};
class ZLConfig;
class ZLOption {
private:
static ZLConfig *ourConfig;
public:
static void createInstance();
static void deleteInstance();
protected:
const std::string &getConfigValue(const std::string &defaultValue) const;
const std::string &getConfigValue() const;
const std::string &getDefaultConfigValue(const std::string &defaultValue) const;
const std::string &getDefaultConfigValue() const;
void setConfigValue(const std::string &value) const;
void unsetConfigValue() const;
public:
static const std::string PLATFORM_GROUP;
static const std::string FULL_KEYBOARD_CONTROL;
static const std::string KEYBOARD_PRESENTED;
static const std::string MOUSE_PRESENTED;
static const std::string TOUCHSCREEN_PRESENTED;
static const std::string FINGER_TAP_DETECTABLE;
public:
static void clearGroup(const std::string &group);
static void listOptionNames(const std::string &group, std::vector<std::string> &names);
static void listOptionGroups(std::vector<std::string> &groups);
static bool isAutoSavingSupported();
static void startAutoSave(int seconds);
protected:
ZLOption(const ZLCategoryKey &category, const std::string &group, const std::string &optionName);
public:
virtual ~ZLOption();
private:
const ZLCategoryKey &myCategory;
std::string myGroupName;
std::string myOptionName;
protected:
mutable bool myIsSynchronized;
private:
ZLOption(const ZLOption&);
const ZLOption &operator = (const ZLOption&);
};
class ZLSimpleOption : public ZLOption {
public:
enum Type {
TYPE_BOOLEAN,
TYPE_BOOLEAN3,
//TYPE_COLOR,
TYPE_STRING,
};
protected:
ZLSimpleOption(const ZLCategoryKey &category, const std::string &group, const std::string &optionName);
public:
virtual Type type() const = 0;
};
class ZLBooleanOption : public ZLSimpleOption {
public:
ZLBooleanOption(const ZLCategoryKey &category, const std::string &group, const std::string &optionName, bool defaultValue);
Type type() const;
bool value() const;
void setValue(bool value);
private:
mutable bool myValue;
const bool myDefaultValue;
};
class ZLBoolean3Option : public ZLSimpleOption {
public:
ZLBoolean3Option(const ZLCategoryKey &category, const std::string &group, const std::string &optionName, ZLBoolean3 defaultValue);
Type type() const;
ZLBoolean3 value() const;
void setValue(ZLBoolean3 value);
private:
mutable ZLBoolean3 myValue;
const ZLBoolean3 myDefaultValue;
};
class ZLIntegerOption : public ZLOption {
public:
ZLIntegerOption(const ZLCategoryKey &category, const std::string &group, const std::string &optionName, long defaultValue);
long value() const;
void setValue(long value);
private:
mutable long myValue;
const long myDefaultValue;
};
class ZLIntegerRangeOption : public ZLOption {
public:
ZLIntegerRangeOption(const ZLCategoryKey &category, const std::string &group, const std::string &optionName, long minValue, long maxValue, long defaultValue);
long value() const;
void setValue(long value);
long minValue() const;
long maxValue() const;
private:
mutable long myValue;
const long myMinValue;
const long myMaxValue;
const long myDefaultValue;
};
class ZLColorOption : public ZLOption {
public:
ZLColorOption(const ZLCategoryKey &category, const std::string &group, const std::string &optionName, ZLColor defaultValue);
ZLColor value() const;
void setValue(ZLColor value);
private:
mutable long myIntValue;
const long myDefaultIntValue;
};
class ZLDoubleOption : public ZLOption {
public:
ZLDoubleOption(const ZLCategoryKey &category, const std::string &group, const std::string &optionName, double defaultValue);
double value() const;
void setValue(double value);
private:
mutable double myValue;
const double myDefaultValue;
};
class ZLStringOption : public ZLSimpleOption {
public:
ZLStringOption(const ZLCategoryKey &category, const std::string &group, const std::string &optionName, const std::string &defaultValue);
Type type() const;
const std::string &value() const;
void setValue(const std::string &value);
private:
mutable std::string myValue;
const std::string myDefaultValue;
};
#endif /* __ZLOPTIONS_H__ */

@ -1 +0,0 @@
../src/dialogs/ZLOptionsDialog.h

@ -0,0 +1,75 @@
/*
* Copyright (C) 2004-2012 Geometer Plus <contact@geometerplus.com>
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
* 02110-1301, USA.
*/
#ifndef __ZLOPTIONSDIALOG_H__
#define __ZLOPTIONSDIALOG_H__
#include <vector>
#include <string>
#include <shared_ptr.h>
#include <ZLRunnable.h>
#include <ZLDialogContent.h>
#include <ZLOptions.h>
#include <ZLResource.h>
class ZLOptionEntry;
class ZLDialogContentBuilder;
class ZLOptionsDialog {
protected:
static void addPlatformDependentBuilder(shared_ptr<ZLDialogContentBuilder> builder);
private:
static std::vector<shared_ptr<ZLDialogContentBuilder> > ourPlatformDependentBuilders;
protected:
ZLOptionsDialog(const ZLResource &resource, shared_ptr<ZLRunnable> applyAction);
public:
virtual ~ZLOptionsDialog();
virtual ZLDialogContent &createTab(const ZLResourceKey &key) = 0;
void createPlatformDependentTabs();
virtual bool run();
protected:
virtual const std::string &selectedTabKey() const = 0;
virtual void selectTab(const ZLResourceKey &key) = 0;
virtual bool runInternal() = 0;
void accept();
const std::string &caption() const;
const ZLResource &tabResource(const ZLResourceKey &key) const;
protected:
ZLStringOption TabOption;
private:
const ZLResource &myResource;
protected:
shared_ptr<ZLRunnable> myApplyAction;
std::vector<shared_ptr<ZLDialogContent> > myTabs;
};
#endif /* __ZLOPTIONSDIALOG_H__ */

@ -1 +0,0 @@
../src/filesystem/ZLOutputStream.h

@ -0,0 +1,45 @@
/*
* Copyright (C) 2004-2012 Geometer Plus <contact@geometerplus.com>
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
* 02110-1301, USA.
*/
#ifndef __ZLOUTPUTSTREAM_H__
#define __ZLOUTPUTSTREAM_H__
#include <string>
class ZLOutputStream {
protected:
ZLOutputStream();
public:
virtual ~ZLOutputStream();
virtual bool open() = 0;
virtual void write(const char *data, std::size_t len) = 0;
virtual void write(const std::string &str) = 0;
virtual void close() = 0;
private:
ZLOutputStream(const ZLOutputStream&);
const ZLOutputStream &operator = (const ZLOutputStream&);
};
inline ZLOutputStream::ZLOutputStream() {}
inline ZLOutputStream::~ZLOutputStream() {}
#endif /* __ZLOUTPUTSTREAM_H__ */

@ -1 +0,0 @@
../src/view/ZLPaintContext.h

@ -0,0 +1,98 @@
/*
* Copyright (C) 2004-2012 Geometer Plus <contact@geometerplus.com>
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
* 02110-1301, USA.
*/
#ifndef __ZLPAINTCONTEXT_H__
#define __ZLPAINTCONTEXT_H__
#include <vector>
#include <string>
#include <ZLColor.h>
#include <ZLImageManager.h>
class ZLPaintContext {
public:
enum LineStyle {
SOLID_LINE,
DASH_LINE,
};
enum FillStyle {
SOLID_FILL,
HALF_FILL,
};
protected:
ZLPaintContext();
public:
virtual ~ZLPaintContext();
virtual void clear(ZLColor color) = 0;
virtual void setFont(const std::string &family, int size, bool bold, bool italic) = 0;
virtual void setColor(ZLColor color, LineStyle style = SOLID_LINE) = 0;
virtual void setFillColor(ZLColor color, FillStyle style = SOLID_FILL) = 0;
virtual int width() const = 0;
virtual int height() const = 0;
virtual int stringWidth(const char *str, int len, bool rtl) const = 0;
virtual int spaceWidth() const = 0;
virtual int stringHeight() const = 0;
virtual int descent() const = 0;
virtual void drawString(int x, int y, const char *str, int len, bool rtl) = 0;
enum ScalingType {
SCALE_FIT_TO_SIZE,
SCALE_REDUCE_SIZE
};
int imageWidth(const ZLImageData &image) const;
int imageHeight(const ZLImageData &image) const;
int imageWidth(const ZLImageData &image, int width, int height, ScalingType type) const;
int imageHeight(const ZLImageData &image, int width, int height, ScalingType type) const;
virtual void drawImage(int x, int y, const ZLImageData &image) = 0;
virtual void drawImage(int x, int y, const ZLImageData &image, int width, int height, ScalingType type) = 0;
virtual void drawLine(int x0, int y0, int x1, int y1) = 0;
virtual void fillRectangle(int x0, int y0, int x1, int y1) = 0;
virtual void drawFilledCircle(int x, int y, int r) = 0;
const std::vector<std::string> &fontFamilies() const;
virtual const std::string realFontFamilyName(std::string &fontFamily) const = 0;
protected:
virtual void fillFamiliesList(std::vector<std::string> &families) const = 0;
private:
mutable std::vector<std::string> myFamilies;
private:
ZLPaintContext(const ZLPaintContext&);
const ZLPaintContext &operator = (const ZLPaintContext&);
friend class ZLMirroredPaintContext;
};
inline int ZLPaintContext::imageWidth(const ZLImageData &image) const { return image.width(); }
inline int ZLPaintContext::imageHeight(const ZLImageData &image) const { return image.height(); }
#endif /* __ZLPAINTCONTEXT_H__ */

@ -1 +0,0 @@
../src/network/ZLPlainAsynchronousInputStream.h

@ -0,0 +1,40 @@
/*
* Copyright (C) 2009-2012 Geometer Plus <contact@geometerplus.com>
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
* 02110-1301, USA.
*/
#ifndef __ZLPLAINASYNCHRONOUSINPUTSTREAM_H__
#define __ZLPLAINASYNCHRONOUSINPUTSTREAM_H__
#include <ZLAsynchronousInputStream.h>
class ZLPlainAsynchronousInputStream : public ZLAsynchronousInputStream {
public:
ZLPlainAsynchronousInputStream(const char *encoding = 0);
private:
bool processInputInternal(Handler &handler);
private:
// disable copying
ZLPlainAsynchronousInputStream(const ZLPlainAsynchronousInputStream &);
const ZLPlainAsynchronousInputStream &operator = (const ZLPlainAsynchronousInputStream &);
};
#endif /* __ZLPLAINASYNCHRONOUSINPUTSTREAM_H__ */

@ -1 +0,0 @@
../src/application/ZLPopupData.h

@ -0,0 +1,43 @@
/*
* Copyright (C) 2008-2012 Geometer Plus <contact@geometerplus.com>
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
* 02110-1301, USA.
*/
#ifndef __ZLPOPUPDATA_H__
#define __ZLPOPUPDATA_H__
#include <string>
#include <ZLResource.h>
class ZLPopupData {
public:
virtual ~ZLPopupData();
virtual std::size_t id() const = 0;
virtual std::size_t count() const = 0;
virtual const std::string text(std::size_t index) = 0;
virtual void run(std::size_t index) = 0;
static const ZLResource &resource(const std::string &actionId);
};
inline ZLPopupData::~ZLPopupData() {
}
#endif /* __ZLPOPUPDATA_H__ */

@ -1 +0,0 @@
../src/dialogs/ZLProgressDialog.h

@ -0,0 +1,49 @@
/*
* Copyright (C) 2009-2012 Geometer Plus <contact@geometerplus.com>
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
* 02110-1301, USA.
*/
#ifndef __ZLPROGRESSDIALOG_H__
#define __ZLPROGRESSDIALOG_H__
#include <ZLResource.h>
#include <ZLNetworkRequest.h>
#include <ZLRunnable.h>
class ZLProgressDialog {
private:
class ProgressListener;
protected:
ZLProgressDialog(const ZLResourceKey &key);
public:
virtual ~ZLProgressDialog();
shared_ptr<ZLNetworkRequest::Listener> listener();
virtual void run(ZLRunnable &runnable) = 0;
virtual void setMessage(const std::string &message) = 0;
const std::string &messageText() const;
std::string messageText(int percent) const;
private:
const std::string myMessage;
};
#endif /* __ZLPROGRESSDIALOG_H__ */

@ -1 +0,0 @@
../src/resources/ZLResource.h

@ -0,0 +1,59 @@
/*
* Copyright (C) 2004-2012 Geometer Plus <contact@geometerplus.com>
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
* 02110-1301, USA.
*/
#ifndef __ZLRESOURCE_H__
#define __ZLRESOURCE_H__
#include <string>
struct ZLResourceKey {
ZLResourceKey() {}
explicit ZLResourceKey(const std::string &name) : Name(name) {}
std::string Name;
};
class ZLResource {
public:
static const ZLResource &resource(const std::string &key);
static const ZLResource &resource(const ZLResourceKey &key);
protected:
ZLResource(const std::string &name);
public:
virtual ~ZLResource();
const std::string &name() const;
virtual bool hasValue() const = 0;
virtual const std::string &value() const = 0;
virtual const std::string &value(int number) const = 0;
virtual const ZLResource &operator [] (const std::string &key) const = 0;
const ZLResource &operator [] (const ZLResourceKey &key) const;
private:
const std::string myName;
private:
// disable copying
ZLResource(const ZLResource&);
const ZLResource &operator = (const ZLResource&);
};
#endif /* __ZLRESOURCE_H__ */

@ -1 +0,0 @@
../src/runnable/ZLRunnable.h

@ -0,0 +1,45 @@
/*
* Copyright (C) 2004-2012 Geometer Plus <contact@geometerplus.com>
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
* 02110-1301, USA.
*/
#ifndef __ZLRUNNABLE_H__
#define __ZLRUNNABLE_H__
#include <string>
class ZLResource;
struct ZLResourceKey;
class ZLRunnable {
public:
virtual ~ZLRunnable();
virtual void run() = 0;
};
class ZLRunnableWithKey : public ZLRunnable {
public:
virtual ZLResourceKey key() const = 0;
virtual std::string text(const ZLResource &resource) const;
virtual bool makesSense() const;
};
inline ZLRunnable::~ZLRunnable() {}
#endif /* __ZLRUNNABLE_H__ */

@ -1 +0,0 @@
../src/util/ZLSearchUtil.h

@ -0,0 +1,60 @@
/*
* Copyright (C) 2004-2012 Geometer Plus <contact@geometerplus.com>
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
* 02110-1301, USA.
*/
#ifndef __ZLSEARCHUTIL_H__
#define __ZLSEARCHUTIL_H__
#include <string>
class ZLSearchPattern {
public:
ZLSearchPattern(const std::string &pattern, bool ignoreCase);
~ZLSearchPattern();
int length() const;
private:
bool ignoreCase() const;
const std::string &lowerCasePattern() const;
const std::string &upperCasePattern() const;
private:
bool myIgnoreCase;
std::string myLowerCasePattern;
std::string myUpperCasePattern;
friend class ZLSearchUtil;
};
class ZLSearchUtil {
private:
ZLSearchUtil();
public:
static int find(const char *text, std::size_t length, const ZLSearchPattern &pattern, int pos = 0);
};
inline ZLSearchPattern::~ZLSearchPattern() {}
inline int ZLSearchPattern::length() const { return myLowerCasePattern.length(); }
inline bool ZLSearchPattern::ignoreCase() const { return myIgnoreCase; }
inline const std::string &ZLSearchPattern::lowerCasePattern() const { return myLowerCasePattern; }
inline const std::string &ZLSearchPattern::upperCasePattern() const { return myUpperCasePattern; }
#endif /* __ZLSEARCHUTIL_H__ */

@ -1 +0,0 @@
../src/util/ZLSliceInputStream.h

@ -0,0 +1,43 @@
/*
* Copyright (C) 2009-2012 Geometer Plus <contact@geometerplus.com>
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
* 02110-1301, USA.
*/
#ifndef __ZLSLICEINPUTSTREAM_H__
#define __ZLSLICEINPUTSTREAM_H__
#include <ZLInputStream.h>
class ZLSliceInputStream : public ZLInputStream {
public:
ZLSliceInputStream(shared_ptr<ZLInputStream> base, std::size_t start, std::size_t length);
bool open();
std::size_t read(char *buffer, std::size_t maxSize);
void close();
void seek(int offset, bool absoluteOffset);
std::size_t offset() const;
std::size_t sizeOfOpened();
private:
shared_ptr<ZLInputStream> myBaseStream;
std::size_t myStart;
std::size_t myLength;
};
#endif /* __ZLSLICEINPUTSTREAM_H__ */

@ -1 +0,0 @@
../src/image/ZLStreamImage.h

@ -0,0 +1,44 @@
/*
* Copyright (C) 2004-2012 Geometer Plus <contact@geometerplus.com>
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
* 02110-1301, USA.
*/
#ifndef __ZLSTREAMIMAGE_H__
#define __ZLSTREAMIMAGE_H__
#include <string>
#include <ZLImage.h>
#include <ZLInputStream.h>
class ZLStreamImage : public ZLSingleImage {
public:
ZLStreamImage(shared_ptr<ZLMimeType> mimeType, std::size_t offset, std::size_t size = 0);
const shared_ptr<std::string> stringData() const;
private:
virtual shared_ptr<ZLInputStream> inputStream() const = 0;
private:
std::size_t myOffset;
mutable std::size_t mySize;
};
inline ZLStreamImage::ZLStreamImage(shared_ptr<ZLMimeType> mimeType, std::size_t offset, std::size_t size) : ZLSingleImage(mimeType), myOffset(offset), mySize(size) {}
#endif /* __ZLSTREAMIMAGE_H__ */

@ -1 +0,0 @@
../src/util/ZLStringUtil.h

@ -0,0 +1,84 @@
/*
* Copyright (C) 2004-2012 Geometer Plus <contact@geometerplus.com>
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
* 02110-1301, USA.
*/
#ifndef __ZLSTRINGUTIL_H__
#define __ZLSTRINGUTIL_H__
#include <vector>
#include <string>
class ZLStringUtil {
private:
ZLStringUtil();
public:
static bool stringStartsWith(const std::string &str, const std::string &start);
static bool stringEndsWith(const std::string &str, const std::string &end);
static bool isDigit(char c);
static bool isLatinLetter(char c);
static void appendNumber(std::string &str, unsigned int n);
static void append(std::string &str, const std::vector<std::string> &buffer);
static void stripWhiteSpaces(std::string &str);
static const std::string SPACE;
static std::vector<std::string> split(const std::string &str, const std::string &delimiter);
static std::string printf(const std::string &format, const std::string &arg0);
static std::string printf(const std::string &format, unsigned int n);
static std::string doubleToString(double value);
static double stringToDouble(const std::string &value, double defaultValue);
static int stringToInteger(const std::string &str, int defaultValue = 0);
static std::string replaceAll(const std::string &str, const std::string& what, const std::string &to);
template <typename T, typename F>
static std::string join(T iterable, F functor, std::string separator);
template <typename T>
static std::string join(T iterable, std::string separator);
template <typename T>
struct self {
inline T operator()(const T &t) {
return t;
}
};
};
template <typename T, typename F>
std::string ZLStringUtil::join(T iterable, F functor, std::string separator) {
std::string result;
for (typename T::const_iterator it=iterable.begin(); it != iterable.end(); ++it) {
if (it != iterable.begin()) {
result += separator;
}
result += functor(*it);
}
return result;
}
template <typename T>
std::string ZLStringUtil::join(T iterable, std::string separator) {
return join(iterable, ZLStringUtil::self<typename T::value_type>(), separator);
}
#endif /* __ZLSTRINGUTIL_H__ */

@ -22,8 +22,8 @@
#include <shared_ptr.h>
#include "../ZLInputStream.h"
#include "../ZLDir.h"
#include "ZLInputStream.h"
#include "ZLDir.h"
class ZLFSArchiverTar;

@ -1 +0,0 @@
../src/time/ZLTime.h

@ -0,0 +1,46 @@
/*
* Copyright (C) 2004-2012 Geometer Plus <contact@geometerplus.com>
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
* 02110-1301, USA.
*/
#ifndef __ZLTIME_H__
#define __ZLTIME_H__
class ZLTime {
public:
ZLTime();
ZLTime(long seconds, long milliseconds);
~ZLTime();
long millisecondsTo(const ZLTime &time) const;
long millisecondsFrom(const ZLTime &time) const;
long inSeconds() const;
short hours() const;
short minutes() const;
short dayOfMonth() const; // from 1 to 31
short month() const; // from 1 to 12
short year() const;
private:
long mySeconds;
long myMilliseconds;
};
#endif /* __ZLTIME_H__ */

@ -1 +0,0 @@
../src/time/ZLTimeManager.h

@ -0,0 +1,94 @@
/*
* Copyright (C) 2004-2012 Geometer Plus <contact@geometerplus.com>
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
* 02110-1301, USA.
*/
#ifndef __ZLTIMEMANAGER_H__
#define __ZLTIMEMANAGER_H__
#include <map>
#include <shared_ptr.h>
#include <ZLRunnable.h>
class ZLTime;
class ZLTimeManager {
private:
class AutoRemovableTask;
protected:
static ZLTimeManager *ourInstance;
public:
static ZLTimeManager &Instance();
static void deleteInstance();
protected:
ZLTimeManager();
virtual ~ZLTimeManager();
public:
virtual void addTask(shared_ptr<ZLRunnable> task, int interval) = 0;
void addAutoRemovableTask(shared_ptr<ZLRunnable> task, int delay = 0);
void removeTask(shared_ptr<ZLRunnable> task);
protected:
virtual void removeTaskInternal(shared_ptr<ZLRunnable> task) = 0;
virtual ZLTime currentTime() const = 0;
virtual short hoursBySeconds(long seconds) const = 0;
virtual short minutesBySeconds(long seconds) const = 0;
virtual short yearBySeconds(long seconds) const = 0;
virtual short monthBySeconds(long seconds) const = 0;
virtual short dayOfMonthBySeconds(long seconds) const = 0;
protected:
typedef void (*DeleteFunc)(void*);
template <typename T> struct DeleteHelper {
static void func(T *object) { delete object; }
};
class DeleteTask : public ZLRunnable {
public:
DeleteTask(void *object, DeleteFunc func) : myObject(object), myFunc(func) {}
private:
void run() { myFunc(myObject); }
void *myObject;
DeleteFunc myFunc;
};
public:
template <typename T> static void deleteLater(shared_ptr<T> object, int delay = 0) {
deleteLater(new shared_ptr<T>(object), delay);
}
template <typename T> static void deleteLater(T *object, int delay = 0) {
DeleteFunc func = reinterpret_cast<DeleteFunc>(&DeleteHelper<T>::func);
ZLTimeManager::Instance().addAutoRemovableTask(new DeleteTask(object, func), delay);
}
private:
std::map<shared_ptr<ZLRunnable>,shared_ptr<ZLRunnable> > myAutoRemovableTasks;
friend class ZLTime;
};
#endif /* __ZLTIMEMANAGER_H__ */

@ -20,7 +20,7 @@
#ifndef __ZLTOGGLEBOOLEANOPTIONENTRY_H__
#define __ZLTOGGLEBOOLEANOPTIONENTRY_H__
#include <optionEntries/ZLSimpleOptionEntry.h>
#include <ZLSimpleOptionEntry.h>
class ZLToggleBooleanOptionEntry : public ZLSimpleBooleanOptionEntry {

@ -1 +0,0 @@
../src/tree/ZLTreeActionNode.h

@ -0,0 +1,36 @@
/*
* Copyright (C) 2009-2012 Geometer Plus <contact@geometerplus.com>
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
* 02110-1301, USA.
*/
#ifndef ZLTREEACTIONNODE_H
#define ZLTREEACTIONNODE_H
#include "ZLTreeTitledNode.h"
class ZLTreeActionNode : public ZLTreeTitledNode {
public:
static const ZLTypeId TYPE_ID;
const ZLTypeId &typeId() const;
public:
// Return true if it is final action (dialog should be closed)
virtual bool activate() = 0;
};
#endif // ZLTREEACTIONNODE_H

@ -1 +0,0 @@
../src/dialogs/ZLTreeDialog.h

@ -0,0 +1,54 @@
/*
* Copyright (C) 2004-2012 Geometer Plus <contact@geometerplus.com>
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
* 02110-1301, USA.
*/
#ifndef __ZLTREEDIALOG_H__
#define __ZLTREEDIALOG_H__
#include <ZLTreeListener.h>
#include <ZLResource.h>
#include <ZLTreeSearcher.h>
class ZLTreeDialog : public ZLTreeListener {
protected:
ZLTreeDialog(const ZLResource &resource);
public:
//TODO maybe run() should return an integer?
virtual void run(ZLTreeNode *rootNode) = 0;
public:
void setSearcher(shared_ptr<ZLTreeSearcher> searcher);
void onNodeBeginInsert(ZLTreeNode *parent, std::size_t index);
void onNodeEndInsert();
void onNodeBeginRemove(ZLTreeNode *parent, std::size_t index);
void onNodeEndRemove();
protected:
const ZLResource &resource() const;
protected:
shared_ptr<ZLTreeSearcher> mySearcher;
private:
const ZLResource &myResource;
};
#endif /* __ZLTREEDIALOG_H__ */

@ -1 +0,0 @@
../src/tree/ZLTreeListener.h

@ -0,0 +1,49 @@
/*
* Copyright (C) 2009-2012 Geometer Plus <contact@geometerplus.com>
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
* 02110-1301, USA.
*/
#ifndef __ZLTREELISTENER_H__
#define __ZLTREELISTENER_H__
#include "ZLTreeNode.h"
//ZLTreeListener is used to get ability to node to notificate Tree Dialog about any changes
class ZLTreeListener {
public:
virtual void onExpandRequest(ZLTreeNode *node) = 0;
virtual void onCloseRequest() = 0;
// Parent has new or remove child at index
virtual void onNodeBeginInsert(ZLTreeNode *parent, std::size_t index) = 0;
virtual void onNodeEndInsert() = 0;
virtual void onNodeBeginRemove(ZLTreeNode *parent, std::size_t index) = 0;
virtual void onNodeEndRemove() = 0;
// This method should be called at every node state change except of adding/removing of children
virtual void onNodeUpdated(ZLTreeNode *node) = 0;
virtual void onDownloadingStarted(ZLTreeNode *node) = 0;
virtual void onDownloadingStopped(ZLTreeNode *node) = 0;
virtual void onSearchStarted(ZLTreeNode *node) = 0;
virtual void onSearchStopped(ZLTreeNode *node) = 0;
virtual void onRefresh() = 0;
};
#endif /* __ZLTREELISTENER_H__ */

@ -1 +0,0 @@
../src/tree/ZLTreeNode.h

@ -0,0 +1,125 @@
/*
* Copyright (C) 2009-2012 Geometer Plus <contact@geometerplus.com>
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
* 02110-1301, USA.
*/
#ifndef __ZLTREENODE_H__
#define __ZLTREENODE_H__
#include <map>
#include <vector>
#include <shared_ptr.h>
#include <ZLTypeId.h>
#include <ZLRunnable.h>
#include <ZLPaintContext.h>
#include <ZLNetworkRequest.h>
// Nowadays I see hierarchy in this way:
//
// ZLTreeNode
// |
// +-ZLTreeTitledNode -- simple node, as shown below
// | |
// | +- ZLTreeActionNode -- node with some action on click, i.e. BookNode at local library
// |
// +-ZLTreePageNode -- usually the leaf of the tree, smth like page with ZLDialogContent
// and some actions, i.e. BookInfo page at network library
class ZLTreeListener;
//class ZLTreeAction : public ZLNetworkRequest { //using ZLRunnableWithKey instead
//public:
// static const ZLTypeId TYPE_ID;
// ZLTreeAction();
// ~ZLTreeAction();
// const ZLTypeId &typeId() const;
// virtual void run() = 0;
// virtual ZLResourceKey key() const = 0;
// virtual std::string text(const ZLResource &resource) const;
// virtual bool makesSense() const;
//};
typedef ZLRunnableWithKey ZLTreeAction;
class ZLTreeNode : public ZLObjectWithRTTI {
public:
typedef std::vector<ZLTreeNode*> List;
public:
static const ZLTypeId TYPE_ID;
const ZLTypeId &typeId() const;
protected:
ZLTreeNode(ZLTreeNode *parent = 0, std::size_t position = -1);
public:
virtual ~ZLTreeNode();
void clear();
public:
ZLTreeNode *parent() const;
ZLTreeNode *previous() const;
ZLTreeNode *next() const;
const List &children() const;
std::size_t childIndex() const;
// Children should be requested from network only if we need them
virtual void requestChildren(shared_ptr<ZLNetworkRequest::Listener> listener = 0);
virtual void requestMoreChildren(shared_ptr<ZLNetworkRequest::Listener> listener = 0);
virtual const ZLResource &resource() const;
void registerAction(shared_ptr<ZLTreeAction> action);
const std::vector<shared_ptr<ZLTreeAction> > &actions() const;
std::string actionText(const shared_ptr<ZLTreeAction> &action) const;
void close() const;
void insert(ZLTreeNode *node, std::size_t index);
void append(ZLTreeNode *node);
void remove(ZLTreeNode *node);
void remove(std::size_t index);
void updated();
void notifyDownloadStarted();
void notifyDownloadStopped();
void notifySearchStarted();
void notifySearchStopped();
protected:
std::size_t level() const;
virtual ZLTreeListener *listener() const;
private:
ZLTreeNode *myParent;
std::size_t myChildIndex;
List myChildren;
// Looks like we should also handle actions for menu on "Tap and hold"
std::vector<shared_ptr<ZLTreeAction> > myActions;
private:
ZLTreeNode(const ZLTreeNode&);
const ZLTreeNode &operator = (const ZLTreeNode&);
};
#endif /* __ZLTREENODE_H__ */

@ -1 +0,0 @@
../src/tree/ZLTreePageNode.h

@ -0,0 +1,53 @@
/*
* Copyright (C) 2009-2012 Geometer Plus <contact@geometerplus.com>
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
* 02110-1301, USA.
*/
#ifndef ZLTREEPAGENODE_H
#define ZLTREEPAGENODE_H
#include "ZLTreeTitledNode.h"
#include <ZLDialogContent.h>
class ZLTreePageInfo {
public:
virtual bool isPageInfoLoaded() = 0;
virtual void loadAll(shared_ptr<ZLNetworkRequest::Listener> listener) = 0;
virtual std::string title() const = 0;
virtual std::vector<std::string> authors() const = 0;
virtual std::vector<std::string> tags() const = 0;
virtual std::string summary() const = 0;
virtual shared_ptr<const ZLImage> image() const = 0;
virtual const std::vector<shared_ptr<ZLTreeAction> > &actions() const = 0;
virtual std::string actionText(const shared_ptr<ZLTreeAction> &action) const = 0;
virtual const std::vector<shared_ptr<ZLTreeAction> > relatedActions() const = 0;
};
class ZLTreePageNode : public ZLTreeTitledNode {
public:
ZLTreePageNode(ZLTreeNode *parent = 0, std::size_t position = -1);
static const ZLTypeId TYPE_ID;
const ZLTypeId &typeId() const;
virtual shared_ptr<ZLTreePageInfo> getPageInfo() = 0;
};
#endif // ZLTREEPAGENODE_H

@ -1 +0,0 @@
../src/tree/ZLTreeSearcher.h

@ -0,0 +1,30 @@
/*
* Copyright (C) 2004-2012 Geometer Plus <contact@geometerplus.com>
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
* 02110-1301, USA.
*/
#ifndef __ZLTREESEARCHER_H__
#define __ZLTREESEARCHER_H__
#include <string>
class ZLTreeSearcher {
public:
virtual void simpleSearch(const std::string &pattern) = 0;
};
#endif /* __ZLTREESEARCHER_H__ */

@ -1 +0,0 @@
../src/tree/ZLTreeTitledNode.h

@ -0,0 +1,49 @@
/*
* Copyright (C) 2009-2012 Geometer Plus <contact@geometerplus.com>
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
* 02110-1301, USA.
*/
#ifndef __ZLTREETITLEDNODE_H__
#define __ZLTREETITLEDNODE_H__
#include "ZLTreeNode.h"
#include <ZLImage.h>
class ZLTreeTitledNode : public ZLTreeNode {
public:
static const ZLTypeId TYPE_ID;
const ZLTypeId &typeId() const;
static const std::string ZLIMAGE_SCHEME;
static const std::string LOCALFILE_SCHEME;
static const std::string SCHEME_POSTFIX;
public:
ZLTreeTitledNode(ZLTreeNode *parent = 0, std::size_t position = -1);
virtual ~ZLTreeTitledNode();
virtual std::string title() const = 0;
virtual std::string subtitle() const;
// Url to image
//virtual std::string imageUrl() const;
// Or the image if there is no url
virtual shared_ptr<const ZLImage> image() const;
};
#endif /* __ZLTREETITLEDNODE_H__ */

@ -1 +0,0 @@
../src/typeId/ZLTypeId.h

@ -0,0 +1,79 @@
/*
* Copyright (C) 2010-2012 Geometer Plus <contact@geometerplus.com>
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
* 02110-1301, USA.
*/
#ifndef __ZLTYPEID_H__
#define __ZLTYPEID_H__
class ZLTypeId {
private:
ZLTypeId();
public:
explicit ZLTypeId(const ZLTypeId &base);
bool operator == (const ZLTypeId &type) const;
bool operator != (const ZLTypeId &type) const;
bool isSubtypeOf(const ZLTypeId &type) const;
private:
const ZLTypeId *myBase;
friend class ZLObjectWithRTTI;
};
class ZLObjectWithRTTI {
public:
static const ZLTypeId TYPE_ID;
public:
virtual ~ZLObjectWithRTTI();
bool isInstanceOf(const ZLTypeId &type, bool exact = false) const;
protected:
virtual const ZLTypeId &typeId() const = 0;
};
template <typename T>
T zlobject_cast(ZLObjectWithRTTI *object) {
if (!object || !object->isInstanceOf(reinterpret_cast<T>(0)->TYPE_ID))
return 0;
return static_cast<T>(object);
}
template <typename T>
T zlobject_cast(const ZLObjectWithRTTI *object) {
if (!object || !object->isInstanceOf(reinterpret_cast<T>(0)->TYPE_ID))
return 0;
return static_cast<T>(object);
}
inline bool ZLTypeId::operator == (const ZLTypeId &type) const {
return this == &type;
}
inline bool ZLTypeId::operator != (const ZLTypeId &type) const {
return this != &type;
}
inline ZLObjectWithRTTI::~ZLObjectWithRTTI() {
}
#endif /* __ZLTYPEID_H__ */

@ -1 +0,0 @@
../src/util/ZLUnicodeUtil.h

@ -0,0 +1,83 @@
/*
* Copyright (C) 2004-2012 Geometer Plus <contact@geometerplus.com>
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
* 02110-1301, USA.
*/
#ifndef __ZLUNICODEUTIL_H__
#define __ZLUNICODEUTIL_H__
#include <stdint.h>
#include <string>
#include <vector>
class ZLUnicodeUtil {
private:
ZLUnicodeUtil();
public:
typedef uint16_t Ucs2Char;
typedef std::vector<Ucs2Char> Ucs2String;
typedef uint32_t Ucs4Char;
typedef std::vector<Ucs4Char> Ucs4String;
enum Breakable {
NO_BREAKABLE,
BREAKABLE_BEFORE,
BREAKABLE_AFTER
};
static bool isUtf8String(const char *str, int len);
static bool isUtf8String(const std::string &str);
static void cleanUtf8String(std::string &str);
static int utf8Length(const char *str, int len);
static int utf8Length(const std::string &str);
static int length(const char *str, int utf8Length);
static int length(const std::string &str, int utf8Length);
static void utf8ToUcs4(Ucs4String &to, const char *from, int length, int toLength = -1);
static void utf8ToUcs4(Ucs4String &to, const std::string &from, int toLength = -1);
static void utf8ToUcs2(Ucs2String &to, const char *from, int length, int toLength = -1);
static void utf8ToUcs2(Ucs2String &to, const std::string &from, int toLength = -1);
static std::size_t firstChar(Ucs4Char &ch, const char *utf8String);
static std::size_t firstChar(Ucs4Char &ch, const std::string &utf8String);
static std::size_t lastChar(Ucs4Char &ch, const char *utf8String);
static std::size_t lastChar(Ucs4Char &ch, const std::string &utf8String);
static void ucs4ToUtf8(std::string &to, const Ucs4String &from, int toLength = -1);
static int ucs4ToUtf8(char *to, Ucs4Char ch);
static void ucs2ToUtf8(std::string &to, const Ucs2String &from, int toLength = -1);
static int ucs2ToUtf8(char *to, Ucs2Char ch);
static bool isLetter(Ucs4Char ch);
static bool isSpace(Ucs4Char ch);
static bool isNBSpace(Ucs4Char ch);
static Breakable isBreakable(Ucs4Char ch);
static Ucs4Char toLower(Ucs4Char ch);
static void toLower(Ucs4String &str);
static std::string toLower(const std::string &utf8String);
static Ucs4Char toUpper(Ucs4Char ch);
static void toUpper(Ucs4String &str);
static std::string toUpper(const std::string &utf8String);
static void utf8Trim(std::string &utf8String);
};
inline bool ZLUnicodeUtil::isNBSpace(Ucs4Char ch) {
return ch == 160;
}
#endif /* __ZLUNICODEUTIL_H__ */

@ -20,7 +20,7 @@
#ifndef __ZLUNIXFSDIR_H__
#define __ZLUNIXFSDIR_H__
#include "../../filesystem/ZLFSDir.h"
#include "ZLFSDir.h"
class ZLUnixFSDir : public ZLFSDir {

@ -20,7 +20,7 @@
#ifndef __ZLUNIXFSMANAGER_H__
#define __ZLUNIXFSMANAGER_H__
#include "../../filesystem/ZLFSManager.h"
#include "ZLFSManager.h"
class ZLUnixFSManager : public ZLFSManager {

@ -1 +0,0 @@
../src/util/ZLUserData.h

@ -0,0 +1,50 @@
/*
* Copyright (C) 2008-2012 Geometer Plus <contact@geometerplus.com>
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
* 02110-1301, USA.
*/
#ifndef __ZLUSERDATA_H__
#define __ZLUSERDATA_H__
#include <map>
#include <string>
#include <shared_ptr.h>
class ZLUserData {
public:
virtual ~ZLUserData();
};
class ZLUserDataHolder {
public:
ZLUserDataHolder();
ZLUserDataHolder(const ZLUserDataHolder &other);
virtual ~ZLUserDataHolder();
void addUserData(const std::string &key, shared_ptr<ZLUserData> data);
void removeUserData(const std::string &key);
shared_ptr<ZLUserData> getUserData(const std::string &key) const;
private:
ZLUserDataHolder &operator =(const ZLUserDataHolder &other);
std::map<std::string,shared_ptr<ZLUserData> > myDataMap;
};
#endif /* __ZLUSERDATA_H__ */

@ -1 +0,0 @@
../src/view/ZLView.h

@ -0,0 +1,110 @@
/*
* Copyright (C) 2004-2012 Geometer Plus <contact@geometerplus.com>
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
* 02110-1301, USA.
*/
#ifndef __ZLVIEW_H__
#define __ZLVIEW_H__
#include <string>
#include <shared_ptr.h>
#include <ZLColor.h>
#include <ZLTypeId.h>
class ZLViewWidget;
class ZLPaintContext;
class ZLView : public ZLObjectWithRTTI {
public:
enum Angle {
DEGREES0 = 0,
DEGREES90 = 90,
DEGREES180 = 180,
DEGREES270 = 270
};
enum Direction {
VERTICAL,
HORIZONTAL
};
protected:
static const ZLTypeId TYPE_ID;
public:
ZLView(ZLPaintContext &context);
virtual ~ZLView();
virtual const std::string &caption() const = 0;
virtual void paint() = 0;
ZLPaintContext &context() const;
/*
* returns true iff stylus/finger event was processed
*/
virtual bool onStylusPress(int x, int y);
virtual bool onStylusRelease(int x, int y);
virtual bool onStylusMove(int x, int y);
virtual bool onStylusMovePressed(int x, int y);
virtual bool onFingerTap(int x, int y);
protected:
const ZLTypeId &typeId() const;
virtual ZLColor backgroundColor() const = 0;
void setScrollbarEnabled(Direction direction, bool enabled);
void setScrollbarParameters(Direction direction, std::size_t full, std::size_t from, std::size_t to);
virtual void onScrollbarMoved(Direction direction, std::size_t full, std::size_t from, std::size_t to);
virtual void onScrollbarStep(Direction direction, int steps);
virtual void onScrollbarPageStep(Direction direction, int steps);
private:
struct ScrollBarInfo {
ScrollBarInfo();
bool Enabled;
bool StandardLocation;
std::size_t Full;
std::size_t From;
std::size_t To;
};
void updateScrollbarState();
void updateScrollbarPlacement();
void updateScrollbarParameters();
void updateScrollbarParameters(Direction direction, const ScrollBarInfo &info, bool invert);
private:
ZLViewWidget *myViewWidget;
ZLPaintContext &myContext;
ScrollBarInfo myVerticalScrollbarInfo;
ScrollBarInfo myHorizontalScrollbarInfo;
private:
ZLView(const ZLView&);
const ZLView &operator=(const ZLView&);
friend class ZLViewWidget;
};
inline ZLPaintContext &ZLView::context() const { return myContext; }
#endif /* __ZLVIEW_H__ */

@ -1 +0,0 @@
../src/constants/ZLXMLNamespace.h

@ -0,0 +1,44 @@
/*
* Copyright (C) 2008-2012 Geometer Plus <contact@geometerplus.com>
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
* 02110-1301, USA.
*/
#ifndef __ZLXMLNAMESPACE_H__
#define __ZLXMLNAMESPACE_H__
#include <string>
class ZLXMLNamespace {
private:
ZLXMLNamespace();
public:
static const std::string DublinCore;
static const std::string DublinCoreLegacy;
static const std::string DublinCoreTerms;
static const std::string XLink;
static const std::string OpenPackagingFormat;
static const std::string Atom;
static const std::string OpenSearch;
static const std::string CalibreMetadata;
static const std::string Opds;
static const std::string DaisyNCX;
static const std::string FBReaderCatalogMetadata;
};
#endif /* __ZLXMLNAMESPACE_H__ */

@ -1 +0,0 @@
../src/xml/ZLXMLReader.h

@ -0,0 +1,125 @@
/*
* Copyright (C) 2004-2012 Geometer Plus <contact@geometerplus.com>
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
* 02110-1301, USA.
*/
#ifndef __ZLXMLREADER_H__
#define __ZLXMLREADER_H__
#include <string>
#include <vector>
#include <map>
#include <shared_ptr.h>
class ZLFile;
class ZLInputStream;
class ZLAsynchronousInputStream;
class ZLXMLReaderInternal;
class ZLXMLReader {
public:
class AttributeNamePredicate {
public:
virtual ~AttributeNamePredicate();
virtual bool accepts(const ZLXMLReader &reader, const char *name) const = 0;
};
class FixedAttributeNamePredicate : public AttributeNamePredicate {
public:
FixedAttributeNamePredicate(const std::string &attributeName);
bool accepts(const ZLXMLReader &reader, const char *name) const;
private:
const std::string myAttributeName;
};
class NamespaceAttributeNamePredicate : public AttributeNamePredicate {
public:
NamespaceAttributeNamePredicate(const std::string &ns, const std::string &name);
bool accepts(const ZLXMLReader &reader, const char *name) const;
private:
const std::string myNamespaceName;
const std::string myAttributeName;
};
protected:
ZLXMLReader(const char *encoding = 0);
public:
virtual ~ZLXMLReader();
bool readDocument(const ZLFile &file);
bool readDocument(shared_ptr<ZLInputStream> stream);
bool readDocument(shared_ptr<ZLAsynchronousInputStream> stream);
const std::string &errorMessage() const;
typedef std::map<std::string,std::string> nsMap;
const nsMap &namespaces() const;
const char *attributeValue(const char **xmlattributes, const char *name);
const char *attributeValue(const char **xmlattributes, const AttributeNamePredicate &predicate);
static std::map<std::string,std::string> getAttributesMap(const char **xmlattributes);
private:
void initialize(const char *encoding = 0);
void shutdown();
bool readFromBuffer(const char *data, std::size_t len);
protected:
virtual void startElementHandler(const char *tag, const char **attributes);
virtual void endElementHandler(const char *tag);
virtual void characterDataHandler(const char *text, std::size_t len);
virtual bool processNamespaces() const;
virtual const std::vector<std::string> &externalDTDs() const;
virtual void collectExternalEntities(std::map<std::string,std::string> &entityMap);
bool testTag(const std::string &ns, const std::string &name, const std::string &tag) const;
bool isInterrupted() const;
std::size_t getCurrentPosition() const;
protected:
void interrupt();
void setErrorMessage(const std::string &message);
private:
bool myInterrupted;
ZLXMLReaderInternal *myInternalReader;
char *myParserBuffer;
std::vector<shared_ptr<nsMap> > myNamespaces;
std::string myErrorMessage;
friend class ZLXMLReaderInternal;
friend class ZLXMLReaderHandler;
};
inline bool ZLXMLReader::isInterrupted() const {
return myInterrupted;
}
inline void ZLXMLReader::interrupt() {
myInterrupted = true;
}
#endif /* __ZLXMLREADER_H__ */

@ -1 +0,0 @@
../src/xml/ZLXMLWriter.h

@ -0,0 +1,88 @@
/*
* Copyright (C) 2004-2012 Geometer Plus <contact@geometerplus.com>
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
* 02110-1301, USA.
*/
#ifndef __ZLXMLWRITER_H__
#define __ZLXMLWRITER_H__
#include <stack>
#include <vector>
#include <string>
#include <ZLOutputStream.h>
class ZLXMLWriter {
private:
struct Attribute {
std::string Name;
std::string Value;
Attribute(const std::string &name, const std::string &value);
~Attribute();
};
class Tag {
public:
Tag(const std::string &name, bool single);
~Tag();
void addAttribute(const std::string &name, const std::string &value);
void addData(const std::string &data);
bool isSingle() const;
bool isDataEmpty() const;
void writeStart(ZLOutputStream &stream) const;
void writeEnd(ZLOutputStream &stream) const;
private:
std::string myName;
std::string myData;
bool mySingle;
std::vector<Attribute> myAttributes;
};
protected:
ZLXMLWriter(ZLOutputStream &stream);
virtual ~ZLXMLWriter();
void addTag(const std::string &name, bool single);
void addAttribute(const std::string &name, const std::string &value);
void addData(const std::string &data);
void closeTag();
void closeAllTags();
private:
void flushTagStart();
private:
ZLOutputStream &myStream;
Tag *myCurrentTag;
std::stack<Tag*> myTags;
};
inline ZLXMLWriter::Attribute::Attribute(const std::string &name, const std::string &value) : Name(name), Value(value) {}
inline ZLXMLWriter::Attribute::~Attribute() {}
inline bool ZLXMLWriter::Tag::isSingle() const { return mySingle; }
inline bool ZLXMLWriter::Tag::isDataEmpty() const { return myData.empty(); }
inline ZLXMLWriter::Tag::~Tag() {}
inline ZLXMLWriter::~ZLXMLWriter() {}
#endif /* __ZLXMLWRITER_H__ */

@ -1 +0,0 @@
../src/filesystem/zip/ZLZDecompressor.h

@ -0,0 +1,45 @@
/*
* Copyright (C) 2004-2012 Geometer Plus <contact@geometerplus.com>
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
* 02110-1301, USA.
*/
#ifndef __ZLZDECOMPRESSOR_H__
#define __ZLZDECOMPRESSOR_H__
#include <zlib.h>
#include <string>
class ZLInputStream;
class ZLZDecompressor {
public:
ZLZDecompressor(std::size_t size);
~ZLZDecompressor();
std::size_t decompress(ZLInputStream &stream, char *buffer, std::size_t maxSize);
private:
z_stream *myZStream;
std::size_t myAvailableSize;
char *myInBuffer;
char *myOutBuffer;
std::string myBuffer;
};
#endif /* __ZLZDECOMPRESSOR_H__ */

@ -24,8 +24,8 @@
#include <shared_ptr.h>
#include "../ZLInputStream.h"
#include "../ZLDir.h"
#include "ZLInputStream.h"
#include "ZLDir.h"
class ZLZDecompressor;
class ZLFile;

@ -1 +0,0 @@
../src/library/ZLibrary.h

@ -0,0 +1,89 @@
/*
* Copyright (C) 2004-2012 Geometer Plus <contact@geometerplus.com>
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
* 02110-1301, USA.
*/
#ifndef __ZLIBRARY_H__
#define __ZLIBRARY_H__
#include <string>
class ZLApplication;
class ZLPaintContext;
class ZLibrary {
public:
static const std::string FileNameDelimiter;
static const std::string PathDelimiter;
static const std::string EndOfLine;
static std::string Language();
static std::string Country();
static const std::string BaseDirectory;
static const std::string &ZLibraryDirectory();
static const std::string &ImageDirectory();
static const std::string &ApplicationName();
static const std::string &ApplicationImageDirectory();
static const std::string &ApplicationDirectory();
static const std::string &DefaultFilesPathPrefix();
static const std::string &ApplicationWritableDirectory();
public:
static bool init(int &argc, char **&argv);
static void parseArguments(int &argc, char **&argv);
static ZLPaintContext *createContext();
static void run(ZLApplication *application);
static void shutdown();
private:
static void initLocale();
private:
static bool ourLocaleIsInitialized;
static std::string ourLanguage;
static std::string ourCountry;
static std::string ourZLibraryDirectory;
static std::string ourImageDirectory;
static std::string ourApplicationImageDirectory;
static std::string ourApplicationName;
static std::string ourApplicationDirectory;
static std::string ourApplicationWritableDirectory;
static std::string ourDefaultFilesPathPrefix;
private:
static std::string replaceRegExps(const std::string &pattern);
static void initApplication(const std::string &name);
private:
ZLibrary();
friend class ZLApplicationBase;
};
inline const std::string &ZLibrary::ZLibraryDirectory() { return ourZLibraryDirectory; }
inline const std::string &ZLibrary::ApplicationName() { return ourApplicationName; }
inline const std::string &ZLibrary::ImageDirectory() { return ourImageDirectory; }
inline const std::string &ZLibrary::ApplicationImageDirectory() { return ourApplicationImageDirectory; }
inline const std::string &ZLibrary::ApplicationDirectory() { return ourApplicationDirectory; }
inline const std::string &ZLibrary::ApplicationWritableDirectory() { return ourApplicationWritableDirectory; }
inline const std::string &ZLibrary::DefaultFilesPathPrefix() { return ourDefaultFilesPathPrefix; }
#endif /* __ZLIBRARY_H__ */

@ -1 +0,0 @@
../src/util/allocator.h

@ -0,0 +1,83 @@
/*
* Copyright (C) 2004-2012 Geometer Plus <contact@geometerplus.com>
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
* 02110-1301, USA.
*/
#ifndef __ALLOCATOR_H__
#define __ALLOCATOR_H__
#include <vector>
template<std::size_t ObjectSize, std::size_t PoolSize> class Allocator {
public:
Allocator();
~Allocator();
void *allocate();
void free(void *ptr);
private:
void addPool();
private:
std::vector<void*> myPools;
void *myFirstUnused;
void *myLastUnused;
};
template<std::size_t ObjectSize, std::size_t PoolSize>
inline Allocator<ObjectSize,PoolSize>::Allocator() {
addPool();
}
template<std::size_t ObjectSize, std::size_t PoolSize>
inline Allocator<ObjectSize,PoolSize>::~Allocator() {
for (std::vector<void*>::const_iterator it = myPools.begin(); it != myPools.end(); ++it) {
delete[] (char*)*it;
}
}
template<std::size_t ObjectSize, std::size_t PoolSize>
inline void Allocator<ObjectSize,PoolSize>::addPool() {
char *pool = new char[ObjectSize * PoolSize];
myFirstUnused = (void*)pool;
myLastUnused = (void*)(pool + ObjectSize * (PoolSize - 1));
for (std::size_t i = 0; i < PoolSize - 1; ++i) {
*(void**)(pool + ObjectSize * i) = pool + ObjectSize * (i + 1);
}
myPools.push_back(myFirstUnused);
}
template<std::size_t ObjectSize, std::size_t PoolSize>
void *Allocator<ObjectSize,PoolSize>::allocate() {
void *ptr = myFirstUnused;
if (myFirstUnused == myLastUnused) {
addPool();
} else {
myFirstUnused = *(void**)myFirstUnused;
}
return ptr;
}
template<std::size_t ObjectSize, std::size_t PoolSize>
void Allocator<ObjectSize,PoolSize>::free(void *ptr) {
*(void**)myLastUnused = ptr;
myLastUnused = ptr;
}
#endif /* __ALLOCATOR_H__ */

@ -1 +0,0 @@
../../src/optionEntries/ZLColorOptionBuilder.h

@ -1 +0,0 @@
../../src/optionEntries/ZLFontFamilyOptionEntry.h

@ -1 +0,0 @@
../../src/optionEntries/ZLLanguageOptionEntry.h

@ -1 +0,0 @@
../../src/optionEntries/ZLSimpleKeyOptionEntry.h

@ -1 +0,0 @@
../../src/optionEntries/ZLSimpleOptionEntry.h

@ -1 +0,0 @@
../../src/optionEntries/ZLStringEditOptionEntry.h

@ -1 +0,0 @@
../../src/optionEntries/ZLStringInfoEntry.h

@ -1 +0,0 @@
../../src/optionEntries/ZLToggleBooleanOptionEntry.h

@ -1 +0,0 @@
../src/util/shared_ptr.h

@ -0,0 +1,424 @@
/*
* Copyright (C) 2004-2012 Geometer Plus <contact@geometerplus.com>
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
* 02110-1301, USA.
*/
#ifndef __SHARED_PTR_H__
#define __SHARED_PTR_H__
template<class T> class shared_ptr_storage {
private:
unsigned int myCounter;
unsigned int myWeakCounter;
T* myPointer;
public:
shared_ptr_storage(T *pointer);
~shared_ptr_storage();
T* pointer() const;
T& content() const;
void addReference();
void removeReference();
void addWeakReference();
void removeWeakReference();
unsigned int counter() const;
};
template<class T> class weak_ptr;
template<class T> class shared_ptr {
friend class weak_ptr<T>;
private:
shared_ptr_storage<T> *myStorage;
shared_ptr_storage<T> *newStorage(T *t);
void attachStorage(shared_ptr_storage<T> *storage);
void detachStorage();
public:
shared_ptr();
shared_ptr(T *t);
shared_ptr(const shared_ptr<T> &t);
shared_ptr(const weak_ptr<T> &t);
~shared_ptr();
const shared_ptr<T> &operator = (T *t);
const shared_ptr<T> &operator = (const shared_ptr<T> &t);
const shared_ptr<T> &operator = (const weak_ptr<T> &t);
T* operator -> () const;
T& operator * () const;
bool isNull() const;
void reset();
bool operator == (const weak_ptr<T> &t) const;
bool operator != (const weak_ptr<T> &t) const;
bool operator < (const weak_ptr<T> &t) const;
bool operator > (const weak_ptr<T> &t) const;
bool operator <= (const weak_ptr<T> &t) const;
bool operator >= (const weak_ptr<T> &t) const;
bool operator == (const shared_ptr<T> &t) const;
bool operator != (const shared_ptr<T> &t) const;
bool operator < (const shared_ptr<T> &t) const;
bool operator > (const shared_ptr<T> &t) const;
bool operator <= (const shared_ptr<T> &t) const;
bool operator >= (const shared_ptr<T> &t) const;
};
template<class T> class weak_ptr {
friend class shared_ptr<T>;
private:
shared_ptr_storage<T> *myStorage;
void attachStorage(shared_ptr_storage<T> *storage);
void detachStorage();
public:
weak_ptr();
weak_ptr(const shared_ptr<T> &t);
weak_ptr(const weak_ptr<T> &t);
~weak_ptr();
const weak_ptr<T> &operator = (const weak_ptr<T> &t);
const weak_ptr<T> &operator = (const shared_ptr<T> &t);
T* operator -> () const;
T& operator * () const;
bool isNull() const;
void reset();
bool operator == (const weak_ptr<T> &t) const;
bool operator != (const weak_ptr<T> &t) const;
bool operator < (const weak_ptr<T> &t) const;
bool operator > (const weak_ptr<T> &t) const;
bool operator <= (const weak_ptr<T> &t) const;
bool operator >= (const weak_ptr<T> &t) const;
bool operator == (const shared_ptr<T> &t) const;
bool operator != (const shared_ptr<T> &t) const;
bool operator < (const shared_ptr<T> &t) const;
bool operator > (const shared_ptr<T> &t) const;
bool operator <= (const shared_ptr<T> &t) const;
bool operator >= (const shared_ptr<T> &t) const;
};
template<class T>
inline shared_ptr_storage<T>::shared_ptr_storage(T *pointer) {
myPointer = pointer;
myCounter = 0;
myWeakCounter = 0;
}
template<class T>
inline shared_ptr_storage<T>::~shared_ptr_storage() {
}
template<class T>
inline T* shared_ptr_storage<T>::pointer() const {
return myPointer;
}
template<class T>
inline T& shared_ptr_storage<T>::content() const {
return *myPointer;
}
template<class T>
inline void shared_ptr_storage<T>::addReference() {
++myCounter;
}
template<class T>
inline void shared_ptr_storage<T>::removeReference() {
--myCounter;
if (myCounter == 0) {
T* ptr = myPointer;
myPointer = 0;
delete ptr;
}
}
template<class T>
inline void shared_ptr_storage<T>::addWeakReference() {
++myWeakCounter;
}
template<class T>
inline void shared_ptr_storage<T>::removeWeakReference() {
--myWeakCounter;
}
template<class T>
inline unsigned int shared_ptr_storage<T>::counter() const {
return myCounter + myWeakCounter;
}
template<class T>
inline shared_ptr_storage<T> *shared_ptr<T>::newStorage(T *t) {
return (t == 0) ? 0 : new shared_ptr_storage<T>(t);
}
template<class T>
inline void shared_ptr<T>::attachStorage(shared_ptr_storage<T> *storage) {
myStorage = storage;
if (myStorage != 0) {
myStorage->addReference();
}
}
template<class T>
inline void shared_ptr<T>::detachStorage() {
if (myStorage != 0) {
if (myStorage->counter() == 1) {
myStorage->removeReference();
delete myStorage;
} else {
myStorage->removeReference();
}
}
}
template<class T>
inline shared_ptr<T>::shared_ptr() {
myStorage = 0;
}
template<class T>
inline shared_ptr<T>::shared_ptr(T *t) {
attachStorage(newStorage(t));
}
template<class T>
inline shared_ptr<T>::shared_ptr(const shared_ptr<T> &t) {
attachStorage(t.myStorage);
}
template<class T>
inline shared_ptr<T>::shared_ptr(const weak_ptr<T> &t) {
if (!t.isNull()) {
attachStorage(t.myStorage);
} else {
attachStorage(0);
}
}
template<class T>
inline shared_ptr<T>::~shared_ptr() {
detachStorage();
}
template<class T>
inline const shared_ptr<T> &shared_ptr<T>::operator = (T *t) {
detachStorage();
attachStorage(newStorage(t));
return *this;
}
template<class T>
inline const shared_ptr<T> &shared_ptr<T>::operator = (const shared_ptr<T> &t) {
if (&t != this) {
detachStorage();
attachStorage(t.myStorage);
}
return *this;
}
template<class T>
inline const shared_ptr<T> &shared_ptr<T>::operator = (const weak_ptr<T> &t) {
detachStorage();
if (!t.isNull()) {
attachStorage(t.myStorage);
} else {
attachStorage(0);
}
return *this;
}
template<class T>
inline T* shared_ptr<T>::operator -> () const {
return (myStorage == 0) ? 0 : myStorage->pointer();
}
template<class T>
inline T& shared_ptr<T>::operator * () const {
return myStorage->content();
}
template<class T>
inline bool shared_ptr<T>::isNull() const {
return myStorage == 0;
}
template<class T>
inline void shared_ptr<T>::reset() {
detachStorage();
attachStorage(0);
}
template<class T>
inline bool shared_ptr<T>::operator == (const weak_ptr<T> &t) const {
return operator -> () == t.operator -> ();
}
template<class T>
inline bool shared_ptr<T>::operator != (const weak_ptr<T> &t) const {
return !operator == (t);
}
template<class T>
inline bool shared_ptr<T>::operator < (const weak_ptr<T> &t) const {
return operator -> () < t.operator -> ();
}
template<class T>
inline bool shared_ptr<T>::operator > (const weak_ptr<T> &t) const {
return t.operator < (*this);
}
template<class T>
inline bool shared_ptr<T>::operator <= (const weak_ptr<T> &t) const {
return !t.operator < (*this);
}
template<class T>
inline bool shared_ptr<T>::operator >= (const weak_ptr<T> &t) const {
return !operator < (t);
}
template<class T>
inline bool shared_ptr<T>::operator == (const shared_ptr<T> &t) const {
return operator -> () == t.operator -> ();
}
template<class T>
inline bool shared_ptr<T>::operator != (const shared_ptr<T> &t) const {
return !operator == (t);
}
template<class T>
inline bool shared_ptr<T>::operator < (const shared_ptr<T> &t) const {
return operator -> () < t.operator -> ();
}
template<class T>
inline bool shared_ptr<T>::operator > (const shared_ptr<T> &t) const {
return t.operator < (*this);
}
template<class T>
inline bool shared_ptr<T>::operator <= (const shared_ptr<T> &t) const {
return !t.operator < (*this);
}
template<class T>
inline bool shared_ptr<T>::operator >= (const shared_ptr<T> &t) const {
return !operator < (t);
}
template<class T>
inline void weak_ptr<T>::attachStorage(shared_ptr_storage<T> *storage) {
myStorage = storage;
if (myStorage != 0) {
myStorage->addWeakReference();
}
}
template<class T>
inline void weak_ptr<T>::detachStorage() {
if (myStorage != 0) {
myStorage->removeWeakReference();
if (myStorage->counter() == 0) {
delete myStorage;
}
}
}
template<class T>
inline weak_ptr<T>::weak_ptr() {
myStorage = 0;
}
template<class T>
inline weak_ptr<T>::weak_ptr(const shared_ptr<T> &t) {
attachStorage(t.myStorage);
}
template<class T>
inline weak_ptr<T>::weak_ptr(const weak_ptr<T> &t) {
if (!t.isNull()) {
attachStorage(t.myStorage);
} else {
attachStorage(0);
}
}
template<class T>
inline weak_ptr<T>::~weak_ptr() {
detachStorage();
}
template<class T>
inline const weak_ptr<T> &weak_ptr<T>::operator = (const weak_ptr<T> &t) {
if (&t != this) {
detachStorage();
if (!t.isNull()) {
attachStorage(t.myStorage);
} else {
attachStorage(0);
}
}
return *this;
}
template<class T>
inline const weak_ptr<T> &weak_ptr<T>::operator = (const shared_ptr<T> &t) {
detachStorage();
attachStorage(t.myStorage);
return *this;
}
template<class T>
inline T* weak_ptr<T>::operator -> () const {
return (myStorage == 0) ? 0 : myStorage->pointer();
}
template<class T>
inline T& weak_ptr<T>::operator * () const {
return myStorage->content();
}
template<class T>
inline bool weak_ptr<T>::isNull() const {
return (myStorage == 0) || (myStorage->pointer() == 0);
}
template<class T>
inline void weak_ptr<T>::reset() {
detachStorage();
attachStorage(0);
}
template<class T>
inline bool weak_ptr<T>::operator == (const weak_ptr<T> &t) const {
return operator -> () == t.operator -> ();
}
template<class T>
inline bool weak_ptr<T>::operator != (const weak_ptr<T> &t) const {
return !operator == (t);
}
template<class T>
inline bool weak_ptr<T>::operator < (const weak_ptr<T> &t) const {
return operator -> () < t.operator -> ();
}
template<class T>
inline bool weak_ptr<T>::operator > (const weak_ptr<T> &t) const {
return t.operator < (*this);
}
template<class T>
inline bool weak_ptr<T>::operator <= (const weak_ptr<T> &t) const {
return !t.operator < (*this);
}
template<class T>
inline bool weak_ptr<T>::operator >= (const weak_ptr<T> &t) const {
return !operator < (t);
}
template<class T>
inline bool weak_ptr<T>::operator == (const shared_ptr<T> &t) const {
return operator -> () == t.operator -> ();
}
template<class T>
inline bool weak_ptr<T>::operator != (const shared_ptr<T> &t) const {
return !operator == (t);
}
template<class T>
inline bool weak_ptr<T>::operator < (const shared_ptr<T> &t) const {
return operator -> () < t.operator -> ();
}
template<class T>
inline bool weak_ptr<T>::operator > (const shared_ptr<T> &t) const {
return t.operator < (*this);
}
template<class T>
inline bool weak_ptr<T>::operator <= (const shared_ptr<T> &t) const {
return !t.operator < (*this);
}
template<class T>
inline bool weak_ptr<T>::operator >= (const shared_ptr<T> &t) const {
return !operator < (t);
}
#endif /* __SHARED_PTR_H__ */

@ -25,9 +25,9 @@
#include "ZLToolbar.h"
#include "ZLMenu.h"
#include "ZLPopupData.h"
#include "../view/ZLView.h"
#include "../view/ZLViewWidget.h"
#include "../view/ZLPaintContext.h"
#include "ZLView.h"
#include "ZLViewWidget.h"
#include "ZLPaintContext.h"
const std::string ZLApplication::MouseScrollDownKey = "<MouseScrollDown>";
const std::string ZLApplication::MouseScrollUpKey = "<MouseScrollUp>";

@ -1,201 +0,0 @@
/*
* Copyright (C) 2004-2012 Geometer Plus <contact@geometerplus.com>
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
* 02110-1301, USA.
*/
#ifndef __ZLAPPLICATION_H__
#define __ZLAPPLICATION_H__
#include <string>
#include <vector>
#include <map>
#include <set>
#include <shared_ptr.h>
#include <ZLOptions.h>
#include <ZLTime.h>
#include <ZLResource.h>
#include <ZLMessage.h>
#include <ZLView.h>
class ZLApplicationWindow;
class ZLViewWidget;
class ZLPaintContext;
class ZLKeyBindings;
class ZLToolbar;
class ZLPopupData;
class ZLMenubar;
class ZLFile;
class ZLApplicationBase {
protected:
ZLApplicationBase(const std::string &name);
~ZLApplicationBase();
};
class ZLApplication : public ZLApplicationBase {
public:
static ZLApplication &Instance();
static void deleteInstance();
private:
static ZLApplication *ourInstance;
public:
static const std::string MouseScrollUpKey;
static const std::string MouseScrollDownKey;
static const std::string NoAction;
public:
ZLIntegerOption RotationAngleOption;
ZLIntegerOption AngleStateOption;
ZLBooleanOption KeyboardControlOption;
ZLBooleanOption ConfigAutoSavingOption;
ZLIntegerRangeOption ConfigAutoSaveTimeoutOption;
ZLIntegerRangeOption KeyDelayOption;
public:
class Action {
public:
virtual ~Action();
virtual bool isVisible() const;
virtual bool isEnabled() const;
void checkAndRun();
virtual bool useKeyDelay() const;
protected:
virtual void run() = 0;
};
protected:
class RotationAction : public Action {
public:
bool isVisible() const;
void run();
};
friend class RotationAction;
public:
class FullscreenAction : public Action {
public:
void run();
};
friend class FullscreenAction;
class PresentWindowHandler : public ZLMessageHandler {
public:
void onMessageReceived(const std::vector<std::string> &arguments);
const std::string &lastCaller() const;
void resetLastCaller();
private:
std::string myLastCaller;
};
protected:
ZLApplication(const std::string &name);
void addAction(const std::string &actionId, shared_ptr<Action> action);
void registerPopupData(const std::string &actionId, shared_ptr<ZLPopupData> popupData);
void setView(shared_ptr<ZLView> view);
ZLView::Angle rotation() const;
void setFullscreen(bool fullscreen);
bool isFullscreen() const;
public:
virtual ~ZLApplication();
virtual void initWindow();
shared_ptr<ZLView> currentView() const;
shared_ptr<ZLPaintContext> context();
void grabAllKeys(bool grab);
void trackStylus(bool track);
void resetWindowCaption();
void setHyperlinkCursor(bool hyperlink);
shared_ptr<Action> action(const std::string &actionId) const;
bool isActionVisible(const std::string &actionId) const;
bool isActionEnabled(const std::string &actionId) const;
void doAction(const std::string &actionId);
virtual shared_ptr<ZLKeyBindings> keyBindings();
void doActionByKey(const std::string &key);
void quit();
virtual bool closeView();
virtual void openFile(const ZLFile &file);
virtual bool canDragFiles(const std::vector<std::string> &filePaths) const;
virtual void dragFiles(const std::vector<std::string> &filePaths);
virtual bool isViewFinal() const;
virtual void refreshWindow();
void presentWindow();
const std::string &lastCaller() const;
void resetLastCaller();
void setVisualParameter(const std::string &id, const std::string &value);
void setParameterValueList(const std::string &id, const std::vector<std::string> &values);
const std::string &visualParameter(const std::string &id);
public:
virtual bool showAuthDialog(const std::string &siteName, std::string &userName, std::string &password, const ZLResourceKey &errorKey) = 0;
virtual void saveUserName(const std::string &siteName, std::string &userName) = 0;
private:
void createToolbar(int index);
// TODO: change access rights to private
public:
const ZLToolbar &toolbar(int index) const;
private:
void createMenubar();
const ZLMenubar &menubar() const;
private:
shared_ptr<ZLViewWidget> myViewWidget;
shared_ptr<ZLView> myInitialView;
std::map<std::string,shared_ptr<Action> > myActionMap;
mutable shared_ptr<ZLToolbar> myToolbar;
mutable shared_ptr<ZLToolbar> myFullscreenToolbar;
mutable shared_ptr<ZLMenubar> myMenubar;
shared_ptr<ZLPaintContext> myContext;
shared_ptr <ZLApplicationWindow> myWindow;
ZLTime myLastKeyActionTime;
shared_ptr<ZLMessageHandler> myPresentWindowHandler;
friend class ZLApplicationWindow;
friend class ZLMenuVisitor;
};
#endif /* __ZLAPPLICATION_H__ */

@ -18,8 +18,8 @@
*/
#include "ZLApplication.h"
#include "../view/ZLView.h"
#include "../view/ZLViewWidget.h"
#include "ZLView.h"
#include "ZLViewWidget.h"
bool ZLApplication::RotationAction::isVisible() const {
ZLApplication &application = ZLApplication::Instance();

@ -19,7 +19,7 @@
#include "ZLApplicationWindow.h"
#include "../view/ZLViewWidget.h"
#include "ZLViewWidget.h"
ZLApplicationWindow *ZLApplicationWindow::ourInstance = 0;

@ -1,48 +0,0 @@
/*
* Copyright (C) 2004-2012 Geometer Plus <contact@geometerplus.com>
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
* 02110-1301, USA.
*/
#ifndef __ZLKEYBINDINGS_H__
#define __ZLKEYBINDINGS_H__
#include <map>
#include <string>
class ZLKeyBindings {
public:
ZLKeyBindings(const std::string &name);
~ZLKeyBindings();
void bindKey(const std::string &key, const std::string &code);
const std::string &getBinding(const std::string &key);
private:
void loadDefaultBindings();
void loadCustomBindings();
public:
void saveCustomBindings();
private:
const std::string myName;
std::map<std::string,std::string> myBindingsMap;
bool myIsChanged;
};
#endif /* __KEYBINDINGS_H__ */

@ -1,43 +0,0 @@
/*
* Copyright (C) 2008-2012 Geometer Plus <contact@geometerplus.com>
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
* 02110-1301, USA.
*/
#ifndef __ZLPOPUPDATA_H__
#define __ZLPOPUPDATA_H__
#include <string>
#include <ZLResource.h>
class ZLPopupData {
public:
virtual ~ZLPopupData();
virtual std::size_t id() const = 0;
virtual std::size_t count() const = 0;
virtual const std::string text(std::size_t index) = 0;
virtual void run(std::size_t index) = 0;
static const ZLResource &resource(const std::string &actionId);
};
inline ZLPopupData::~ZLPopupData() {
}
#endif /* __ZLPOPUPDATA_H__ */

@ -28,7 +28,7 @@
#include "ZLToolbar.h"
#include "ZLApplicationWindow.h"
#include <optionEntries/ZLStringInfoEntry.h>
#include <ZLStringInfoEntry.h>
class ZLToolbarCreator : public ZLXMLReader {

@ -1,104 +0,0 @@
/*
* Copyright (C) 2009-2012 Geometer Plus <contact@geometerplus.com>
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
* 02110-1301, USA.
*/
#ifndef __ZLBLOCKTREENODE_H__
#define __ZLBLOCKTREENODE_H__
#include <map>
#include <vector>
#include <shared_ptr.h>
#include <ZLTypeId.h>
#include <ZLRunnable.h>
#include <ZLPaintContext.h>
class ZLBlockTreeView;
class ZLBlockTreeNode : public ZLObjectWithRTTI {
public:
typedef std::vector<ZLBlockTreeNode*> List;
protected:
struct Rectangle {
const std::size_t Left;
const std::size_t Top;
const std::size_t Right;
const std::size_t Bottom;
Rectangle(std::size_t left, std::size_t vOffset, std::size_t right, std::size_t bottom);
bool contains(std::size_t x, std::size_t y) const;
bool operator < (const Rectangle &r) const;
};
public:
static const ZLTypeId TYPE_ID;
protected:
ZLBlockTreeNode(ZLBlockTreeView &view);
ZLBlockTreeNode(ZLBlockTreeNode *parent, std::size_t atPosition = -1);
public:
virtual ~ZLBlockTreeNode();
void clear();
public:
ZLBlockTreeNode *parent() const;
ZLBlockTreeNode *previous() const;
ZLBlockTreeNode *next() const;
const List &children() const;
void open(bool openNotClose);
bool isOpen() const;
protected:
std::size_t level() const;
ZLBlockTreeView &view();
public:
virtual void paint(ZLPaintContext &context, int vOffset) = 0;
virtual int height(ZLPaintContext &context) const = 0;
void onStylusPress(std::size_t x, std::size_t y);
bool isOverHyperlink(std::size_t x, std::size_t y);
protected:
void addHyperlink(std::size_t left, std::size_t top, std::size_t right, std::size_t bottom, shared_ptr<ZLRunnableWithKey> action);
void removeAllHyperlinks();
private:
ZLBlockTreeView &myView;
ZLBlockTreeNode *myParent;
std::size_t myChildIndex;
List myChildren;
bool myIsOpen;
typedef std::map<Rectangle,shared_ptr<ZLRunnableWithKey> > LinkMap;
LinkMap myHyperlinks;
private:
ZLBlockTreeNode(const ZLBlockTreeNode&);
const ZLBlockTreeNode &operator = (const ZLBlockTreeNode&);
};
#endif /* __ZLBLOCKTREENODE_H__ */

@ -1,97 +0,0 @@
/*
* Copyright (C) 2009-2012 Geometer Plus <contact@geometerplus.com>
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
* 02110-1301, USA.
*/
#ifndef __ZLBLOCKTREEVIEW_H__
#define __ZLBLOCKTREEVIEW_H__
#include <ZLView.h>
#include <ZLBlockTreeNode.h>
class ZLBlockTreeView : public ZLView {
public:
class RootNode : public ZLBlockTreeNode {
public:
static const ZLTypeId TYPE_ID;
public:
RootNode(ZLBlockTreeView &view);
private:
const ZLTypeId &typeId() const;
void paint(ZLPaintContext &context, int vOffset);
int height(ZLPaintContext &context) const;
};
public:
static const ZLTypeId TYPE_ID;
protected:
ZLBlockTreeView(ZLPaintContext &context);
const ZLTypeId &typeId() const;
RootNode &rootNode();
void clear();
public:
ZLBlockTreeNode *firstVisibleNode() const;
void setFirstVisibleNode(ZLBlockTreeNode *node);
enum VisibilityMode {
INVISIBLE,
VISIBLE,
VISIBLE_PARTIAL_AT_TOP,
VISIBLE_PARTIAL_AT_BOTTOM
};
VisibilityMode visibilityMode(ZLBlockTreeNode *node) const;
void ensureVisible(ZLBlockTreeNode *node);
enum ScrollingMode {
NONE,
PAGE,
ITEM,
};
void scroll(ScrollingMode mode, bool back);
protected:
void paint();
private:
bool onStylusPress(int x, int y);
bool onStylusMove(int x, int y);
void onScrollbarMoved(Direction direction, std::size_t full, std::size_t from, std::size_t to);
void onScrollbarStep(Direction direction, int steps);
void onScrollbarPageStep(Direction direction, int steps);
private:
ZLBlockTreeNode *findNode(int &y);
private:
RootNode myRootNode;
ZLBlockTreeNode *myFirstVisibleNode;
std::size_t myNodePartToSkip;
bool myCanScrollForward;
};
#endif /* __ZLBLOCKTREEVIEW_H__ */

@ -1,93 +0,0 @@
/*
* Copyright (C) 2010-2012 Geometer Plus <contact@geometerplus.com>
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
* 02110-1301, USA.
*/
#ifndef __ZLMIMETYPE_H__
#define __ZLMIMETYPE_H__
#include <string>
#include <shared_ptr.h>
#include <map>
class ZLMimeType {
private:
ZLMimeType(std::string& name, std::map<std::string,std::string>& parameters);
private:
static std::map<std::string,shared_ptr<ZLMimeType> > ourSimpleTypesMap;
public:
static shared_ptr<ZLMimeType> get(const char *text);
static shared_ptr<ZLMimeType> get(std::string text);
static bool isImage(shared_ptr<ZLMimeType> mimeType);
private:
const std::map<std::string,std::string> myParameters;
const std::string myName;
public:
const std::string& getName() const;
const std::string& getParameter(const std::string &key) const;
bool weakEquals(const ZLMimeType& t) const;
bool operator ==(const ZLMimeType& t) const;
bool operator !=(const ZLMimeType& t) const;
static const shared_ptr<ZLMimeType> APPLICATION_XML;
static const shared_ptr<ZLMimeType> APPLICATION_ZIP;
static const shared_ptr<ZLMimeType> APPLICATION_EPUB_ZIP;
static const shared_ptr<ZLMimeType> APPLICATION_FB2_ZIP;
static const shared_ptr<ZLMimeType> APPLICATION_MOBIPOCKET_EBOOK;
static const shared_ptr<ZLMimeType> APPLICATION_PDF;
static const shared_ptr<ZLMimeType> APPLICATION_CHM;
static const shared_ptr<ZLMimeType> APPLICATION_PALM_DB;
static const shared_ptr<ZLMimeType> APPLICATION_ATOM_XML;
static const shared_ptr<ZLMimeType> APPLICATION_LITRES_XML;
static const shared_ptr<ZLMimeType> APPLICATION_LITRES_XML_BOOKS;
static const shared_ptr<ZLMimeType> APPLICATION_LITRES_XML_AUTHORS;
static const shared_ptr<ZLMimeType> APPLICATION_LITRES_XML_GENRES;
static const shared_ptr<ZLMimeType> APPLICATION_OPENSEARCH_XML;
static const shared_ptr<ZLMimeType> APPLICATION_OR_XML;
static const shared_ptr<ZLMimeType> APPLICATION_GZIP;
static const shared_ptr<ZLMimeType> APPLICATION_BZIP2;
static const shared_ptr<ZLMimeType> APPLICATION_TAR;
static const shared_ptr<ZLMimeType> APPLICATION_TAR_GZIP;
static const shared_ptr<ZLMimeType> APPLICATION_TAR_BZIP2;
static const shared_ptr<ZLMimeType> APPLICATION_TAR_7Z;
static const shared_ptr<ZLMimeType> IMAGE_PNG;
static const shared_ptr<ZLMimeType> IMAGE_JPEG;
static const shared_ptr<ZLMimeType> IMAGE_SVG;
static const shared_ptr<ZLMimeType> IMAGE_PALM;
static const shared_ptr<ZLMimeType> IMAGE_AUTO;
static const shared_ptr<ZLMimeType> TEXT_HTML;
static const shared_ptr<ZLMimeType> TEXT_PLAIN;
static const shared_ptr<ZLMimeType> TEXT_XML;
static const shared_ptr<ZLMimeType> EMPTY;
};
#endif /* __ZLMIMETYPE_H__ */

@ -1,44 +0,0 @@
/*
* Copyright (C) 2008-2012 Geometer Plus <contact@geometerplus.com>
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
* 02110-1301, USA.
*/
#ifndef __ZLXMLNAMESPACE_H__
#define __ZLXMLNAMESPACE_H__
#include <string>
class ZLXMLNamespace {
private:
ZLXMLNamespace();
public:
static const std::string DublinCore;
static const std::string DublinCoreLegacy;
static const std::string DublinCoreTerms;
static const std::string XLink;
static const std::string OpenPackagingFormat;
static const std::string Atom;
static const std::string OpenSearch;
static const std::string CalibreMetadata;
static const std::string Opds;
static const std::string DaisyNCX;
static const std::string FBReaderCatalogMetadata;
};
#endif /* __ZLXMLNAMESPACE_H__ */

@ -1,51 +0,0 @@
/*
* Copyright (C) 2004-2012 Geometer Plus <contact@geometerplus.com>
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
* 02110-1301, USA.
*/
#ifndef __ZLDIALOG_H__
#define __ZLDIALOG_H__
#include <string>
#include <ZLDialogContent.h>
#include <ZLResource.h>
class ZLDialog {
protected:
ZLDialog();
public:
virtual ~ZLDialog();
virtual void addButton(const ZLResourceKey &key, bool accept) = 0;
void addOption(const std::string &name, const std::string &tooltip, ZLOptionEntry *option);
void addOption(const ZLResourceKey &key, ZLOptionEntry *option);
void addOption(const ZLResourceKey &key, ZLSimpleOption &option);
const ZLResource &resource(const ZLResourceKey &key) const;
// TODO: change return type to int (or std::string?)
virtual bool run() = 0;
void acceptValues();
protected:
ZLDialogContent *myTab;
};
#endif /* __ZLDIALOG_H__ */

@ -17,7 +17,7 @@
* 02110-1301, USA.
*/
#include <optionEntries/ZLSimpleOptionEntry.h>
#include <ZLSimpleOptionEntry.h>
#include "ZLOptionView.h"
#include "ZLDialogContent.h"

@ -1,65 +0,0 @@
/*
* Copyright (C) 2004-2012 Geometer Plus <contact@geometerplus.com>
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
* 02110-1301, USA.
*/
#ifndef __ZLDIALOGCONTENT_H__
#define __ZLDIALOGCONTENT_H__
#include <string>
#include <vector>
#include <ZLOptions.h>
#include <ZLResource.h>
class ZLOptionEntry;
class ZLOptionView;
class ZLDialogContent {
protected:
ZLDialogContent(const ZLResource &resource);
public:
virtual ~ZLDialogContent();
const std::string &key() const;
const std::string &displayName() const;
const std::string &value(const ZLResourceKey &key) const;
const ZLResource &resource(const ZLResourceKey &key) const;
virtual void addOption(const std::string &name, const std::string &tooltip, ZLOptionEntry *option) = 0;
void addOption(const ZLResourceKey &key, ZLOptionEntry *option);
void addOption(const ZLResourceKey &key, ZLSimpleOption &option);
virtual void addOptions(const std::string &name0, const std::string &tooltip0, ZLOptionEntry *option0,
const std::string &name1, const std::string &tooltip1, ZLOptionEntry *option1) = 0;
void addOptions(const ZLResourceKey &key0, ZLOptionEntry *option0,
const ZLResourceKey &key1, ZLOptionEntry *option1);
void addOptions(const ZLResourceKey &key0, ZLSimpleOption &option0,
const ZLResourceKey &key1, ZLSimpleOption &option1);
void accept();
protected:
void addView(ZLOptionView *view);
private:
const ZLResource &myResource;
std::vector<ZLOptionView*> myViews;
};
#endif /* __ZLDIALOGCONTENT_H__ */

@ -1,101 +0,0 @@
/*
* Copyright (C) 2004-2012 Geometer Plus <contact@geometerplus.com>
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
* 02110-1301, USA.
*/
#ifndef __ZLDIALOGMANAGER_H__
#define __ZLDIALOGMANAGER_H__
#include <string>
#include <shared_ptr.h>
#include <ZLRunnable.h>
#include <ZLResource.h>
#include <ZLOpenFileDialog.h>
#include <ZLTreeDialog.h>
class ZLDialog;
class ZLOptionsDialog;
class ZLTreeHandler;
class ZLApplication;
class ZLImageData;
class ZLProgressDialog;
class ZLDialogManager {
public:
static const ZLResourceKey OK_BUTTON;
static const ZLResourceKey CANCEL_BUTTON;
static const ZLResourceKey YES_BUTTON;
static const ZLResourceKey NO_BUTTON;
static const ZLResourceKey APPLY_BUTTON;
static const ZLResourceKey COLOR_KEY;
static const ZLResourceKey DIALOG_TITLE;
static const std::string &dialogTitle(const ZLResourceKey &key);
static const std::string &dialogMessage(const ZLResourceKey &key);
static const std::string &buttonName(const ZLResourceKey &key);
static const std::string &waitMessageText(const ZLResourceKey &key);
protected:
static const ZLResource &resource();
public:
static bool isInitialized();
static ZLDialogManager &Instance();
static void deleteInstance();
protected:
static ZLDialogManager *ourInstance;
protected:
ZLDialogManager();
virtual ~ZLDialogManager();
public:
virtual void createApplicationWindow(ZLApplication *application) const = 0;
virtual shared_ptr<ZLDialog> createDialog(const ZLResourceKey &key) const = 0;
virtual shared_ptr<ZLOptionsDialog> createOptionsDialog(const ZLResourceKey &key, shared_ptr<ZLRunnable> applyAction = 0, bool showApplyButton = false) const = 0;
virtual shared_ptr<ZLOpenFileDialog> createOpenFileDialog(const ZLResourceKey &key, const std::string &directoryPath, const std::string &filePath, const ZLOpenFileDialog::Filter &filter) const = 0;
virtual shared_ptr<ZLTreeDialog> createTreeDialog(const ZLResource &resource) const = 0;
void informationBox(const ZLResourceKey &key) const;
void informationBox(const ZLResourceKey &key, const std::string &message) const;
virtual void informationBox(const std::string &title, const std::string &message) const = 0;
void errorBox(const ZLResourceKey &key) const;
virtual void errorBox(const ZLResourceKey &key, const std::string &message) const = 0;
int questionBox(const ZLResourceKey &key, const ZLResourceKey &button0, const ZLResourceKey &button1, const ZLResourceKey &button2 = ZLResourceKey()) const;
virtual int questionBox(const ZLResourceKey &key, const std::string &message, const ZLResourceKey &button0, const ZLResourceKey &button1, const ZLResourceKey &button2 = ZLResourceKey()) const = 0;
virtual shared_ptr<ZLProgressDialog> createProgressDialog(const ZLResourceKey &key, bool network) const = 0;
void wait(const ZLResourceKey &key, ZLRunnable &runnable) const;
enum ClipboardType {
CLIPBOARD_MAIN,
CLIPBOARD_SELECTION
};
virtual bool isClipboardSupported(ClipboardType type) const = 0;
virtual void setClipboardText(const std::string &text, ClipboardType type) const = 0;
virtual void setClipboardImage(const ZLImageData &imageData, ClipboardType type) const = 0;
};
#endif /* __ZLDIALOGMANAGER_H__ */

@ -1,43 +0,0 @@
/*
* Copyright (C) 2010-2012 Geometer Plus <contact@geometerplus.com>
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
* 02110-1301, USA.
*/
#ifndef __ZLOPENFILEDIALOG_H__
#define __ZLOPENFILEDIALOG_H__
#include <string>
class ZLFile;
class ZLOpenFileDialog {
public:
class Filter {
public:
virtual ~Filter();
virtual bool accepts(const ZLFile &file) const = 0;
};
public:
virtual bool run() = 0;
virtual std::string filePath() const = 0;
virtual std::string directoryPath() const = 0;
};
#endif /* __ZLOPENFILEDIALOG_H__ */

@ -1,294 +0,0 @@
/*
* Copyright (C) 2004-2012 Geometer Plus <contact@geometerplus.com>
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
* 02110-1301, USA.
*/
#ifndef __ZLOPTIONENTRY_H__
#define __ZLOPTIONENTRY_H__
#include <vector>
#include <string>
#include <ZLOptions.h>
class ZLOptionView;
class ZLOptionEntry {
public:
enum ZLOptionKind {
CHOICE,
BOOLEAN,
BOOLEAN3,
STRING,
PASSWORD,
SPIN,
COMBO,
COLOR,
KEY,
ORDER,
MULTILINE,
STATIC,
};
public:
ZLOptionEntry();
virtual ~ZLOptionEntry();
virtual ZLOptionKind kind() const = 0;
void setView(ZLOptionView *view);
void resetView();
virtual void setVisible(bool visible);
bool isVisible() const;
virtual void setActive(bool active);
bool isActive() const;
private:
ZLOptionView *myView;
bool myIsVisible;
bool myIsActive;
};
class ZLChoiceOptionEntry : public ZLOptionEntry {
protected:
ZLChoiceOptionEntry();
public:
ZLOptionKind kind() const;
virtual const std::string &text(int index) const = 0;
virtual int choiceNumber() const = 0;
virtual int initialCheckedIndex() const = 0;
virtual void onAccept(int index) = 0;
};
class ZLTextOptionEntry : public ZLOptionEntry {
public:
virtual const std::string &initialValue() const = 0;
void onAccept(const char *value);
virtual void onAccept(const std::string &value) = 0;
virtual bool useOnValueEdited() const;
void onValueEdited(const char *value);
virtual void onValueEdited(const std::string &value);
};
class ZLStringOptionEntry : public ZLTextOptionEntry {
protected:
ZLStringOptionEntry();
public:
ZLOptionKind kind() const;
};
class ZLPasswordOptionEntry : public ZLTextOptionEntry {
protected:
ZLPasswordOptionEntry();
public:
ZLOptionKind kind() const;
};
class ZLMultilineOptionEntry : public ZLTextOptionEntry {
protected:
ZLMultilineOptionEntry();
public:
ZLOptionKind kind() const;
};
class ZLBooleanOptionEntry : public ZLOptionEntry {
protected:
ZLBooleanOptionEntry();
public:
ZLOptionKind kind() const;
virtual bool initialState() const = 0;
virtual void onStateChanged(bool state);
virtual void onAccept(bool state) = 0;
};
class ZLBoolean3OptionEntry : public ZLOptionEntry {
protected:
ZLBoolean3OptionEntry();
public:
ZLOptionKind kind() const;
virtual ZLBoolean3 initialState() const = 0;
virtual void onStateChanged(ZLBoolean3 state);
virtual void onAccept(ZLBoolean3 state) = 0;
};
class ZLSpinOptionEntry : public ZLOptionEntry {
protected:
ZLSpinOptionEntry();
public:
ZLOptionKind kind() const;
virtual int initialValue() const = 0;
virtual int minValue() const = 0;
virtual int maxValue() const = 0;
virtual int step() const = 0;
virtual void onAccept(int value) = 0;
};
class ZLComboOptionEntry : public ZLOptionEntry {
protected:
ZLComboOptionEntry(bool editable = false);
public:
ZLOptionKind kind() const;
virtual const std::string &initialValue() const = 0;
virtual const std::vector<std::string> &values() const = 0;
virtual void onValueSelected(int index);
void onStringValueSelected(const char *value);
void onStringValueSelected(const std::string &value);
virtual bool useOnValueEdited() const;
void onValueEdited(const char *value);
virtual void onValueEdited(const std::string &value);
void onAccept(const char *value);
virtual void onAccept(const std::string &value) = 0;
bool isEditable() const;
private:
const bool myEditable;
};
class ZLColorOptionEntry : public ZLOptionEntry {
protected:
ZLColorOptionEntry();
public:
ZLOptionKind kind() const;
virtual const ZLColor initialColor() const = 0;
virtual const ZLColor color() const = 0;
virtual void onAccept(ZLColor color) = 0;
virtual void onReset(ZLColor color);
};
class ZLKeyOptionEntry : public ZLOptionEntry {
public:
ZLKeyOptionEntry();
void addActionName(const std::string &actionName);
const std::vector<std::string> &actionNames() const;
virtual void onAccept() = 0;
virtual int actionIndex(const std::string &key) = 0;
virtual void onValueChanged(const std::string &key, int index) = 0;
virtual void onKeySelected(const std::string &key) = 0;
protected:
ZLOptionKind kind() const;
private:
std::vector<std::string> myActionNames;
};
class ZLOrderOptionEntry : public ZLOptionEntry {
public:
ZLOrderOptionEntry();
std::vector<std::string> &values();
protected:
ZLOptionKind kind() const;
private:
std::vector<std::string> myValues;
};
class ZLStaticTextOptionEntry : public ZLOptionEntry {
public:
virtual ZLOptionKind kind() const;
virtual const std::string &initialValue() const = 0;
};
inline ZLOptionEntry::ZLOptionEntry() : myView(0), myIsVisible(true), myIsActive(true) {}
inline ZLOptionEntry::~ZLOptionEntry() {}
inline void ZLOptionEntry::setView(ZLOptionView *view) { myView = view; }
inline bool ZLOptionEntry::isVisible() const { return myIsVisible; }
inline bool ZLOptionEntry::isActive() const { return myIsActive; }
inline ZLChoiceOptionEntry::ZLChoiceOptionEntry() {}
inline ZLOptionEntry::ZLOptionKind ZLChoiceOptionEntry::kind() const { return CHOICE; }
inline bool ZLTextOptionEntry::useOnValueEdited() const { return false; }
inline void ZLTextOptionEntry::onValueEdited(const std::string&) {}
inline ZLStringOptionEntry::ZLStringOptionEntry() {}
inline ZLOptionEntry::ZLOptionKind ZLStringOptionEntry::kind() const { return STRING; }
inline ZLPasswordOptionEntry::ZLPasswordOptionEntry() {}
inline ZLOptionEntry::ZLOptionKind ZLPasswordOptionEntry::kind() const { return PASSWORD; }
inline ZLMultilineOptionEntry::ZLMultilineOptionEntry() {}
inline ZLOptionEntry::ZLOptionKind ZLMultilineOptionEntry::kind() const { return MULTILINE; }
inline ZLBooleanOptionEntry::ZLBooleanOptionEntry() {}
inline ZLOptionEntry::ZLOptionKind ZLBooleanOptionEntry::kind() const { return BOOLEAN; }
inline void ZLBooleanOptionEntry::onStateChanged(bool) {}
inline ZLBoolean3OptionEntry::ZLBoolean3OptionEntry() {}
inline ZLOptionEntry::ZLOptionKind ZLBoolean3OptionEntry::kind() const { return BOOLEAN3; }
inline void ZLBoolean3OptionEntry::onStateChanged(ZLBoolean3) {}
inline ZLSpinOptionEntry::ZLSpinOptionEntry() {}
inline ZLOptionEntry::ZLOptionKind ZLSpinOptionEntry::kind() const { return SPIN; }
inline ZLComboOptionEntry::ZLComboOptionEntry(bool editable) : myEditable(editable) {}
inline ZLOptionEntry::ZLOptionKind ZLComboOptionEntry::kind() const { return COMBO; }
inline void ZLComboOptionEntry::onValueSelected(int) {}
inline bool ZLComboOptionEntry::useOnValueEdited() const { return false; }
inline void ZLComboOptionEntry::onValueEdited(const std::string&) {}
inline bool ZLComboOptionEntry::isEditable() const { return myEditable; }
inline ZLColorOptionEntry::ZLColorOptionEntry() {}
inline ZLOptionEntry::ZLOptionKind ZLColorOptionEntry::kind() const { return COLOR; }
inline void ZLColorOptionEntry::onReset(ZLColor) {}
inline ZLKeyOptionEntry::ZLKeyOptionEntry() {}
inline void ZLKeyOptionEntry::addActionName(const std::string &actionName) { myActionNames.push_back(actionName); }
inline const std::vector<std::string> &ZLKeyOptionEntry::actionNames() const { return myActionNames; }
inline ZLOptionEntry::ZLOptionKind ZLKeyOptionEntry::kind() const { return KEY; }
inline ZLOrderOptionEntry::ZLOrderOptionEntry() {}
inline ZLOptionEntry::ZLOptionKind ZLOrderOptionEntry::kind() const { return ORDER; }
inline std::vector<std::string> &ZLOrderOptionEntry::values() { return myValues; }
inline ZLOptionEntry::ZLOptionKind ZLStaticTextOptionEntry::kind() const { return STATIC; }
#endif /* __ZLOPTIONENTRY_H__ */

@ -1,75 +0,0 @@
/*
* Copyright (C) 2004-2012 Geometer Plus <contact@geometerplus.com>
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
* 02110-1301, USA.
*/
#ifndef __ZLOPTIONSDIALOG_H__
#define __ZLOPTIONSDIALOG_H__
#include <vector>
#include <string>
#include <shared_ptr.h>
#include <ZLRunnable.h>
#include <ZLDialogContent.h>
#include <ZLOptions.h>
#include <ZLResource.h>
class ZLOptionEntry;
class ZLDialogContentBuilder;
class ZLOptionsDialog {
protected:
static void addPlatformDependentBuilder(shared_ptr<ZLDialogContentBuilder> builder);
private:
static std::vector<shared_ptr<ZLDialogContentBuilder> > ourPlatformDependentBuilders;
protected:
ZLOptionsDialog(const ZLResource &resource, shared_ptr<ZLRunnable> applyAction);
public:
virtual ~ZLOptionsDialog();
virtual ZLDialogContent &createTab(const ZLResourceKey &key) = 0;
void createPlatformDependentTabs();
virtual bool run();
protected:
virtual const std::string &selectedTabKey() const = 0;
virtual void selectTab(const ZLResourceKey &key) = 0;
virtual bool runInternal() = 0;
void accept();
const std::string &caption() const;
const ZLResource &tabResource(const ZLResourceKey &key) const;
protected:
ZLStringOption TabOption;
private:
const ZLResource &myResource;
protected:
shared_ptr<ZLRunnable> myApplyAction;
std::vector<shared_ptr<ZLDialogContent> > myTabs;
};
#endif /* __ZLOPTIONSDIALOG_H__ */

@ -1,49 +0,0 @@
/*
* Copyright (C) 2009-2012 Geometer Plus <contact@geometerplus.com>
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
* 02110-1301, USA.
*/
#ifndef __ZLPROGRESSDIALOG_H__
#define __ZLPROGRESSDIALOG_H__
#include <ZLResource.h>
#include <ZLNetworkRequest.h>
#include <ZLRunnable.h>
class ZLProgressDialog {
private:
class ProgressListener;
protected:
ZLProgressDialog(const ZLResourceKey &key);
public:
virtual ~ZLProgressDialog();
shared_ptr<ZLNetworkRequest::Listener> listener();
virtual void run(ZLRunnable &runnable) = 0;
virtual void setMessage(const std::string &message) = 0;
const std::string &messageText() const;
std::string messageText(int percent) const;
private:
const std::string myMessage;
};
#endif /* __ZLPROGRESSDIALOG_H__ */

@ -1,54 +0,0 @@
/*
* Copyright (C) 2004-2012 Geometer Plus <contact@geometerplus.com>
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
* 02110-1301, USA.
*/
#ifndef __ZLTREEDIALOG_H__
#define __ZLTREEDIALOG_H__
#include <ZLTreeListener.h>
#include <ZLResource.h>
#include <ZLTreeSearcher.h>
class ZLTreeDialog : public ZLTreeListener {
protected:
ZLTreeDialog(const ZLResource &resource);
public:
//TODO maybe run() should return an integer?
virtual void run(ZLTreeNode *rootNode) = 0;
public:
void setSearcher(shared_ptr<ZLTreeSearcher> searcher);
void onNodeBeginInsert(ZLTreeNode *parent, std::size_t index);
void onNodeEndInsert();
void onNodeBeginRemove(ZLTreeNode *parent, std::size_t index);
void onNodeEndRemove();
protected:
const ZLResource &resource() const;
protected:
shared_ptr<ZLTreeSearcher> mySearcher;
private:
const ZLResource &myResource;
};
#endif /* __ZLTREEDIALOG_H__ */

@ -23,7 +23,7 @@
#include <ZLUnicodeUtil.h>
#include <ZLXMLReader.h>
#include "../options/ZLConfig.h"
#include "ZLConfig.h"
#include "ZLEncodingConverter.h"
#include "DummyEncodingConverter.h"
#include "Utf8EncodingConverter.h"

@ -1,130 +0,0 @@
/*
* Copyright (C) 2004-2012 Geometer Plus <contact@geometerplus.com>
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
* 02110-1301, USA.
*/
#ifndef __ZLENCODINGCONVERTER_H__
#define __ZLENCODINGCONVERTER_H__
#include <string>
#include <vector>
#include <map>
#include <shared_ptr.h>
class ZLEncodingConverter {
public:
static const std::string ASCII;
static const std::string UTF8;
static const std::string UTF16;
static const std::string UTF16BE;
protected:
ZLEncodingConverter();
public:
virtual ~ZLEncodingConverter();
virtual void convert(std::string &dst, const char *srcStart, const char *srcEnd) = 0;
void convert(std::string &dst, const std::string &src);
virtual void reset() = 0;
virtual bool fillTable(int *map) = 0;
private:
ZLEncodingConverter(const ZLEncodingConverter&);
ZLEncodingConverter &operator = (const ZLEncodingConverter&);
};
class ZLEncodingConverterInfo {
public:
ZLEncodingConverterInfo(const std::string &name, const std::string &region);
void addAlias(const std::string &alias);
const std::string &name() const;
const std::string &visibleName() const;
const std::vector<std::string> &aliases() const;
shared_ptr<ZLEncodingConverter> createConverter() const;
bool canCreateConverter() const;
private:
const std::string myName;
const std::string myVisibleName;
std::vector<std::string> myAliases;
private:
ZLEncodingConverterInfo(const ZLEncodingConverterInfo&);
ZLEncodingConverterInfo &operator = (const ZLEncodingConverterInfo&);
};
typedef shared_ptr<ZLEncodingConverterInfo> ZLEncodingConverterInfoPtr;
class ZLEncodingSet {
public:
ZLEncodingSet(const std::string &name);
void addInfo(ZLEncodingConverterInfoPtr info);
const std::string &name() const;
const std::vector<ZLEncodingConverterInfoPtr> &infos() const;
private:
const std::string myName;
std::vector<ZLEncodingConverterInfoPtr> myInfos;
private:
ZLEncodingSet(const ZLEncodingSet&);
ZLEncodingSet &operator = (const ZLEncodingSet&);
};
class ZLEncodingConverterProvider;
class ZLEncodingCollection {
public:
static ZLEncodingCollection &Instance();
static std::string encodingDescriptionPath();
private:
static ZLEncodingCollection *ourInstance;
public:
const std::vector<shared_ptr<ZLEncodingSet> > &sets();
ZLEncodingConverterInfoPtr info(const std::string &name);
ZLEncodingConverterInfoPtr info(int code);
shared_ptr<ZLEncodingConverter> defaultConverter();
void registerProvider(shared_ptr<ZLEncodingConverterProvider> provider);
private:
void addInfo(ZLEncodingConverterInfoPtr info);
const std::vector<shared_ptr<ZLEncodingConverterProvider> > &providers() const;
private:
std::vector<shared_ptr<ZLEncodingSet> > mySets;
std::map<std::string,ZLEncodingConverterInfoPtr> myInfosByName;
std::vector<shared_ptr<ZLEncodingConverterProvider> > myProviders;
private:
ZLEncodingCollection();
~ZLEncodingCollection();
void init();
friend class ZLEncodingConverterInfo;
friend class ZLEncodingCollectionReader;
};
#endif /* __ZLENCODINGCONVERTER_H__ */

@ -1,58 +0,0 @@
/*
* Copyright (C) 2004-2012 Geometer Plus <contact@geometerplus.com>
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
* 02110-1301, USA.
*/
#ifndef __ZLDIR_H__
#define __ZLDIR_H__
#include <string>
#include <vector>
#include <shared_ptr.h>
class ZLDir {
public:
static shared_ptr<ZLDir> root();
protected:
ZLDir(const std::string &path);
public:
virtual ~ZLDir();
const std::string &path() const;
std::string name() const;
std::string parentPath() const;
std::string itemPath(const std::string &name) const;
bool isRoot() const;
virtual void collectSubDirs(std::vector<std::string> &names, bool includeSymlinks) = 0;
virtual void collectFiles(std::vector<std::string> &names, bool includeSymlinks) = 0;
protected:
virtual std::string delimiter() const = 0;
private:
std::string myPath;
private:
ZLDir(const ZLDir&);
const ZLDir &operator = (const ZLDir&);
};
#endif /* __ZLDIR_H__ */

@ -22,10 +22,10 @@
#include "ZLFSPlugin.h"
#include "ZLFSPluginManager.h"
#include "zip/ZLFSCompressorGzip.h"
#include "bzip2/ZLFSCompressorBzip2.h"
#include "zip/ZLFSArchiverZip.h"
#include "tar/ZLFSArchiverTar.h"
#include "ZLFSCompressorGzip.h"
#include "ZLFSCompressorBzip2.h"
#include "ZLFSArchiverZip.h"
#include "ZLFSArchiverTar.h"
static const char ARCHIVERS_SEPARATOR = '.';

@ -1,129 +0,0 @@
/*
* Copyright (C) 2004-2012 Geometer Plus <contact@geometerplus.com>
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
* 02110-1301, USA.
*/
#ifndef __ZLFILE_H__
#define __ZLFILE_H__
#include <string>
#include <map>
#include <shared_ptr.h>
#include <ZLFileInfo.h>
#include <ZLMimeType.h>
class ZLDir;
class ZLInputStream;
class ZLOutputStream;
class ZLFSCompressor;
class ZLFSArchiver;
class ZLFSPluginManager;
class ZLFile {
friend class ZLFSPluginManager;
friend class ZLFSArchiver;
public:
static const ZLFile NO_FILE;
private:
static std::map<std::string,weak_ptr<ZLInputStream> > ourPlainStreamCache;
public:
static std::string fileNameToUtf8(const std::string &fileName);
static std::string replaceIllegalCharacters(const std::string &fileName, char replaceWith);
public:
static const std::string ZIP; // = "zip"
typedef std::string ArchiveType; //ArchiveType is a string like "tag.gz", that describes sequence of compressors/archivers need to be used
ArchiveType archiveType() const;
private:
void setArchiveType(const ArchiveType type);
void setCompressed(bool compressed);
void setArchived(bool archived);
private:
ZLFile();
public:
explicit ZLFile(const std::string &path, shared_ptr<ZLMimeType> mimeType = ZLMimeType::EMPTY);
~ZLFile();
bool exists() const;
std::size_t size() const;
void forceArchiveType(const std::string & type) const;
bool isCompressed() const;
bool isDirectory() const;
bool isArchive() const;
bool remove() const;
bool canRemove() const;
const std::string &path() const;
const std::string &name(bool hideExtension) const;
const std::string &extension() const;
shared_ptr<ZLMimeType> mimeType() const;
std::string physicalFilePath() const;
std::string resolvedPath() const;
shared_ptr<ZLInputStream> inputStream() const;
shared_ptr<ZLOutputStream> outputStream(bool writeThrough = false) const;
shared_ptr<ZLDir> directory(bool createUnexisting = false) const;
bool operator == (const ZLFile &other) const;
bool operator != (const ZLFile &other) const;
bool operator < (const ZLFile &other) const;
private:
void fillInfo() const;
shared_ptr<ZLInputStream> envelopeCompressedStream(shared_ptr<ZLInputStream> &base) const;
private:
std::string myPath;
std::string myNameWithExtension;
std::string myNameWithoutExtension;
std::string myExtension;
mutable shared_ptr<ZLMimeType> myMimeType;
mutable bool myMimeTypeIsUpToDate;
mutable ArchiveType myArchiveType;
bool myIsCompressed;
bool myIsArchive;
mutable ZLFileInfo myInfo;
mutable bool myInfoIsFilled;
};
inline ZLFile::~ZLFile() {}
inline bool ZLFile::isCompressed() const { return myIsCompressed; }
inline bool ZLFile::isArchive() const { return myIsArchive; }
inline ZLFile::ArchiveType ZLFile::archiveType() const { return myArchiveType; }
inline void ZLFile::setCompressed(bool compressed) { myIsCompressed = compressed; }
inline void ZLFile::setArchived(bool archived) { myIsArchive = archived; }
inline const std::string &ZLFile::path() const { return myPath; }
inline const std::string &ZLFile::name(bool hideExtension) const { return hideExtension ? myNameWithoutExtension : myNameWithExtension; }
inline const std::string &ZLFile::extension() const { return myExtension; }
inline bool ZLFile::operator == (const ZLFile &other) const { return myPath == other.myPath; }
inline bool ZLFile::operator != (const ZLFile &other) const { return myPath != other.myPath; }
inline bool ZLFile::operator < (const ZLFile &other) const { return myPath < other.myPath; }
#endif /* __ZLFILE_H__ */

@ -1,34 +0,0 @@
/*
* Copyright (C) 2004-2012 Geometer Plus <contact@geometerplus.com>
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
* 02110-1301, USA.
*/
#ifndef __ZLFILEINFO_H__
#define __ZLFILEINFO_H__
struct ZLFileInfo {
bool Exists;
bool IsDirectory;
std::size_t Size;
ZLFileInfo();
};
inline ZLFileInfo::ZLFileInfo() : Exists(false), IsDirectory(false), Size(0) {
}
#endif /* __ZLFILEINFO_H__ */

@ -1,71 +0,0 @@
/*
* Copyright (C) 2004-2012 Geometer Plus <contact@geometerplus.com>
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
* 02110-1301, USA.
*/
#ifndef __ZLINPUTSTREAM_H__
#define __ZLINPUTSTREAM_H__
#include <string>
#include <shared_ptr.h>
#include <ZLUserData.h>
class ZLInputStream : public ZLUserDataHolder {
protected:
ZLInputStream();
public:
virtual ~ZLInputStream();
virtual bool open() = 0;
virtual std::size_t read(char *buffer, std::size_t maxSize) = 0;
virtual void close() = 0;
virtual void seek(int offset, bool absoluteOffset) = 0;
virtual std::size_t offset() const = 0;
virtual std::size_t sizeOfOpened() = 0;
private:
// disable copying
ZLInputStream(const ZLInputStream&);
const ZLInputStream &operator = (const ZLInputStream&);
};
class ZLInputStreamDecorator : public ZLInputStream {
public:
ZLInputStreamDecorator(shared_ptr<ZLInputStream> decoratee);
private:
bool open();
std::size_t read(char *buffer, std::size_t maxSize);
void close();
void seek(int offset, bool absoluteOffset);
std::size_t offset() const;
std::size_t sizeOfOpened();
private:
shared_ptr<ZLInputStream> myBaseStream;
std::size_t myBaseOffset;
};
inline ZLInputStream::ZLInputStream() {}
inline ZLInputStream::~ZLInputStream() {}
#endif /* __ZLINPUTSTREAM_H__ */

@ -1,45 +0,0 @@
/*
* Copyright (C) 2004-2012 Geometer Plus <contact@geometerplus.com>
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
* 02110-1301, USA.
*/
#ifndef __ZLOUTPUTSTREAM_H__
#define __ZLOUTPUTSTREAM_H__
#include <string>
class ZLOutputStream {
protected:
ZLOutputStream();
public:
virtual ~ZLOutputStream();
virtual bool open() = 0;
virtual void write(const char *data, std::size_t len) = 0;
virtual void write(const std::string &str) = 0;
virtual void close() = 0;
private:
ZLOutputStream(const ZLOutputStream&);
const ZLOutputStream &operator = (const ZLOutputStream&);
};
inline ZLOutputStream::ZLOutputStream() {}
inline ZLOutputStream::~ZLOutputStream() {}
#endif /* __ZLOUTPUTSTREAM_H__ */

@ -23,7 +23,7 @@
#include "ZLFSCompressorBzip2.h"
#include "ZLBzip2InputStream.h"
#include "../ZLFSPluginManager.h"
#include "ZLFSPluginManager.h"
ZLFSCompressorBzip2::ZLFSCompressorBzip2() {
}

@ -21,7 +21,7 @@
#include <cctype>
#include "ZLTar.h"
#include "../ZLFile.h"
#include "ZLFile.h"
struct ZLTarHeader {
std::string Name;

@ -23,7 +23,7 @@
#include "ZLFSCompressorGzip.h"
#include "ZLZip.h"
#include "../ZLFSPluginManager.h"
#include "ZLFSPluginManager.h"
ZLFSCompressorGzip::ZLFSCompressorGzip() {
}

@ -21,7 +21,7 @@
#include <algorithm>
#include "../ZLInputStream.h"
#include "ZLInputStream.h"
#include "ZLZDecompressor.h"
const std::size_t IN_BUFFER_SIZE = 2048;

@ -1,45 +0,0 @@
/*
* Copyright (C) 2004-2012 Geometer Plus <contact@geometerplus.com>
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
* 02110-1301, USA.
*/
#ifndef __ZLZDECOMPRESSOR_H__
#define __ZLZDECOMPRESSOR_H__
#include <zlib.h>
#include <string>
class ZLInputStream;
class ZLZDecompressor {
public:
ZLZDecompressor(std::size_t size);
~ZLZDecompressor();
std::size_t decompress(ZLInputStream &stream, char *buffer, std::size_t maxSize);
private:
z_stream *myZStream;
std::size_t myAvailableSize;
char *myInBuffer;
char *myOutBuffer;
std::string myBuffer;
};
#endif /* __ZLZDECOMPRESSOR_H__ */

@ -19,7 +19,7 @@
#include "ZLZip.h"
#include "ZLZipHeader.h"
#include "../ZLFile.h"
#include "ZLFile.h"
void ZLZipDir::collectFiles(std::vector<std::string> &names, bool) {
shared_ptr<ZLInputStream> stream = ZLFile(path()).inputStream();

@ -21,7 +21,7 @@
#include "ZLZipHeader.h"
#include "ZLZDecompressor.h"
#include "../ZLInputStream.h"
#include "ZLInputStream.h"
const int ZLZipHeader::SignatureCentralDirectory = 0x02014B50;
const int ZLZipHeader::SignatureLocalFile = 0x04034B50;

@ -22,7 +22,7 @@
#include "ZLZip.h"
#include "ZLZipHeader.h"
#include "ZLZDecompressor.h"
#include "../ZLFSManager.h"
#include "ZLFSManager.h"
ZLZipInputStream::ZLZipInputStream(shared_ptr<ZLInputStream> &base, const std::string &baseName, const std::string &entryName) : myBaseStream(new ZLInputStreamDecorator(base)), myBaseName(baseName), myEntryName(entryName), myUncompressedSize(0) {
}

@ -1,47 +0,0 @@
/*
* Copyright (C) 2004-2012 Geometer Plus <contact@geometerplus.com>
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
* 02110-1301, USA.
*/
#ifndef __ZLBASE64ENCODEDIMAGE_H__
#define __ZLBASE64ENCODEDIMAGE_H__
#include <vector>
#include <ZLImage.h>
class ZLBase64EncodedImage : public ZLSingleImage {
public:
ZLBase64EncodedImage(shared_ptr<ZLMimeType> mimeType);
~ZLBase64EncodedImage();
void addData(const std::string &text, std::size_t offset, std::size_t len);
void addData(const std::vector<std::string> &text);
const shared_ptr<std::string> stringData() const;
private:
void decode() const;
private:
mutable std::string myEncodedData;
mutable shared_ptr<std::string> myData;
};
inline ZLBase64EncodedImage::ZLBase64EncodedImage(shared_ptr<ZLMimeType> mimeType) : ZLSingleImage(mimeType) {}
inline ZLBase64EncodedImage::~ZLBase64EncodedImage() {}
#endif /* __ZLBASE64ENCODEDIMAGE_H__ */

@ -1,61 +0,0 @@
/*
* Copyright (C) 2004-2012 Geometer Plus <contact@geometerplus.com>
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
* 02110-1301, USA.
*/
#ifndef __ZLFILEIMAGE_H__
#define __ZLFILEIMAGE_H__
#include <string>
#include <vector>
#include <ZLFile.h>
#include <ZLImage.h>
class ZLFileImage : public ZLSingleImage {
public:
struct Block {
unsigned int offset;
unsigned int size;
Block(unsigned int off, unsigned int s);
};
typedef std::vector<Block> Blocks;
public:
static const std::string ENCODING_NONE;
static const std::string ENCODING_HEX;
static const std::string ENCODING_BASE64;
public:
ZLFileImage(const ZLFile &file, std::size_t offset, std::size_t size = 0, const std::string &encoding = ZLFileImage::ENCODING_NONE);
ZLFileImage(const ZLFile &file, const Blocks &blocks, const std::string &encoding = ZLFileImage::ENCODING_NONE);
const shared_ptr<std::string> stringData() const;
protected:
//shared_ptr<ZLInputStream> inputStream() const;
private:
const ZLFile myFile;
const std::string myEncoding;
Blocks myBlocks;
};
inline ZLFileImage::Block::Block(unsigned int off, unsigned int s) : offset(off), size(s) {}
#endif /* __ZLFILEIMAGE_H__ */

@ -1,83 +0,0 @@
/*
* Copyright (C) 2004-2012 Geometer Plus <contact@geometerplus.com>
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
* 02110-1301, USA.
*/
#ifndef __ZLIMAGE_H__
#define __ZLIMAGE_H__
#include <string>
#include <shared_ptr.h>
#include <ZLMimeType.h>
class ZLNetworkRequest;
class ZLImage {
protected:
ZLImage();
public:
virtual ~ZLImage();
virtual bool isSingle() const = 0;
virtual shared_ptr<ZLNetworkRequest> synchronizationData() const;
virtual bool good() const = 0;
};
class ZLSingleImage : public ZLImage {
protected:
ZLSingleImage(shared_ptr<ZLMimeType> mimeType);
virtual ~ZLSingleImage();
public:
bool isSingle() const { return true; }
shared_ptr<ZLMimeType> mimeType() const;
bool good() const;
virtual const shared_ptr<std::string> stringData() const = 0;
private:
shared_ptr<ZLMimeType> myMimeType;
};
class ZLMultiImage : public ZLImage {
protected:
ZLMultiImage();
virtual ~ZLMultiImage();
public:
bool isSingle() const { return false; }
bool good() const;
virtual unsigned int rows() const = 0;
virtual unsigned int columns() const = 0;
virtual shared_ptr<const ZLImage> subImage(unsigned int row, unsigned int column) const = 0;
};
inline ZLImage::ZLImage() {}
inline ZLImage::~ZLImage() {}
inline ZLSingleImage::ZLSingleImage(shared_ptr<ZLMimeType> mimeType) : myMimeType(mimeType) {}
inline ZLSingleImage::~ZLSingleImage() {}
inline shared_ptr<ZLMimeType> ZLSingleImage::mimeType() const { return myMimeType; }
inline ZLMultiImage::ZLMultiImage() : ZLImage() {}
inline ZLMultiImage::~ZLMultiImage() {}
#endif /* __ZLIMAGE_H__ */

@ -1,83 +0,0 @@
/*
* Copyright (C) 2004-2012 Geometer Plus <contact@geometerplus.com>
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
* 02110-1301, USA.
*/
#ifndef __ZLIMAGEMANAGER_H__
#define __ZLIMAGEMANAGER_H__
#include <string>
#include <vector>
#include <shared_ptr.h>
class ZLImage;
class ZLMultiImage;
class ZLImageData {
protected:
ZLImageData() {}
public:
virtual ~ZLImageData() {}
virtual unsigned int width() const = 0;
virtual unsigned int height() const = 0;
virtual void init(unsigned int width, unsigned int height) = 0;
virtual void setPosition(unsigned int x, unsigned int y) = 0;
virtual void moveX(int delta) = 0;
virtual void moveY(int delta) = 0;
virtual void setPixel(unsigned char r, unsigned char g, unsigned char b) = 0;
void setGrayPixel(unsigned char c);
virtual void copyFrom(const ZLImageData &source, unsigned int targetX, unsigned int targetY) = 0;
};
class ZLImageManager {
public:
static const ZLImageManager &Instance();
static void deleteInstance();
protected:
static ZLImageManager *ourInstance;
public:
shared_ptr<ZLImageData> imageData(const ZLImage &image) const;
public:
virtual shared_ptr<const ZLImage> makeBatchImage(const std::vector<shared_ptr<const ZLImage> > &images, shared_ptr<const ZLImage> defaultImage) const = 0;
protected:
ZLImageManager() {}
virtual ~ZLImageManager() {}
virtual shared_ptr<ZLImageData> createData() const = 0;
virtual bool convertImageDirect(const std::string &stringData, ZLImageData &imageData) const = 0;
private:
bool convertMultiImage(const ZLMultiImage &multiImage, ZLImageData &imageData) const;
bool convertFromPalmImageFormat(const std::string &imageString, ZLImageData &imageData) const;
};
inline void ZLImageData::setGrayPixel(unsigned char c) { setPixel(c, c, c); }
inline const ZLImageManager &ZLImageManager::Instance() { return *ourInstance; }
#endif /* __IMAGEMANAGER_H__ */

@ -1,43 +0,0 @@
/*
* Copyright (C) 2009-2012 Geometer Plus <contact@geometerplus.com>
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
* 02110-1301, USA.
*/
#ifndef __ZLNETWORKIMAGE_H__
#define __ZLNETWORKIMAGE_H__
#include <ZLImage.h>
class ZLFileImage;
class ZLNetworkImage : public ZLSingleImage {
public:
ZLNetworkImage(shared_ptr<ZLMimeType> mimeType, const std::string &url);
const shared_ptr<std::string> stringData() const;
private:
shared_ptr<ZLNetworkRequest> synchronizationData() const;
private:
const std::string myURL;
std::string myFileName;
mutable bool myIsSynchronized;
mutable shared_ptr<ZLFileImage> myCachedImage;
};
#endif /* __ZLNETWORKIMAGE_H__ */

@ -1,44 +0,0 @@
/*
* Copyright (C) 2004-2012 Geometer Plus <contact@geometerplus.com>
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
* 02110-1301, USA.
*/
#ifndef __ZLSTREAMIMAGE_H__
#define __ZLSTREAMIMAGE_H__
#include <string>
#include <ZLImage.h>
#include <ZLInputStream.h>
class ZLStreamImage : public ZLSingleImage {
public:
ZLStreamImage(shared_ptr<ZLMimeType> mimeType, std::size_t offset, std::size_t size = 0);
const shared_ptr<std::string> stringData() const;
private:
virtual shared_ptr<ZLInputStream> inputStream() const = 0;
private:
std::size_t myOffset;
mutable std::size_t mySize;
};
inline ZLStreamImage::ZLStreamImage(shared_ptr<ZLMimeType> mimeType, std::size_t offset, std::size_t size) : ZLSingleImage(mimeType), myOffset(offset), mySize(size) {}
#endif /* __ZLSTREAMIMAGE_H__ */

@ -1,51 +0,0 @@
/*
* Copyright (C) 2007-2012 Geometer Plus <contact@geometerplus.com>
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
* 02110-1301, USA.
*/
#ifndef __ZLLANGUAGEDETECTOR_H__
#define __ZLLANGUAGEDETECTOR_H__
#include <vector>
#include <string>
//#include <shared_ptr.h>
class ZLStatisticsBasedMatcher;
class ZLLanguageDetector {
public:
struct LanguageInfo {
LanguageInfo(const std::string &language, const std::string &encoding);
const std::string Language;
const std::string Encoding;
};
public:
ZLLanguageDetector();
~ZLLanguageDetector();
shared_ptr<LanguageInfo> findInfo(const char *buffer, std::size_t length, int matchingCriterion = 0);
shared_ptr<LanguageInfo> findInfoForEncoding(const std::string &encoding, const char *buffer, std::size_t length, int matchingCriterion = 0);
private:
typedef std::vector<shared_ptr<ZLStatisticsBasedMatcher> > SBVector;
SBVector myMatchers;
};
#endif /* __ZLLANGUAGEDETECTOR_H__ */

@ -1,41 +0,0 @@
/*
* Copyright (C) 2007-2012 Geometer Plus <contact@geometerplus.com>
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
* 02110-1301, USA.
*/
#ifndef __ZLLANGUAGELIST_H__
#define __ZLLANGUAGELIST_H__
#include <vector>
#include <ZLDir.h>
class ZLLanguageList {
public:
static std::string patternsDirectoryPath();
static const std::vector<std::string> &languageCodes();
static std::string languageName(const std::string &code);
private:
static std::vector<std::string> ourLanguageCodes;
private:
ZLLanguageList();
};
#endif /* __ZLLANGUAGELIST_H__ */

@ -25,9 +25,9 @@
#include <ZLLogger.h>
#include "ZLibrary.h"
#include "../filesystem/ZLFSManager.h"
#include "../options/ZLConfig.h"
#include "../network/ZLNetworkManager.h"
#include "ZLFSManager.h"
#include "ZLConfig.h"
#include "ZLNetworkManager.h"
#include "config.h"

@ -1,89 +0,0 @@
/*
* Copyright (C) 2004-2012 Geometer Plus <contact@geometerplus.com>
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
* 02110-1301, USA.
*/
#ifndef __ZLIBRARY_H__
#define __ZLIBRARY_H__
#include <string>
class ZLApplication;
class ZLPaintContext;
class ZLibrary {
public:
static const std::string FileNameDelimiter;
static const std::string PathDelimiter;
static const std::string EndOfLine;
static std::string Language();
static std::string Country();
static const std::string BaseDirectory;
static const std::string &ZLibraryDirectory();
static const std::string &ImageDirectory();
static const std::string &ApplicationName();
static const std::string &ApplicationImageDirectory();
static const std::string &ApplicationDirectory();
static const std::string &DefaultFilesPathPrefix();
static const std::string &ApplicationWritableDirectory();
public:
static bool init(int &argc, char **&argv);
static void parseArguments(int &argc, char **&argv);
static ZLPaintContext *createContext();
static void run(ZLApplication *application);
static void shutdown();
private:
static void initLocale();
private:
static bool ourLocaleIsInitialized;
static std::string ourLanguage;
static std::string ourCountry;
static std::string ourZLibraryDirectory;
static std::string ourImageDirectory;
static std::string ourApplicationImageDirectory;
static std::string ourApplicationName;
static std::string ourApplicationDirectory;
static std::string ourApplicationWritableDirectory;
static std::string ourDefaultFilesPathPrefix;
private:
static std::string replaceRegExps(const std::string &pattern);
static void initApplication(const std::string &name);
private:
ZLibrary();
friend class ZLApplicationBase;
};
inline const std::string &ZLibrary::ZLibraryDirectory() { return ourZLibraryDirectory; }
inline const std::string &ZLibrary::ApplicationName() { return ourApplicationName; }
inline const std::string &ZLibrary::ImageDirectory() { return ourImageDirectory; }
inline const std::string &ZLibrary::ApplicationImageDirectory() { return ourApplicationImageDirectory; }
inline const std::string &ZLibrary::ApplicationDirectory() { return ourApplicationDirectory; }
inline const std::string &ZLibrary::ApplicationWritableDirectory() { return ourApplicationWritableDirectory; }
inline const std::string &ZLibrary::DefaultFilesPathPrefix() { return ourDefaultFilesPathPrefix; }
#endif /* __ZLIBRARY_H__ */

@ -1,48 +0,0 @@
/*
* Copyright (C) 2009-2012 Geometer Plus <contact@geometerplus.com>
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
* 02110-1301, USA.
*/
#ifndef __ZLLOGGER_H__
#define __ZLLOGGER_H__
#include <string>
#include <set>
class ZLLogger {
public:
static const std::string DEFAULT_CLASS;
static ZLLogger &Instance();
private:
static ZLLogger *ourInstance;
private:
ZLLogger();
public:
void registerClass(const std::string &className);
void print(const std::string &className, const std::string &message) const;
void println(const std::string &className, const std::string &message) const;
private:
std::set<std::string> myRegisteredClasses;
};
#endif /* __ZLLOGGER_H__ */

@ -1,92 +0,0 @@
/*
* Copyright (C) 2004-2012 Geometer Plus <contact@geometerplus.com>
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
* 02110-1301, USA.
*/
#ifndef __ZLMESSAGE_H__
#define __ZLMESSAGE_H__
#include <vector>
#include <map>
#include <string>
#include <shared_ptr.h>
class ZLMessageOutputChannel;
class ZLMessageSender;
class ZLMessageHandler;
class ZLCommunicationManager {
public:
static ZLCommunicationManager &Instance();
static void deleteInstance();
protected:
static ZLCommunicationManager *ourInstance;
public:
typedef std::map<std::string,std::string> Data;
protected:
ZLCommunicationManager();
virtual ~ZLCommunicationManager();
void init();
void onMessageReceived(const std::string &command, const std::vector<std::string> &arguments);
public:
virtual shared_ptr<ZLMessageOutputChannel> createMessageOutputChannel(const std::string &protocol, const std::string &testFile) = 0;
virtual void addInputMessageDescription(const std::string &command, const std::string &protocol, const Data &data) = 0;
void registerHandler(const std::string &command, shared_ptr<ZLMessageHandler> receiver);
private:
shared_ptr<ZLMessageHandler> handler(const std::string &command);
private:
std::map<std::string,weak_ptr<ZLMessageHandler> > myRegisteredHandlers;
bool myInitialized;
private:
ZLCommunicationManager(const ZLCommunicationManager&);
const ZLCommunicationManager &operator = (const ZLCommunicationManager&);
};
class ZLMessageOutputChannel {
public:
virtual ~ZLMessageOutputChannel();
virtual shared_ptr<ZLMessageSender> createSender(const ZLCommunicationManager::Data &data) = 0;
};
class ZLMessageSender {
public:
virtual ~ZLMessageSender();
virtual void sendStringMessage(const std::string &message) = 0;
};
class ZLMessageHandler {
public:
virtual ~ZLMessageHandler();
virtual void onMessageReceived(const std::vector<std::string> &arguments) = 0;
};
#endif /* __ZLMESSAGE_H__ */

@ -1,72 +0,0 @@
/*
* Copyright (C) 2009-2012 Geometer Plus <contact@geometerplus.com>
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
* 02110-1301, USA.
*/
#ifndef __ZLASYNCHRONOUSINPUTSTREAM_H__
#define __ZLASYNCHRONOUSINPUTSTREAM_H__
#include <string>
class ZLAsynchronousInputStream {
public:
class Handler {
public:
virtual ~Handler();
virtual void initialize(const char *encoding) = 0;
virtual void shutdown() = 0;
virtual bool handleBuffer(const char *data, std::size_t len) = 0;
};
public:
ZLAsynchronousInputStream(const char *encoding = 0);
virtual ~ZLAsynchronousInputStream();
void setEof();
void setBuffer(const char *data, std::size_t len);
bool eof() const;
bool initialized() const;
bool processInput(Handler &handler);
protected:
virtual bool processInputInternal(Handler &handler) = 0;
protected:
const char *myData;
std::size_t myDataLen;
private:
std::string myEncoding;
bool myInitialized;
bool myEof;
private:
// disable copying
ZLAsynchronousInputStream(const ZLAsynchronousInputStream &);
const ZLAsynchronousInputStream &operator = (const ZLAsynchronousInputStream &);
};
inline void ZLAsynchronousInputStream::setEof() { myEof = true; myData = 0; myDataLen = 0; }
inline void ZLAsynchronousInputStream::setBuffer(const char *data, std::size_t len) { myData = data; myDataLen = len; }
inline bool ZLAsynchronousInputStream::eof() const { return myEof; }
inline bool ZLAsynchronousInputStream::initialized() const { return myInitialized; }
#endif /* __ZLASYNCHRONOUSINPUTSTREAM_H__ */

@ -31,10 +31,10 @@
#include "ZLNetworkRequest.h"
#include "ZLNetworkUtil.h"
#include "requests/ZLNetworkDownloadRequest.h"
#include "requests/ZLNetworkNoActionRequest.h"
#include "requests/ZLNetworkReadToStringRequest.h"
#include "requests/ZLNetworkXMLParserRequest.h"
#include "ZLNetworkDownloadRequest.h"
#include "ZLNetworkNoActionRequest.h"
#include "ZLNetworkReadToStringRequest.h"
#include "ZLNetworkXMLParserRequest.h"
ZLNetworkManager *ZLNetworkManager::ourInstance = 0;

@ -1,103 +0,0 @@
/*
* Copyright (C) 2008-2012 Geometer Plus <contact@geometerplus.com>
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
* 02110-1301, USA.
*/
#ifndef __ZLNETWORKMANAGER_H__
#define __ZLNETWORKMANAGER_H__
#include <string>
#include <shared_ptr.h>
#include <ZLOptions.h>
#include <ZLNetworkRequest.h>
#include <ZLRunnable.h>
class ZLNetworkData;
class ZLOutputStream;
class ZLXMLReader;
class ZLNetworkManager {
public:
static void deleteInstance();
static ZLNetworkManager &Instance();
static std::string CacheDirectory();
static std::string CookiesPath();
protected:
static ZLNetworkManager *ourInstance;
public:
ZLIntegerRangeOption &ConnectTimeoutOption() const;
ZLIntegerRangeOption &TimeoutOption() const;
ZLBooleanOption &UseProxyOption() const;
ZLStringOption &ProxyHostOption() const;
ZLStringOption &ProxyPortOption() const;
protected:
ZLNetworkManager();
virtual ~ZLNetworkManager();
public:
virtual std::string perform(const ZLNetworkRequest::Vector &requests) const = 0;
virtual std::string performAsync(const ZLNetworkRequest::Vector &requests) const = 0;
std::string perform(shared_ptr<ZLNetworkRequest> request) const;
std::string performAsync(shared_ptr<ZLNetworkRequest> request) const;
public:
virtual bool connect() const;
virtual void release() const;
virtual bool providesProxyInfo() const;
protected:
virtual bool useProxy() const;
virtual std::string proxyHost() const;
virtual std::string proxyPort() const;
public:
// returns error message
std::string downloadFile(const std::string &url, const std::string &fileName, shared_ptr<ZLNetworkRequest::Listener> listener = 0) const;
public:
shared_ptr<ZLNetworkRequest> createDownloadRequest(const std::string &url, const std::string &fileName) const;
shared_ptr<ZLNetworkRequest> createDownloadRequest(const std::string &url, shared_ptr<ZLOutputStream> stream) const;
shared_ptr<ZLNetworkRequest> createNoActionRequest(const std::string &url) const;
shared_ptr<ZLNetworkRequest> createReadToStringRequest(const std::string &url, std::string &buffer) const;
shared_ptr<ZLNetworkRequest> createXMLParserRequest(const std::string &url, shared_ptr<ZLXMLReader> reader, shared_ptr<ZLRunnable> runnable = 0) const;
public:
void setUserAgent(const std::string &userAgent);
const std::string &userAgent() const;
private:
mutable shared_ptr<ZLIntegerRangeOption> myConnectTimeoutOption;
mutable shared_ptr<ZLIntegerRangeOption> myTimeoutOption;
mutable shared_ptr<ZLBooleanOption> myUseProxyOption;
mutable shared_ptr<ZLStringOption> myProxyHostOption;
mutable shared_ptr<ZLStringOption> myProxyPortOption;
std::string myUserAgent;
};
inline void ZLNetworkManager::setUserAgent(const std::string &userAgent) { myUserAgent = userAgent; }
inline const std::string &ZLNetworkManager::userAgent() const { return myUserAgent; }
#endif /* __ZLNETWORKMANAGER_H__ */

@ -1,120 +0,0 @@
/*
* Copyright (C) 2010-2012 Geometer Plus <contact@geometerplus.com>
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
* 02110-1301, USA.
*/
#ifndef __ZLNETWORKREQUEST_H__
#define __ZLNETWORKREQUEST_H__
#include <string>
#include <vector>
#include <shared_ptr.h>
class ZLNetworkRequest {
public:
typedef std::vector<shared_ptr<ZLNetworkRequest> > Vector;
public:
class Listener {
protected:
Listener();
public:
virtual ~Listener();
virtual void finished(const std::string &error = std::string()) = 0;
virtual void showPercent(int ready, int full);
virtual void setUIStatus(bool enabled);
friend class ZLNetworkRequest;
};
protected:
ZLNetworkRequest(const std::string &url);
public:
virtual bool handleHeader(void *ptr, std::size_t size);
virtual bool handleContent(void *ptr, std::size_t size) = 0;
virtual bool doBefore() = 0;
// When error is empty return false MUST make request fail; when error is not empty return value MUST be ignored
virtual bool doAfter(const std::string &error) = 0;
protected:
void setErrorMessage(const std::string &message);
public:
const std::string &errorMessage() const;
const std::string &url() const;
public: // HTTP parameters
void setupAuthentication(const std::string &userName, const std::string &password);
const std::string &userName() const;
const std::string &password() const;
void setRedirectionSupported(bool supported);
bool isRedirectionSupported() const;
const std::vector<std::pair<std::string, std::string> > &postParameters() const;
void setPostParameters(const std::vector<std::pair<std::string, std::string> > &parameters);
public: //listeners methods
bool hasListener() const;
void setListener(shared_ptr<Listener> listener);
void setPercent(int ready, int full);
void setUIStatus(bool enabled);
protected:
void finished(const std::string &error);
shared_ptr<Listener> listener() const;
private:
const std::string myURL;
std::string myErrorMessage;
std::string myUserName;
std::string myPassword;
bool myRedirectionSupported;
std::vector<std::pair<std::string, std::string> > myPostParameters;
shared_ptr<Listener> myListener;
private: // disable copying
ZLNetworkRequest(const ZLNetworkRequest &);
const ZLNetworkRequest &operator = (const ZLNetworkRequest &);
};
inline void ZLNetworkRequest::setupAuthentication(const std::string &userName, const std::string &password) {
myUserName = userName;
myPassword = password;
}
inline const std::string &ZLNetworkRequest::userName() const { return myUserName; }
inline const std::string &ZLNetworkRequest::password() const { return myPassword; }
inline void ZLNetworkRequest::setRedirectionSupported(bool supported) { myRedirectionSupported = supported; }
inline bool ZLNetworkRequest::isRedirectionSupported() const { return myRedirectionSupported; }
inline const std::vector<std::pair<std::string, std::string> > &ZLNetworkRequest::postParameters() const { return myPostParameters; }
inline shared_ptr<ZLNetworkRequest::Listener> ZLNetworkRequest::listener() const { return myListener; }
#endif /* __ZLNETWORKREQUEST_H__ */

@ -1,42 +0,0 @@
/*
* Copyright (C) 2008-2012 Geometer Plus <contact@geometerplus.com>
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
* 02110-1301, USA.
*/
#ifndef __ZLNETWORKUTIL_H__
#define __ZLNETWORKUTIL_H__
#include <string>
class ZLNetworkUtil {
public:
static std::string htmlEncode(const std::string &stringToEncode);
static std::string hostFromUrl(const std::string &url);
static std::string url(const std::string &baseUrl, const std::string &relativePath);
static std::string &appendParameter(std::string &url, const std::string &name, const std::string &value);
static bool hasParameter(const std::string &url, const std::string &name);
private:
static bool isNonRelativeUrl(const std::string &url);
private:
ZLNetworkUtil();
};
#endif /* __ZLNETWORKUTIL_H__ */

@ -1,40 +0,0 @@
/*
* Copyright (C) 2009-2012 Geometer Plus <contact@geometerplus.com>
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
* 02110-1301, USA.
*/
#ifndef __ZLPLAINASYNCHRONOUSINPUTSTREAM_H__
#define __ZLPLAINASYNCHRONOUSINPUTSTREAM_H__
#include <ZLAsynchronousInputStream.h>
class ZLPlainAsynchronousInputStream : public ZLAsynchronousInputStream {
public:
ZLPlainAsynchronousInputStream(const char *encoding = 0);
private:
bool processInputInternal(Handler &handler);
private:
// disable copying
ZLPlainAsynchronousInputStream(const ZLPlainAsynchronousInputStream &);
const ZLPlainAsynchronousInputStream &operator = (const ZLPlainAsynchronousInputStream &);
};
#endif /* __ZLPLAINASYNCHRONOUSINPUTSTREAM_H__ */

@ -24,8 +24,8 @@
#include "ZLNetworkXMLParserRequest.h"
#include "../ZLPlainAsynchronousInputStream.h"
#include "../ZLGzipAsynchronousInputStream.h"
#include "ZLPlainAsynchronousInputStream.h"
#include "ZLGzipAsynchronousInputStream.h"
static const std::string CONTENT_ENCODING = "content-encoding:";

@ -1,217 +0,0 @@
/*
* Copyright (C) 2004-2012 Geometer Plus <contact@geometerplus.com>
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
* 02110-1301, USA.
*/
#ifndef __ZLOPTIONS_H__
#define __ZLOPTIONS_H__
#include <vector>
#include <string>
#include <ZLColor.h>
#include <ZLBoolean3.h>
class ZLCategoryKey {
public:
static const ZLCategoryKey EMPTY;
static const ZLCategoryKey LOOK_AND_FEEL;
static const ZLCategoryKey CONFIG;
static const ZLCategoryKey STATE;
static const ZLCategoryKey SYSTEM;
static const ZLCategoryKey NETWORK;
protected:
explicit ZLCategoryKey(const std::string &name);
public:
bool operator == (const ZLCategoryKey &key) const;
bool operator != (const ZLCategoryKey &key) const;
const std::string Name;
};
class ZLConfig;
class ZLOption {
private:
static ZLConfig *ourConfig;
public:
static void createInstance();
static void deleteInstance();
protected:
const std::string &getConfigValue(const std::string &defaultValue) const;
const std::string &getConfigValue() const;
const std::string &getDefaultConfigValue(const std::string &defaultValue) const;
const std::string &getDefaultConfigValue() const;
void setConfigValue(const std::string &value) const;
void unsetConfigValue() const;
public:
static const std::string PLATFORM_GROUP;
static const std::string FULL_KEYBOARD_CONTROL;
static const std::string KEYBOARD_PRESENTED;
static const std::string MOUSE_PRESENTED;
static const std::string TOUCHSCREEN_PRESENTED;
static const std::string FINGER_TAP_DETECTABLE;
public:
static void clearGroup(const std::string &group);
static void listOptionNames(const std::string &group, std::vector<std::string> &names);
static void listOptionGroups(std::vector<std::string> &groups);
static bool isAutoSavingSupported();
static void startAutoSave(int seconds);
protected:
ZLOption(const ZLCategoryKey &category, const std::string &group, const std::string &optionName);
public:
virtual ~ZLOption();
private:
const ZLCategoryKey &myCategory;
std::string myGroupName;
std::string myOptionName;
protected:
mutable bool myIsSynchronized;
private:
ZLOption(const ZLOption&);
const ZLOption &operator = (const ZLOption&);
};
class ZLSimpleOption : public ZLOption {
public:
enum Type {
TYPE_BOOLEAN,
TYPE_BOOLEAN3,
//TYPE_COLOR,
TYPE_STRING,
};
protected:
ZLSimpleOption(const ZLCategoryKey &category, const std::string &group, const std::string &optionName);
public:
virtual Type type() const = 0;
};
class ZLBooleanOption : public ZLSimpleOption {
public:
ZLBooleanOption(const ZLCategoryKey &category, const std::string &group, const std::string &optionName, bool defaultValue);
Type type() const;
bool value() const;
void setValue(bool value);
private:
mutable bool myValue;
const bool myDefaultValue;
};
class ZLBoolean3Option : public ZLSimpleOption {
public:
ZLBoolean3Option(const ZLCategoryKey &category, const std::string &group, const std::string &optionName, ZLBoolean3 defaultValue);
Type type() const;
ZLBoolean3 value() const;
void setValue(ZLBoolean3 value);
private:
mutable ZLBoolean3 myValue;
const ZLBoolean3 myDefaultValue;
};
class ZLIntegerOption : public ZLOption {
public:
ZLIntegerOption(const ZLCategoryKey &category, const std::string &group, const std::string &optionName, long defaultValue);
long value() const;
void setValue(long value);
private:
mutable long myValue;
const long myDefaultValue;
};
class ZLIntegerRangeOption : public ZLOption {
public:
ZLIntegerRangeOption(const ZLCategoryKey &category, const std::string &group, const std::string &optionName, long minValue, long maxValue, long defaultValue);
long value() const;
void setValue(long value);
long minValue() const;
long maxValue() const;
private:
mutable long myValue;
const long myMinValue;
const long myMaxValue;
const long myDefaultValue;
};
class ZLColorOption : public ZLOption {
public:
ZLColorOption(const ZLCategoryKey &category, const std::string &group, const std::string &optionName, ZLColor defaultValue);
ZLColor value() const;
void setValue(ZLColor value);
private:
mutable long myIntValue;
const long myDefaultIntValue;
};
class ZLDoubleOption : public ZLOption {
public:
ZLDoubleOption(const ZLCategoryKey &category, const std::string &group, const std::string &optionName, double defaultValue);
double value() const;
void setValue(double value);
private:
mutable double myValue;
const double myDefaultValue;
};
class ZLStringOption : public ZLSimpleOption {
public:
ZLStringOption(const ZLCategoryKey &category, const std::string &group, const std::string &optionName, const std::string &defaultValue);
Type type() const;
const std::string &value() const;
void setValue(const std::string &value);
private:
mutable std::string myValue;
const std::string myDefaultValue;
};
#endif /* __ZLOPTIONS_H__ */

@ -1,59 +0,0 @@
/*
* Copyright (C) 2004-2012 Geometer Plus <contact@geometerplus.com>
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
* 02110-1301, USA.
*/
#ifndef __ZLRESOURCE_H__
#define __ZLRESOURCE_H__
#include <string>
struct ZLResourceKey {
ZLResourceKey() {}
explicit ZLResourceKey(const std::string &name) : Name(name) {}
std::string Name;
};
class ZLResource {
public:
static const ZLResource &resource(const std::string &key);
static const ZLResource &resource(const ZLResourceKey &key);
protected:
ZLResource(const std::string &name);
public:
virtual ~ZLResource();
const std::string &name() const;
virtual bool hasValue() const = 0;
virtual const std::string &value() const = 0;
virtual const std::string &value(int number) const = 0;
virtual const ZLResource &operator [] (const std::string &key) const = 0;
const ZLResource &operator [] (const ZLResourceKey &key) const;
private:
const std::string myName;
private:
// disable copying
ZLResource(const ZLResource&);
const ZLResource &operator = (const ZLResource&);
};
#endif /* __ZLRESOURCE_H__ */

@ -1,77 +0,0 @@
/*
* Copyright (C) 2004-2012 Geometer Plus <contact@geometerplus.com>
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
* 02110-1301, USA.
*/
#ifndef __ZLEXECUTIONUTIL_H__
#define __ZLEXECUTIONUTIL_H__
#include <ZLUserData.h>
#include "ZLNetworkRequest.h"
class ZLExecutionUtil {
//code for convenient async syntax createListener method:
public:
template <typename T, typename Method>
static shared_ptr<ZLNetworkRequest::Listener> createListener(shared_ptr<ZLUserDataHolder> data, T object, Method method) {
data->addUserData(ourHandlerId, new HandlerHelper<T, Method>(object, method));
return createListener(data);
}
template <typename T, typename Method>
static shared_ptr<ZLNetworkRequest::Listener> createListener(T object, Method method) {
return createListener(new ZLUserDataHolder, object, method);
}
template <typename T, typename Method>
static shared_ptr<ZLNetworkRequest::Listener> createListener(ZLUserData *scope, T object, Method method) {
shared_ptr<ZLUserDataHolder> scopeData = new ZLUserDataHolder;
scopeData->addUserData("scope", scope);
return createListener(scopeData, object, method);
}
private:
typedef void (*Handler)(ZLUserDataHolder &data, const std::string &error);
class AbstractHandlerHelper : public ZLUserData {
public:
virtual void handle(ZLUserDataHolder &data, const std::string &error) = 0;
};
template <typename T, typename Method>
class HandlerHelper : public AbstractHandlerHelper {
public:
HandlerHelper(T object, Method method) : myObject(object), myMethod(method) {
}
void handle(ZLUserDataHolder &data, const std::string &error) {
(myObject->*myMethod)(data, error);
}
private:
T myObject;
Method myMethod;
};
static void handleHelper(ZLUserDataHolder &data, const std::string &error);
static shared_ptr<ZLNetworkRequest::Listener> createListener(shared_ptr<ZLUserDataHolder> data);
static std::string ourHandlerId;
friend class ZLExecutionHandler;
};
#endif /* __ZLEXECUTIONUTIL_H__ */

@ -1,45 +0,0 @@
/*
* Copyright (C) 2004-2012 Geometer Plus <contact@geometerplus.com>
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
* 02110-1301, USA.
*/
#ifndef __ZLRUNNABLE_H__
#define __ZLRUNNABLE_H__
#include <string>
class ZLResource;
struct ZLResourceKey;
class ZLRunnable {
public:
virtual ~ZLRunnable();
virtual void run() = 0;
};
class ZLRunnableWithKey : public ZLRunnable {
public:
virtual ZLResourceKey key() const = 0;
virtual std::string text(const ZLResource &resource) const;
virtual bool makesSense() const;
};
inline ZLRunnable::~ZLRunnable() {}
#endif /* __ZLRUNNABLE_H__ */

@ -1,46 +0,0 @@
/*
* Copyright (C) 2004-2012 Geometer Plus <contact@geometerplus.com>
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
* 02110-1301, USA.
*/
#ifndef __ZLTIME_H__
#define __ZLTIME_H__
class ZLTime {
public:
ZLTime();
ZLTime(long seconds, long milliseconds);
~ZLTime();
long millisecondsTo(const ZLTime &time) const;
long millisecondsFrom(const ZLTime &time) const;
long inSeconds() const;
short hours() const;
short minutes() const;
short dayOfMonth() const; // from 1 to 31
short month() const; // from 1 to 12
short year() const;
private:
long mySeconds;
long myMilliseconds;
};
#endif /* __ZLTIME_H__ */

@ -1,94 +0,0 @@
/*
* Copyright (C) 2004-2012 Geometer Plus <contact@geometerplus.com>
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
* 02110-1301, USA.
*/
#ifndef __ZLTIMEMANAGER_H__
#define __ZLTIMEMANAGER_H__
#include <map>
#include <shared_ptr.h>
#include <ZLRunnable.h>
class ZLTime;
class ZLTimeManager {
private:
class AutoRemovableTask;
protected:
static ZLTimeManager *ourInstance;
public:
static ZLTimeManager &Instance();
static void deleteInstance();
protected:
ZLTimeManager();
virtual ~ZLTimeManager();
public:
virtual void addTask(shared_ptr<ZLRunnable> task, int interval) = 0;
void addAutoRemovableTask(shared_ptr<ZLRunnable> task, int delay = 0);
void removeTask(shared_ptr<ZLRunnable> task);
protected:
virtual void removeTaskInternal(shared_ptr<ZLRunnable> task) = 0;
virtual ZLTime currentTime() const = 0;
virtual short hoursBySeconds(long seconds) const = 0;
virtual short minutesBySeconds(long seconds) const = 0;
virtual short yearBySeconds(long seconds) const = 0;
virtual short monthBySeconds(long seconds) const = 0;
virtual short dayOfMonthBySeconds(long seconds) const = 0;
protected:
typedef void (*DeleteFunc)(void*);
template <typename T> struct DeleteHelper {
static void func(T *object) { delete object; }
};
class DeleteTask : public ZLRunnable {
public:
DeleteTask(void *object, DeleteFunc func) : myObject(object), myFunc(func) {}
private:
void run() { myFunc(myObject); }
void *myObject;
DeleteFunc myFunc;
};
public:
template <typename T> static void deleteLater(shared_ptr<T> object, int delay = 0) {
deleteLater(new shared_ptr<T>(object), delay);
}
template <typename T> static void deleteLater(T *object, int delay = 0) {
DeleteFunc func = reinterpret_cast<DeleteFunc>(&DeleteHelper<T>::func);
ZLTimeManager::Instance().addAutoRemovableTask(new DeleteTask(object, func), delay);
}
private:
std::map<shared_ptr<ZLRunnable>,shared_ptr<ZLRunnable> > myAutoRemovableTasks;
friend class ZLTime;
};
#endif /* __ZLTIMEMANAGER_H__ */

@ -1,36 +0,0 @@
/*
* Copyright (C) 2009-2012 Geometer Plus <contact@geometerplus.com>
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
* 02110-1301, USA.
*/
#ifndef ZLTREEACTIONNODE_H
#define ZLTREEACTIONNODE_H
#include "ZLTreeTitledNode.h"
class ZLTreeActionNode : public ZLTreeTitledNode {
public:
static const ZLTypeId TYPE_ID;
const ZLTypeId &typeId() const;
public:
// Return true if it is final action (dialog should be closed)
virtual bool activate() = 0;
};
#endif // ZLTREEACTIONNODE_H

@ -1,49 +0,0 @@
/*
* Copyright (C) 2009-2012 Geometer Plus <contact@geometerplus.com>
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
* 02110-1301, USA.
*/
#ifndef __ZLTREELISTENER_H__
#define __ZLTREELISTENER_H__
#include "ZLTreeNode.h"
//ZLTreeListener is used to get ability to node to notificate Tree Dialog about any changes
class ZLTreeListener {
public:
virtual void onExpandRequest(ZLTreeNode *node) = 0;
virtual void onCloseRequest() = 0;
// Parent has new or remove child at index
virtual void onNodeBeginInsert(ZLTreeNode *parent, std::size_t index) = 0;
virtual void onNodeEndInsert() = 0;
virtual void onNodeBeginRemove(ZLTreeNode *parent, std::size_t index) = 0;
virtual void onNodeEndRemove() = 0;
// This method should be called at every node state change except of adding/removing of children
virtual void onNodeUpdated(ZLTreeNode *node) = 0;
virtual void onDownloadingStarted(ZLTreeNode *node) = 0;
virtual void onDownloadingStopped(ZLTreeNode *node) = 0;
virtual void onSearchStarted(ZLTreeNode *node) = 0;
virtual void onSearchStopped(ZLTreeNode *node) = 0;
virtual void onRefresh() = 0;
};
#endif /* __ZLTREELISTENER_H__ */

@ -20,7 +20,7 @@
#include <algorithm>
#include "ZLTreeNode.h"
#include "ZLTreeListener.h"
#include "../resources/ZLResource.h"
#include "ZLResource.h"
//const ZLTypeId ZLTreeAction::TYPE_ID(ZLNetworkRequest::TYPE_ID);

@ -1,125 +0,0 @@
/*
* Copyright (C) 2009-2012 Geometer Plus <contact@geometerplus.com>
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
* 02110-1301, USA.
*/
#ifndef __ZLTREENODE_H__
#define __ZLTREENODE_H__
#include <map>
#include <vector>
#include <shared_ptr.h>
#include <ZLTypeId.h>
#include <ZLRunnable.h>
#include <ZLPaintContext.h>
#include <ZLNetworkRequest.h>
// Nowadays I see hierarchy in this way:
//
// ZLTreeNode
// |
// +-ZLTreeTitledNode -- simple node, as shown below
// | |
// | +- ZLTreeActionNode -- node with some action on click, i.e. BookNode at local library
// |
// +-ZLTreePageNode -- usually the leaf of the tree, smth like page with ZLDialogContent
// and some actions, i.e. BookInfo page at network library
class ZLTreeListener;
//class ZLTreeAction : public ZLNetworkRequest { //using ZLRunnableWithKey instead
//public:
// static const ZLTypeId TYPE_ID;
// ZLTreeAction();
// ~ZLTreeAction();
// const ZLTypeId &typeId() const;
// virtual void run() = 0;
// virtual ZLResourceKey key() const = 0;
// virtual std::string text(const ZLResource &resource) const;
// virtual bool makesSense() const;
//};
typedef ZLRunnableWithKey ZLTreeAction;
class ZLTreeNode : public ZLObjectWithRTTI {
public:
typedef std::vector<ZLTreeNode*> List;
public:
static const ZLTypeId TYPE_ID;
const ZLTypeId &typeId() const;
protected:
ZLTreeNode(ZLTreeNode *parent = 0, std::size_t position = -1);
public:
virtual ~ZLTreeNode();
void clear();
public:
ZLTreeNode *parent() const;
ZLTreeNode *previous() const;
ZLTreeNode *next() const;
const List &children() const;
std::size_t childIndex() const;
// Children should be requested from network only if we need them
virtual void requestChildren(shared_ptr<ZLNetworkRequest::Listener> listener = 0);
virtual void requestMoreChildren(shared_ptr<ZLNetworkRequest::Listener> listener = 0);
virtual const ZLResource &resource() const;
void registerAction(shared_ptr<ZLTreeAction> action);
const std::vector<shared_ptr<ZLTreeAction> > &actions() const;
std::string actionText(const shared_ptr<ZLTreeAction> &action) const;
void close() const;
void insert(ZLTreeNode *node, std::size_t index);
void append(ZLTreeNode *node);
void remove(ZLTreeNode *node);
void remove(std::size_t index);
void updated();
void notifyDownloadStarted();
void notifyDownloadStopped();
void notifySearchStarted();
void notifySearchStopped();
protected:
std::size_t level() const;
virtual ZLTreeListener *listener() const;
private:
ZLTreeNode *myParent;
std::size_t myChildIndex;
List myChildren;
// Looks like we should also handle actions for menu on "Tap and hold"
std::vector<shared_ptr<ZLTreeAction> > myActions;
private:
ZLTreeNode(const ZLTreeNode&);
const ZLTreeNode &operator = (const ZLTreeNode&);
};
#endif /* __ZLTREENODE_H__ */

@ -1,53 +0,0 @@
/*
* Copyright (C) 2009-2012 Geometer Plus <contact@geometerplus.com>
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
* 02110-1301, USA.
*/
#ifndef ZLTREEPAGENODE_H
#define ZLTREEPAGENODE_H
#include "ZLTreeTitledNode.h"
#include <ZLDialogContent.h>
class ZLTreePageInfo {
public:
virtual bool isPageInfoLoaded() = 0;
virtual void loadAll(shared_ptr<ZLNetworkRequest::Listener> listener) = 0;
virtual std::string title() const = 0;
virtual std::vector<std::string> authors() const = 0;
virtual std::vector<std::string> tags() const = 0;
virtual std::string summary() const = 0;
virtual shared_ptr<const ZLImage> image() const = 0;
virtual const std::vector<shared_ptr<ZLTreeAction> > &actions() const = 0;
virtual std::string actionText(const shared_ptr<ZLTreeAction> &action) const = 0;
virtual const std::vector<shared_ptr<ZLTreeAction> > relatedActions() const = 0;
};
class ZLTreePageNode : public ZLTreeTitledNode {
public:
ZLTreePageNode(ZLTreeNode *parent = 0, std::size_t position = -1);
static const ZLTypeId TYPE_ID;
const ZLTypeId &typeId() const;
virtual shared_ptr<ZLTreePageInfo> getPageInfo() = 0;
};
#endif // ZLTREEPAGENODE_H

@ -1,30 +0,0 @@
/*
* Copyright (C) 2004-2012 Geometer Plus <contact@geometerplus.com>
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
* 02110-1301, USA.
*/
#ifndef __ZLTREESEARCHER_H__
#define __ZLTREESEARCHER_H__
#include <string>
class ZLTreeSearcher {
public:
virtual void simpleSearch(const std::string &pattern) = 0;
};
#endif /* __ZLTREESEARCHER_H__ */

@ -1,49 +0,0 @@
/*
* Copyright (C) 2009-2012 Geometer Plus <contact@geometerplus.com>
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
* 02110-1301, USA.
*/
#ifndef __ZLTREETITLEDNODE_H__
#define __ZLTREETITLEDNODE_H__
#include "ZLTreeNode.h"
#include <ZLImage.h>
class ZLTreeTitledNode : public ZLTreeNode {
public:
static const ZLTypeId TYPE_ID;
const ZLTypeId &typeId() const;
static const std::string ZLIMAGE_SCHEME;
static const std::string LOCALFILE_SCHEME;
static const std::string SCHEME_POSTFIX;
public:
ZLTreeTitledNode(ZLTreeNode *parent = 0, std::size_t position = -1);
virtual ~ZLTreeTitledNode();
virtual std::string title() const = 0;
virtual std::string subtitle() const;
// Url to image
//virtual std::string imageUrl() const;
// Or the image if there is no url
virtual shared_ptr<const ZLImage> image() const;
};
#endif /* __ZLTREETITLEDNODE_H__ */

@ -1,79 +0,0 @@
/*
* Copyright (C) 2010-2012 Geometer Plus <contact@geometerplus.com>
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
* 02110-1301, USA.
*/
#ifndef __ZLTYPEID_H__
#define __ZLTYPEID_H__
class ZLTypeId {
private:
ZLTypeId();
public:
explicit ZLTypeId(const ZLTypeId &base);
bool operator == (const ZLTypeId &type) const;
bool operator != (const ZLTypeId &type) const;
bool isSubtypeOf(const ZLTypeId &type) const;
private:
const ZLTypeId *myBase;
friend class ZLObjectWithRTTI;
};
class ZLObjectWithRTTI {
public:
static const ZLTypeId TYPE_ID;
public:
virtual ~ZLObjectWithRTTI();
bool isInstanceOf(const ZLTypeId &type, bool exact = false) const;
protected:
virtual const ZLTypeId &typeId() const = 0;
};
template <typename T>
T zlobject_cast(ZLObjectWithRTTI *object) {
if (!object || !object->isInstanceOf(reinterpret_cast<T>(0)->TYPE_ID))
return 0;
return static_cast<T>(object);
}
template <typename T>
T zlobject_cast(const ZLObjectWithRTTI *object) {
if (!object || !object->isInstanceOf(reinterpret_cast<T>(0)->TYPE_ID))
return 0;
return static_cast<T>(object);
}
inline bool ZLTypeId::operator == (const ZLTypeId &type) const {
return this == &type;
}
inline bool ZLTypeId::operator != (const ZLTypeId &type) const {
return this != &type;
}
inline ZLObjectWithRTTI::~ZLObjectWithRTTI() {
}
#endif /* __ZLTYPEID_H__ */

@ -27,7 +27,7 @@
#include <tqcursor.h>
#include <tqlineedit.h>
#include "../../../../core/src/desktop/application/ZLDesktopApplicationWindow.h"
#include "ZLDesktopApplicationWindow.h"
class ZLTQtApplicationWindow : public TQMainWindow, public ZLDesktopApplicationWindow {
TQ_OBJECT

@ -20,7 +20,7 @@
#ifndef __ZLTQTDIALOGCONTENT_H__
#define __ZLTQTDIALOGCONTENT_H__
#include "../../../../core/src/desktop/dialogs/ZLDesktopOptionsDialog.h"
#include "ZLDesktopOptionsDialog.h"
class TQWidget;
class TQGridLayout;

@ -20,7 +20,7 @@
#ifndef __ZLTQTOPENFILEDIALOG_H__
#define __ZLTQTOPENFILEDIALOG_H__
#include "../../../../core/src/desktop/dialogs/ZLDesktopOpenFileDialog.h"
#include "ZLDesktopOpenFileDialog.h"
class TQFileDialog;

@ -24,7 +24,7 @@
#include <ZLOptionsDialog.h>
#include <ZLOptionEntry.h>
#include "../../../../core/src/dialogs/ZLOptionView.h"
#include "ZLOptionView.h"
class ZLTQtDialogContent;

@ -25,7 +25,7 @@
#include <tqwidget.h>
#include <tqtabdialog.h>
#include "../../../../core/src/desktop/dialogs/ZLDesktopOptionsDialog.h"
#include "ZLDesktopOptionsDialog.h"
class ZLTQtOptionsDialog : public TQTabDialog, public ZLDesktopOptionsDialog {
TQ_OBJECT

@ -20,7 +20,7 @@
#ifndef __ZLTQTFSMANAGER_H__
#define __ZLTQTFSMANAGER_H__
#include "../../../../core/src/unix/filesystem/ZLUnixFSManager.h"
#include "ZLUnixFSManager.h"
class ZLTQtFSManager : public ZLUnixFSManager {

@ -23,18 +23,18 @@
#include <ZLibrary.h>
#include <ZLLanguageUtil.h>
#include "../../unix/library/ZLibraryImplementation.h"
#include "ZLibraryImplementation.h"
#include "../filesystem/ZLTQtFSManager.h"
#include "../dialogs/ZLTQtDialogManager.h"
#include "../image/ZLTQtImageManager.h"
#include "../time/ZLTQtTime.h"
#include "../view/ZLTQtPaintContext.h"
#include "../../encoding/ZLEncodingConverter.h"
#include "../../unix/iconv/IConvEncodingConverter.h"
#include "../../unix/message/ZLUnixMessage.h"
#include "../../unix/xmlconfig/XMLConfig.h"
#include "../../util/ZLKeyUtil.h"
#include "ZLEncodingConverter.h"
#include "IConvEncodingConverter.h"
#include "ZLUnixMessage.h"
#include "XMLConfig.h"
#include "ZLKeyUtil.h"
class ZLTQtLibraryImplementation : public ZLibraryImplementation {

@ -24,7 +24,7 @@
#include <tqobject.h>
#include "../../../../core/src/unix/time/ZLUnixTime.h"
#include "ZLUnixTime.h"
class ZLTQtTimeManager : public TQObject, public ZLUnixTimeManager {

@ -20,7 +20,7 @@
#ifndef __ZLTQTKEYUTIL_H__
#define __ZLTQTKEYUTIL_H__
#include "../../../../core/src/util/ZLKeyUtil.h"
#include "ZLKeyUtil.h"
class TQKeyEvent;

@ -22,7 +22,7 @@
#include <tqwidget.h>
#include "../../../../core/src/view/ZLViewWidget.h"
#include "ZLViewWidget.h"
#include <ZLApplication.h>
class ZLTQtApplicationWindow;

@ -1,54 +0,0 @@
/*
* Copyright (C) 2009-2012 Geometer Plus <contact@geometerplus.com>
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
* 02110-1301, USA.
*/
#ifndef __ZLBASE64INPUTSTREAM_H__
#define __ZLBASE64INPUTSTREAM_H__
#include <ZLInputStream.h>
class ZLBase64InputStream : public ZLInputStream {
public:
ZLBase64InputStream(shared_ptr<ZLInputStream> base);
~ZLBase64InputStream();
bool open();
int read();
std::size_t read(char *buffer, std::size_t maxSize);
void close();
void seek(int offset, bool absoluteOffset);
std::size_t offset() const;
std::size_t sizeOfOpened();
private:
void fillDecodedBuffer();
bool fillBuffer();
static int decode(char b);
private:
shared_ptr<ZLInputStream> myBaseStream;
int myDecoded0;
int myDecoded1;
int myDecoded2;
char* myBuffer;
int myBufferOffset;
int myBufferLength;
};
#endif /* __ZLBASE64INPUTSTREAM_H__ */

@ -1,29 +0,0 @@
/*
* Copyright (C) 2004-2012 Geometer Plus <contact@geometerplus.com>
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
* 02110-1301, USA.
*/
#ifndef __ZLBOOLEAN3_H__
#define __ZLBOOLEAN3_H__
enum ZLBoolean3 {
B3_FALSE = 0,
B3_TRUE = 1,
B3_UNDEFINED = 2
};
#endif /* __ZLBOOLEAN3_H__ */

@ -1,42 +0,0 @@
/*
* Copyright (C) 2004-2012 Geometer Plus <contact@geometerplus.com>
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
* 02110-1301, USA.
*/
#ifndef __ZLCOLOR_H__
#define __ZLCOLOR_H__
struct ZLColor {
unsigned char Red;
unsigned char Green;
unsigned char Blue;
ZLColor(unsigned char r, unsigned char g, unsigned char b);
ZLColor(long longValue = 0);
long intValue();
bool operator == (const ZLColor &color) const;
bool operator != (const ZLColor &color) const;
};
inline ZLColor::ZLColor(unsigned char r, unsigned char g, unsigned char b) : Red(r), Green(g), Blue(b) {}
inline ZLColor::ZLColor(long longValue) : Red((unsigned char)(longValue >> 16)), Green((unsigned char)(longValue >> 8)), Blue((unsigned char)longValue) {}
inline long ZLColor::intValue() { return (((long)Red) << 16) + (((long)Green) << 8) + Blue; }
inline bool ZLColor::operator == (const ZLColor &color) const { return (Red == color.Red) && (Green == color.Green) && (Blue == color.Blue); }
inline bool ZLColor::operator != (const ZLColor &color) const { return !operator==(color); }
#endif /* __ZLCOLOR_H__ */

@ -1,34 +0,0 @@
/*
* Copyright (C) 2010-2012 Geometer Plus <contact@geometerplus.com>
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
* 02110-1301, USA.
*/
#ifndef __ZLFILEUTIL_H__
#define __ZLFILEUTIL_H__
#include <string>
class ZLFileUtil {
public:
static std::string normalizeUnixPath(const std::string &path);
private:
ZLFileUtil();
};
#endif /* __ZLFILEUTIL_H__ */

@ -1,50 +0,0 @@
/*
* Copyright (C) 2009-2012 Geometer Plus <contact@geometerplus.com>
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
* 02110-1301, USA.
*/
#ifndef __ZLHEXINPUTSTREAM_H__
#define __ZLHEXINPUTSTREAM_H__
#include <ZLInputStream.h>
class ZLHexInputStream : public ZLInputStream {
public:
ZLHexInputStream(shared_ptr<ZLInputStream> base);
~ZLHexInputStream();
bool open();
int read();
std::size_t read(char *buffer, std::size_t maxSize);
void close();
void seek(int offset, bool absoluteOffset);
std::size_t offset() const;
std::size_t sizeOfOpened();
private:
bool fillBuffer();
static int decode(char b);
private:
shared_ptr<ZLInputStream> myBaseStream;
char* myBuffer;
int myBufferOffset;
int myBufferLength;
};
#endif /* __ZLHEXINPUTSTREAM_H__ */

@ -1,38 +0,0 @@
/*
* Copyright (C) 2008-2012 Geometer Plus <contact@geometerplus.com>
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
* 02110-1301, USA.
*/
#ifndef __ZLLANGUAGEUTIL_H__
#define __ZLLANGUAGEUTIL_H__
#include <string>
class ZLLanguageUtil {
public:
static const std::string OtherLanguageCode;
public:
static std::string languageByCode(unsigned char languageCode, unsigned char subLanguageCode);
static bool isRTLLanguage(const std::string &languageCode);
private:
ZLLanguageUtil();
};
#endif /* __ZLLANGUAGEUTIL_H__ */

@ -1,60 +0,0 @@
/*
* Copyright (C) 2004-2012 Geometer Plus <contact@geometerplus.com>
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
* 02110-1301, USA.
*/
#ifndef __ZLSEARCHUTIL_H__
#define __ZLSEARCHUTIL_H__
#include <string>
class ZLSearchPattern {
public:
ZLSearchPattern(const std::string &pattern, bool ignoreCase);
~ZLSearchPattern();
int length() const;
private:
bool ignoreCase() const;
const std::string &lowerCasePattern() const;
const std::string &upperCasePattern() const;
private:
bool myIgnoreCase;
std::string myLowerCasePattern;
std::string myUpperCasePattern;
friend class ZLSearchUtil;
};
class ZLSearchUtil {
private:
ZLSearchUtil();
public:
static int find(const char *text, std::size_t length, const ZLSearchPattern &pattern, int pos = 0);
};
inline ZLSearchPattern::~ZLSearchPattern() {}
inline int ZLSearchPattern::length() const { return myLowerCasePattern.length(); }
inline bool ZLSearchPattern::ignoreCase() const { return myIgnoreCase; }
inline const std::string &ZLSearchPattern::lowerCasePattern() const { return myLowerCasePattern; }
inline const std::string &ZLSearchPattern::upperCasePattern() const { return myUpperCasePattern; }
#endif /* __ZLSEARCHUTIL_H__ */

@ -1,43 +0,0 @@
/*
* Copyright (C) 2009-2012 Geometer Plus <contact@geometerplus.com>
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
* 02110-1301, USA.
*/
#ifndef __ZLSLICEINPUTSTREAM_H__
#define __ZLSLICEINPUTSTREAM_H__
#include <ZLInputStream.h>
class ZLSliceInputStream : public ZLInputStream {
public:
ZLSliceInputStream(shared_ptr<ZLInputStream> base, std::size_t start, std::size_t length);
bool open();
std::size_t read(char *buffer, std::size_t maxSize);
void close();
void seek(int offset, bool absoluteOffset);
std::size_t offset() const;
std::size_t sizeOfOpened();
private:
shared_ptr<ZLInputStream> myBaseStream;
std::size_t myStart;
std::size_t myLength;
};
#endif /* __ZLSLICEINPUTSTREAM_H__ */

@ -1,84 +0,0 @@
/*
* Copyright (C) 2004-2012 Geometer Plus <contact@geometerplus.com>
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
* 02110-1301, USA.
*/
#ifndef __ZLSTRINGUTIL_H__
#define __ZLSTRINGUTIL_H__
#include <vector>
#include <string>
class ZLStringUtil {
private:
ZLStringUtil();
public:
static bool stringStartsWith(const std::string &str, const std::string &start);
static bool stringEndsWith(const std::string &str, const std::string &end);
static bool isDigit(char c);
static bool isLatinLetter(char c);
static void appendNumber(std::string &str, unsigned int n);
static void append(std::string &str, const std::vector<std::string> &buffer);
static void stripWhiteSpaces(std::string &str);
static const std::string SPACE;
static std::vector<std::string> split(const std::string &str, const std::string &delimiter);
static std::string printf(const std::string &format, const std::string &arg0);
static std::string printf(const std::string &format, unsigned int n);
static std::string doubleToString(double value);
static double stringToDouble(const std::string &value, double defaultValue);
static int stringToInteger(const std::string &str, int defaultValue = 0);
static std::string replaceAll(const std::string &str, const std::string& what, const std::string &to);
template <typename T, typename F>
static std::string join(T iterable, F functor, std::string separator);
template <typename T>
static std::string join(T iterable, std::string separator);
template <typename T>
struct self {
inline T operator()(const T &t) {
return t;
}
};
};
template <typename T, typename F>
std::string ZLStringUtil::join(T iterable, F functor, std::string separator) {
std::string result;
for (typename T::const_iterator it=iterable.begin(); it != iterable.end(); ++it) {
if (it != iterable.begin()) {
result += separator;
}
result += functor(*it);
}
return result;
}
template <typename T>
std::string ZLStringUtil::join(T iterable, std::string separator) {
return join(iterable, ZLStringUtil::self<typename T::value_type>(), separator);
}
#endif /* __ZLSTRINGUTIL_H__ */

@ -1,83 +0,0 @@
/*
* Copyright (C) 2004-2012 Geometer Plus <contact@geometerplus.com>
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
* 02110-1301, USA.
*/
#ifndef __ZLUNICODEUTIL_H__
#define __ZLUNICODEUTIL_H__
#include <stdint.h>
#include <string>
#include <vector>
class ZLUnicodeUtil {
private:
ZLUnicodeUtil();
public:
typedef uint16_t Ucs2Char;
typedef std::vector<Ucs2Char> Ucs2String;
typedef uint32_t Ucs4Char;
typedef std::vector<Ucs4Char> Ucs4String;
enum Breakable {
NO_BREAKABLE,
BREAKABLE_BEFORE,
BREAKABLE_AFTER
};
static bool isUtf8String(const char *str, int len);
static bool isUtf8String(const std::string &str);
static void cleanUtf8String(std::string &str);
static int utf8Length(const char *str, int len);
static int utf8Length(const std::string &str);
static int length(const char *str, int utf8Length);
static int length(const std::string &str, int utf8Length);
static void utf8ToUcs4(Ucs4String &to, const char *from, int length, int toLength = -1);
static void utf8ToUcs4(Ucs4String &to, const std::string &from, int toLength = -1);
static void utf8ToUcs2(Ucs2String &to, const char *from, int length, int toLength = -1);
static void utf8ToUcs2(Ucs2String &to, const std::string &from, int toLength = -1);
static std::size_t firstChar(Ucs4Char &ch, const char *utf8String);
static std::size_t firstChar(Ucs4Char &ch, const std::string &utf8String);
static std::size_t lastChar(Ucs4Char &ch, const char *utf8String);
static std::size_t lastChar(Ucs4Char &ch, const std::string &utf8String);
static void ucs4ToUtf8(std::string &to, const Ucs4String &from, int toLength = -1);
static int ucs4ToUtf8(char *to, Ucs4Char ch);
static void ucs2ToUtf8(std::string &to, const Ucs2String &from, int toLength = -1);
static int ucs2ToUtf8(char *to, Ucs2Char ch);
static bool isLetter(Ucs4Char ch);
static bool isSpace(Ucs4Char ch);
static bool isNBSpace(Ucs4Char ch);
static Breakable isBreakable(Ucs4Char ch);
static Ucs4Char toLower(Ucs4Char ch);
static void toLower(Ucs4String &str);
static std::string toLower(const std::string &utf8String);
static Ucs4Char toUpper(Ucs4Char ch);
static void toUpper(Ucs4String &str);
static std::string toUpper(const std::string &utf8String);
static void utf8Trim(std::string &utf8String);
};
inline bool ZLUnicodeUtil::isNBSpace(Ucs4Char ch) {
return ch == 160;
}
#endif /* __ZLUNICODEUTIL_H__ */

@ -1,50 +0,0 @@
/*
* Copyright (C) 2008-2012 Geometer Plus <contact@geometerplus.com>
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
* 02110-1301, USA.
*/
#ifndef __ZLUSERDATA_H__
#define __ZLUSERDATA_H__
#include <map>
#include <string>
#include <shared_ptr.h>
class ZLUserData {
public:
virtual ~ZLUserData();
};
class ZLUserDataHolder {
public:
ZLUserDataHolder();
ZLUserDataHolder(const ZLUserDataHolder &other);
virtual ~ZLUserDataHolder();
void addUserData(const std::string &key, shared_ptr<ZLUserData> data);
void removeUserData(const std::string &key);
shared_ptr<ZLUserData> getUserData(const std::string &key) const;
private:
ZLUserDataHolder &operator =(const ZLUserDataHolder &other);
std::map<std::string,shared_ptr<ZLUserData> > myDataMap;
};
#endif /* __ZLUSERDATA_H__ */

@ -1,83 +0,0 @@
/*
* Copyright (C) 2004-2012 Geometer Plus <contact@geometerplus.com>
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
* 02110-1301, USA.
*/
#ifndef __ALLOCATOR_H__
#define __ALLOCATOR_H__
#include <vector>
template<std::size_t ObjectSize, std::size_t PoolSize> class Allocator {
public:
Allocator();
~Allocator();
void *allocate();
void free(void *ptr);
private:
void addPool();
private:
std::vector<void*> myPools;
void *myFirstUnused;
void *myLastUnused;
};
template<std::size_t ObjectSize, std::size_t PoolSize>
inline Allocator<ObjectSize,PoolSize>::Allocator() {
addPool();
}
template<std::size_t ObjectSize, std::size_t PoolSize>
inline Allocator<ObjectSize,PoolSize>::~Allocator() {
for (std::vector<void*>::const_iterator it = myPools.begin(); it != myPools.end(); ++it) {
delete[] (char*)*it;
}
}
template<std::size_t ObjectSize, std::size_t PoolSize>
inline void Allocator<ObjectSize,PoolSize>::addPool() {
char *pool = new char[ObjectSize * PoolSize];
myFirstUnused = (void*)pool;
myLastUnused = (void*)(pool + ObjectSize * (PoolSize - 1));
for (std::size_t i = 0; i < PoolSize - 1; ++i) {
*(void**)(pool + ObjectSize * i) = pool + ObjectSize * (i + 1);
}
myPools.push_back(myFirstUnused);
}
template<std::size_t ObjectSize, std::size_t PoolSize>
void *Allocator<ObjectSize,PoolSize>::allocate() {
void *ptr = myFirstUnused;
if (myFirstUnused == myLastUnused) {
addPool();
} else {
myFirstUnused = *(void**)myFirstUnused;
}
return ptr;
}
template<std::size_t ObjectSize, std::size_t PoolSize>
void Allocator<ObjectSize,PoolSize>::free(void *ptr) {
*(void**)myLastUnused = ptr;
myLastUnused = ptr;
}
#endif /* __ALLOCATOR_H__ */

@ -1,424 +0,0 @@
/*
* Copyright (C) 2004-2012 Geometer Plus <contact@geometerplus.com>
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
* 02110-1301, USA.
*/
#ifndef __SHARED_PTR_H__
#define __SHARED_PTR_H__
template<class T> class shared_ptr_storage {
private:
unsigned int myCounter;
unsigned int myWeakCounter;
T* myPointer;
public:
shared_ptr_storage(T *pointer);
~shared_ptr_storage();
T* pointer() const;
T& content() const;
void addReference();
void removeReference();
void addWeakReference();
void removeWeakReference();
unsigned int counter() const;
};
template<class T> class weak_ptr;
template<class T> class shared_ptr {
friend class weak_ptr<T>;
private:
shared_ptr_storage<T> *myStorage;
shared_ptr_storage<T> *newStorage(T *t);
void attachStorage(shared_ptr_storage<T> *storage);
void detachStorage();
public:
shared_ptr();
shared_ptr(T *t);
shared_ptr(const shared_ptr<T> &t);
shared_ptr(const weak_ptr<T> &t);
~shared_ptr();
const shared_ptr<T> &operator = (T *t);
const shared_ptr<T> &operator = (const shared_ptr<T> &t);
const shared_ptr<T> &operator = (const weak_ptr<T> &t);
T* operator -> () const;
T& operator * () const;
bool isNull() const;
void reset();
bool operator == (const weak_ptr<T> &t) const;
bool operator != (const weak_ptr<T> &t) const;
bool operator < (const weak_ptr<T> &t) const;
bool operator > (const weak_ptr<T> &t) const;
bool operator <= (const weak_ptr<T> &t) const;
bool operator >= (const weak_ptr<T> &t) const;
bool operator == (const shared_ptr<T> &t) const;
bool operator != (const shared_ptr<T> &t) const;
bool operator < (const shared_ptr<T> &t) const;
bool operator > (const shared_ptr<T> &t) const;
bool operator <= (const shared_ptr<T> &t) const;
bool operator >= (const shared_ptr<T> &t) const;
};
template<class T> class weak_ptr {
friend class shared_ptr<T>;
private:
shared_ptr_storage<T> *myStorage;
void attachStorage(shared_ptr_storage<T> *storage);
void detachStorage();
public:
weak_ptr();
weak_ptr(const shared_ptr<T> &t);
weak_ptr(const weak_ptr<T> &t);
~weak_ptr();
const weak_ptr<T> &operator = (const weak_ptr<T> &t);
const weak_ptr<T> &operator = (const shared_ptr<T> &t);
T* operator -> () const;
T& operator * () const;
bool isNull() const;
void reset();
bool operator == (const weak_ptr<T> &t) const;
bool operator != (const weak_ptr<T> &t) const;
bool operator < (const weak_ptr<T> &t) const;
bool operator > (const weak_ptr<T> &t) const;
bool operator <= (const weak_ptr<T> &t) const;
bool operator >= (const weak_ptr<T> &t) const;
bool operator == (const shared_ptr<T> &t) const;
bool operator != (const shared_ptr<T> &t) const;
bool operator < (const shared_ptr<T> &t) const;
bool operator > (const shared_ptr<T> &t) const;
bool operator <= (const shared_ptr<T> &t) const;
bool operator >= (const shared_ptr<T> &t) const;
};
template<class T>
inline shared_ptr_storage<T>::shared_ptr_storage(T *pointer) {
myPointer = pointer;
myCounter = 0;
myWeakCounter = 0;
}
template<class T>
inline shared_ptr_storage<T>::~shared_ptr_storage() {
}
template<class T>
inline T* shared_ptr_storage<T>::pointer() const {
return myPointer;
}
template<class T>
inline T& shared_ptr_storage<T>::content() const {
return *myPointer;
}
template<class T>
inline void shared_ptr_storage<T>::addReference() {
++myCounter;
}
template<class T>
inline void shared_ptr_storage<T>::removeReference() {
--myCounter;
if (myCounter == 0) {
T* ptr = myPointer;
myPointer = 0;
delete ptr;
}
}
template<class T>
inline void shared_ptr_storage<T>::addWeakReference() {
++myWeakCounter;
}
template<class T>
inline void shared_ptr_storage<T>::removeWeakReference() {
--myWeakCounter;
}
template<class T>
inline unsigned int shared_ptr_storage<T>::counter() const {
return myCounter + myWeakCounter;
}
template<class T>
inline shared_ptr_storage<T> *shared_ptr<T>::newStorage(T *t) {
return (t == 0) ? 0 : new shared_ptr_storage<T>(t);
}
template<class T>
inline void shared_ptr<T>::attachStorage(shared_ptr_storage<T> *storage) {
myStorage = storage;
if (myStorage != 0) {
myStorage->addReference();
}
}
template<class T>
inline void shared_ptr<T>::detachStorage() {
if (myStorage != 0) {
if (myStorage->counter() == 1) {
myStorage->removeReference();
delete myStorage;
} else {
myStorage->removeReference();
}
}
}
template<class T>
inline shared_ptr<T>::shared_ptr() {
myStorage = 0;
}
template<class T>
inline shared_ptr<T>::shared_ptr(T *t) {
attachStorage(newStorage(t));
}
template<class T>
inline shared_ptr<T>::shared_ptr(const shared_ptr<T> &t) {
attachStorage(t.myStorage);
}
template<class T>
inline shared_ptr<T>::shared_ptr(const weak_ptr<T> &t) {
if (!t.isNull()) {
attachStorage(t.myStorage);
} else {
attachStorage(0);
}
}
template<class T>
inline shared_ptr<T>::~shared_ptr() {
detachStorage();
}
template<class T>
inline const shared_ptr<T> &shared_ptr<T>::operator = (T *t) {
detachStorage();
attachStorage(newStorage(t));
return *this;
}
template<class T>
inline const shared_ptr<T> &shared_ptr<T>::operator = (const shared_ptr<T> &t) {
if (&t != this) {
detachStorage();
attachStorage(t.myStorage);
}
return *this;
}
template<class T>
inline const shared_ptr<T> &shared_ptr<T>::operator = (const weak_ptr<T> &t) {
detachStorage();
if (!t.isNull()) {
attachStorage(t.myStorage);
} else {
attachStorage(0);
}
return *this;
}
template<class T>
inline T* shared_ptr<T>::operator -> () const {
return (myStorage == 0) ? 0 : myStorage->pointer();
}
template<class T>
inline T& shared_ptr<T>::operator * () const {
return myStorage->content();
}
template<class T>
inline bool shared_ptr<T>::isNull() const {
return myStorage == 0;
}
template<class T>
inline void shared_ptr<T>::reset() {
detachStorage();
attachStorage(0);
}
template<class T>
inline bool shared_ptr<T>::operator == (const weak_ptr<T> &t) const {
return operator -> () == t.operator -> ();
}
template<class T>
inline bool shared_ptr<T>::operator != (const weak_ptr<T> &t) const {
return !operator == (t);
}
template<class T>
inline bool shared_ptr<T>::operator < (const weak_ptr<T> &t) const {
return operator -> () < t.operator -> ();
}
template<class T>
inline bool shared_ptr<T>::operator > (const weak_ptr<T> &t) const {
return t.operator < (*this);
}
template<class T>
inline bool shared_ptr<T>::operator <= (const weak_ptr<T> &t) const {
return !t.operator < (*this);
}
template<class T>
inline bool shared_ptr<T>::operator >= (const weak_ptr<T> &t) const {
return !operator < (t);
}
template<class T>
inline bool shared_ptr<T>::operator == (const shared_ptr<T> &t) const {
return operator -> () == t.operator -> ();
}
template<class T>
inline bool shared_ptr<T>::operator != (const shared_ptr<T> &t) const {
return !operator == (t);
}
template<class T>
inline bool shared_ptr<T>::operator < (const shared_ptr<T> &t) const {
return operator -> () < t.operator -> ();
}
template<class T>
inline bool shared_ptr<T>::operator > (const shared_ptr<T> &t) const {
return t.operator < (*this);
}
template<class T>
inline bool shared_ptr<T>::operator <= (const shared_ptr<T> &t) const {
return !t.operator < (*this);
}
template<class T>
inline bool shared_ptr<T>::operator >= (const shared_ptr<T> &t) const {
return !operator < (t);
}
template<class T>
inline void weak_ptr<T>::attachStorage(shared_ptr_storage<T> *storage) {
myStorage = storage;
if (myStorage != 0) {
myStorage->addWeakReference();
}
}
template<class T>
inline void weak_ptr<T>::detachStorage() {
if (myStorage != 0) {
myStorage->removeWeakReference();
if (myStorage->counter() == 0) {
delete myStorage;
}
}
}
template<class T>
inline weak_ptr<T>::weak_ptr() {
myStorage = 0;
}
template<class T>
inline weak_ptr<T>::weak_ptr(const shared_ptr<T> &t) {
attachStorage(t.myStorage);
}
template<class T>
inline weak_ptr<T>::weak_ptr(const weak_ptr<T> &t) {
if (!t.isNull()) {
attachStorage(t.myStorage);
} else {
attachStorage(0);
}
}
template<class T>
inline weak_ptr<T>::~weak_ptr() {
detachStorage();
}
template<class T>
inline const weak_ptr<T> &weak_ptr<T>::operator = (const weak_ptr<T> &t) {
if (&t != this) {
detachStorage();
if (!t.isNull()) {
attachStorage(t.myStorage);
} else {
attachStorage(0);
}
}
return *this;
}
template<class T>
inline const weak_ptr<T> &weak_ptr<T>::operator = (const shared_ptr<T> &t) {
detachStorage();
attachStorage(t.myStorage);
return *this;
}
template<class T>
inline T* weak_ptr<T>::operator -> () const {
return (myStorage == 0) ? 0 : myStorage->pointer();
}
template<class T>
inline T& weak_ptr<T>::operator * () const {
return myStorage->content();
}
template<class T>
inline bool weak_ptr<T>::isNull() const {
return (myStorage == 0) || (myStorage->pointer() == 0);
}
template<class T>
inline void weak_ptr<T>::reset() {
detachStorage();
attachStorage(0);
}
template<class T>
inline bool weak_ptr<T>::operator == (const weak_ptr<T> &t) const {
return operator -> () == t.operator -> ();
}
template<class T>
inline bool weak_ptr<T>::operator != (const weak_ptr<T> &t) const {
return !operator == (t);
}
template<class T>
inline bool weak_ptr<T>::operator < (const weak_ptr<T> &t) const {
return operator -> () < t.operator -> ();
}
template<class T>
inline bool weak_ptr<T>::operator > (const weak_ptr<T> &t) const {
return t.operator < (*this);
}
template<class T>
inline bool weak_ptr<T>::operator <= (const weak_ptr<T> &t) const {
return !t.operator < (*this);
}
template<class T>
inline bool weak_ptr<T>::operator >= (const weak_ptr<T> &t) const {
return !operator < (t);
}
template<class T>
inline bool weak_ptr<T>::operator == (const shared_ptr<T> &t) const {
return operator -> () == t.operator -> ();
}
template<class T>
inline bool weak_ptr<T>::operator != (const shared_ptr<T> &t) const {
return !operator == (t);
}
template<class T>
inline bool weak_ptr<T>::operator < (const shared_ptr<T> &t) const {
return operator -> () < t.operator -> ();
}
template<class T>
inline bool weak_ptr<T>::operator > (const shared_ptr<T> &t) const {
return t.operator < (*this);
}
template<class T>
inline bool weak_ptr<T>::operator <= (const shared_ptr<T> &t) const {
return !t.operator < (*this);
}
template<class T>
inline bool weak_ptr<T>::operator >= (const shared_ptr<T> &t) const {
return !operator < (t);
}
#endif /* __SHARED_PTR_H__ */

@ -1,72 +0,0 @@
/*
* Copyright (C) 2004-2012 Geometer Plus <contact@geometerplus.com>
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
* 02110-1301, USA.
*/
#ifndef __ZLMIRROREDPAINTCONTEXT_H__
#define __ZLMIRROREDPAINTCONTEXT_H__
#include <vector>
#include <string>
#include <ZLColor.h>
#include <ZLPaintContext.h>
class ZLMirroredPaintContext : public ZLPaintContext {
public:
ZLMirroredPaintContext(ZLPaintContext &base);
public:
int mirroredX(int x) const;
private:
void clear(ZLColor color);
void setFont(const std::string &family, int size, bool bold, bool italic);
void setColor(ZLColor color, LineStyle style);
void setFillColor(ZLColor color, FillStyle style);
int width() const;
int height() const;
int stringWidth(const char *str, int len, bool rtl) const;
int spaceWidth() const;
int stringHeight() const;
int descent() const;
void drawString(int x, int y, const char *str, int len, bool rtl);
void drawImage(int x, int y, const ZLImageData &image);
void drawImage(int x, int y, const ZLImageData &image, int width, int height, ScalingType type);
void drawLine(int x0, int y0, int x1, int y1);
void fillRectangle(int x0, int y0, int x1, int y1);
void drawFilledCircle(int x, int y, int r);
const std::string realFontFamilyName(std::string &fontFamily) const;
void fillFamiliesList(std::vector<std::string> &families) const;
private:
ZLPaintContext &myBase;
};
inline int ZLMirroredPaintContext::mirroredX(int x) const {
return myBase.width() - x - 1;
}
#endif /* __ZLMIRROREDPAINTCONTEXT_H__ */

@ -1,98 +0,0 @@
/*
* Copyright (C) 2004-2012 Geometer Plus <contact@geometerplus.com>
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
* 02110-1301, USA.
*/
#ifndef __ZLPAINTCONTEXT_H__
#define __ZLPAINTCONTEXT_H__
#include <vector>
#include <string>
#include <ZLColor.h>
#include <ZLImageManager.h>
class ZLPaintContext {
public:
enum LineStyle {
SOLID_LINE,
DASH_LINE,
};
enum FillStyle {
SOLID_FILL,
HALF_FILL,
};
protected:
ZLPaintContext();
public:
virtual ~ZLPaintContext();
virtual void clear(ZLColor color) = 0;
virtual void setFont(const std::string &family, int size, bool bold, bool italic) = 0;
virtual void setColor(ZLColor color, LineStyle style = SOLID_LINE) = 0;
virtual void setFillColor(ZLColor color, FillStyle style = SOLID_FILL) = 0;
virtual int width() const = 0;
virtual int height() const = 0;
virtual int stringWidth(const char *str, int len, bool rtl) const = 0;
virtual int spaceWidth() const = 0;
virtual int stringHeight() const = 0;
virtual int descent() const = 0;
virtual void drawString(int x, int y, const char *str, int len, bool rtl) = 0;
enum ScalingType {
SCALE_FIT_TO_SIZE,
SCALE_REDUCE_SIZE
};
int imageWidth(const ZLImageData &image) const;
int imageHeight(const ZLImageData &image) const;
int imageWidth(const ZLImageData &image, int width, int height, ScalingType type) const;
int imageHeight(const ZLImageData &image, int width, int height, ScalingType type) const;
virtual void drawImage(int x, int y, const ZLImageData &image) = 0;
virtual void drawImage(int x, int y, const ZLImageData &image, int width, int height, ScalingType type) = 0;
virtual void drawLine(int x0, int y0, int x1, int y1) = 0;
virtual void fillRectangle(int x0, int y0, int x1, int y1) = 0;
virtual void drawFilledCircle(int x, int y, int r) = 0;
const std::vector<std::string> &fontFamilies() const;
virtual const std::string realFontFamilyName(std::string &fontFamily) const = 0;
protected:
virtual void fillFamiliesList(std::vector<std::string> &families) const = 0;
private:
mutable std::vector<std::string> myFamilies;
private:
ZLPaintContext(const ZLPaintContext&);
const ZLPaintContext &operator = (const ZLPaintContext&);
friend class ZLMirroredPaintContext;
};
inline int ZLPaintContext::imageWidth(const ZLImageData &image) const { return image.width(); }
inline int ZLPaintContext::imageHeight(const ZLImageData &image) const { return image.height(); }
#endif /* __ZLPAINTCONTEXT_H__ */

@ -1,110 +0,0 @@
/*
* Copyright (C) 2004-2012 Geometer Plus <contact@geometerplus.com>
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
* 02110-1301, USA.
*/
#ifndef __ZLVIEW_H__
#define __ZLVIEW_H__
#include <string>
#include <shared_ptr.h>
#include <ZLColor.h>
#include <ZLTypeId.h>
class ZLViewWidget;
class ZLPaintContext;
class ZLView : public ZLObjectWithRTTI {
public:
enum Angle {
DEGREES0 = 0,
DEGREES90 = 90,
DEGREES180 = 180,
DEGREES270 = 270
};
enum Direction {
VERTICAL,
HORIZONTAL
};
protected:
static const ZLTypeId TYPE_ID;
public:
ZLView(ZLPaintContext &context);
virtual ~ZLView();
virtual const std::string &caption() const = 0;
virtual void paint() = 0;
ZLPaintContext &context() const;
/*
* returns true iff stylus/finger event was processed
*/
virtual bool onStylusPress(int x, int y);
virtual bool onStylusRelease(int x, int y);
virtual bool onStylusMove(int x, int y);
virtual bool onStylusMovePressed(int x, int y);
virtual bool onFingerTap(int x, int y);
protected:
const ZLTypeId &typeId() const;
virtual ZLColor backgroundColor() const = 0;
void setScrollbarEnabled(Direction direction, bool enabled);
void setScrollbarParameters(Direction direction, std::size_t full, std::size_t from, std::size_t to);
virtual void onScrollbarMoved(Direction direction, std::size_t full, std::size_t from, std::size_t to);
virtual void onScrollbarStep(Direction direction, int steps);
virtual void onScrollbarPageStep(Direction direction, int steps);
private:
struct ScrollBarInfo {
ScrollBarInfo();
bool Enabled;
bool StandardLocation;
std::size_t Full;
std::size_t From;
std::size_t To;
};
void updateScrollbarState();
void updateScrollbarPlacement();
void updateScrollbarParameters();
void updateScrollbarParameters(Direction direction, const ScrollBarInfo &info, bool invert);
private:
ZLViewWidget *myViewWidget;
ZLPaintContext &myContext;
ScrollBarInfo myVerticalScrollbarInfo;
ScrollBarInfo myHorizontalScrollbarInfo;
private:
ZLView(const ZLView&);
const ZLView &operator=(const ZLView&);
friend class ZLViewWidget;
};
inline ZLPaintContext &ZLView::context() const { return myContext; }
#endif /* __ZLVIEW_H__ */

@ -21,16 +21,13 @@
#include <algorithm>
#include "ZLAsynchronousInputStream.h"
#include <ZLFile.h>
#include <ZLInputStream.h>
#include <ZLStringUtil.h>
#include <ZLUnicodeUtil.h>
#include "ZLAsynchronousInputStream.h"
#include "ZLXMLReader.h"
#include "expat/ZLXMLReaderInternal.h"
#include "ZLXMLReaderInternal.h"
class ZLXMLReaderHandler : public ZLAsynchronousInputStream::Handler {

@ -1,125 +0,0 @@
/*
* Copyright (C) 2004-2012 Geometer Plus <contact@geometerplus.com>
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
* 02110-1301, USA.
*/
#ifndef __ZLXMLREADER_H__
#define __ZLXMLREADER_H__
#include <string>
#include <vector>
#include <map>
#include <shared_ptr.h>
class ZLFile;
class ZLInputStream;
class ZLAsynchronousInputStream;
class ZLXMLReaderInternal;
class ZLXMLReader {
public:
class AttributeNamePredicate {
public:
virtual ~AttributeNamePredicate();
virtual bool accepts(const ZLXMLReader &reader, const char *name) const = 0;
};
class FixedAttributeNamePredicate : public AttributeNamePredicate {
public:
FixedAttributeNamePredicate(const std::string &attributeName);
bool accepts(const ZLXMLReader &reader, const char *name) const;
private:
const std::string myAttributeName;
};
class NamespaceAttributeNamePredicate : public AttributeNamePredicate {
public:
NamespaceAttributeNamePredicate(const std::string &ns, const std::string &name);
bool accepts(const ZLXMLReader &reader, const char *name) const;
private:
const std::string myNamespaceName;
const std::string myAttributeName;
};
protected:
ZLXMLReader(const char *encoding = 0);
public:
virtual ~ZLXMLReader();
bool readDocument(const ZLFile &file);
bool readDocument(shared_ptr<ZLInputStream> stream);
bool readDocument(shared_ptr<ZLAsynchronousInputStream> stream);
const std::string &errorMessage() const;
typedef std::map<std::string,std::string> nsMap;
const nsMap &namespaces() const;
const char *attributeValue(const char **xmlattributes, const char *name);
const char *attributeValue(const char **xmlattributes, const AttributeNamePredicate &predicate);
static std::map<std::string,std::string> getAttributesMap(const char **xmlattributes);
private:
void initialize(const char *encoding = 0);
void shutdown();
bool readFromBuffer(const char *data, std::size_t len);
protected:
virtual void startElementHandler(const char *tag, const char **attributes);
virtual void endElementHandler(const char *tag);
virtual void characterDataHandler(const char *text, std::size_t len);
virtual bool processNamespaces() const;
virtual const std::vector<std::string> &externalDTDs() const;
virtual void collectExternalEntities(std::map<std::string,std::string> &entityMap);
bool testTag(const std::string &ns, const std::string &name, const std::string &tag) const;
bool isInterrupted() const;
std::size_t getCurrentPosition() const;
protected:
void interrupt();
void setErrorMessage(const std::string &message);
private:
bool myInterrupted;
ZLXMLReaderInternal *myInternalReader;
char *myParserBuffer;
std::vector<shared_ptr<nsMap> > myNamespaces;
std::string myErrorMessage;
friend class ZLXMLReaderInternal;
friend class ZLXMLReaderHandler;
};
inline bool ZLXMLReader::isInterrupted() const {
return myInterrupted;
}
inline void ZLXMLReader::interrupt() {
myInterrupted = true;
}
#endif /* __ZLXMLREADER_H__ */

@ -1,88 +0,0 @@
/*
* Copyright (C) 2004-2012 Geometer Plus <contact@geometerplus.com>
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
* 02110-1301, USA.
*/
#ifndef __ZLXMLWRITER_H__
#define __ZLXMLWRITER_H__
#include <stack>
#include <vector>
#include <string>
#include <ZLOutputStream.h>
class ZLXMLWriter {
private:
struct Attribute {
std::string Name;
std::string Value;
Attribute(const std::string &name, const std::string &value);
~Attribute();
};
class Tag {
public:
Tag(const std::string &name, bool single);
~Tag();
void addAttribute(const std::string &name, const std::string &value);
void addData(const std::string &data);
bool isSingle() const;
bool isDataEmpty() const;
void writeStart(ZLOutputStream &stream) const;
void writeEnd(ZLOutputStream &stream) const;
private:
std::string myName;
std::string myData;
bool mySingle;
std::vector<Attribute> myAttributes;
};
protected:
ZLXMLWriter(ZLOutputStream &stream);
virtual ~ZLXMLWriter();
void addTag(const std::string &name, bool single);
void addAttribute(const std::string &name, const std::string &value);
void addData(const std::string &data);
void closeTag();
void closeAllTags();
private:
void flushTagStart();
private:
ZLOutputStream &myStream;
Tag *myCurrentTag;
std::stack<Tag*> myTags;
};
inline ZLXMLWriter::Attribute::Attribute(const std::string &name, const std::string &value) : Name(name), Value(value) {}
inline ZLXMLWriter::Attribute::~Attribute() {}
inline bool ZLXMLWriter::Tag::isSingle() const { return mySingle; }
inline bool ZLXMLWriter::Tag::isDataEmpty() const { return myData.empty(); }
inline ZLXMLWriter::Tag::~Tag() {}
inline ZLXMLWriter::~ZLXMLWriter() {}
#endif /* __ZLXMLWRITER_H__ */

@ -24,7 +24,7 @@
#include <ZLEncodingConverter.h>
#include "ZLXMLReaderInternal.h"
#include "../ZLXMLReader.h"
#include "ZLXMLReader.h"
void ZLXMLReaderInternal::fCharacterDataHandler(void *userData, const char *text, int len) {
ZLXMLReader &reader = *(ZLXMLReader*)userData;

@ -28,7 +28,7 @@
#include "ZLTextAreaStyle.h"
#include "ZLTextParagraphCursor.h"
#include "ZLTextElement.h"
#include "../style/ZLTextDecoratedStyle.h"
#include "ZLTextDecoratedStyle.h"
ZLTextArea::Style::Style(const ZLTextArea &area, shared_ptr<ZLTextStyle> style) : myArea(area) {
myTextStyle = style;

@ -24,7 +24,7 @@
#include <ZLResource.h>
#include <ZLOptionEntry.h>
#include <optionEntries/ZLFontFamilyOptionEntry.h>
#include <ZLFontFamilyOptionEntry.h>
class ZLPaintContext;

@ -21,7 +21,7 @@
#include "ZLTextSelectionScroller.h"
#include "ZLTextView.h"
#include "../area/ZLTextSelectionModel.h"
#include "ZLTextSelectionModel.h"
ZLTextSelectionScroller::ZLTextSelectionScroller(ZLTextView &view) : myView(view), myDirection(DONT_SCROLL) {
}

@ -28,11 +28,11 @@
#include "ZLTextView.h"
#include "ZLTextSelectionScroller.h"
#include "ZLTextPositionIndicator.h"
#include "../area/ZLTextSelectionModel.h"
#include "../area/ZLTextLineInfo.h"
#include "../area/ZLTextParagraphCursor.h"
#include "../area/ZLTextWord.h"
#include "../area/ZLTextAreaStyle.h"
#include "ZLTextSelectionModel.h"
#include "ZLTextLineInfo.h"
#include "ZLTextParagraphCursor.h"
#include "ZLTextWord.h"
#include "ZLTextAreaStyle.h"
const ZLTypeId ZLTextView::TYPE_ID(ZLView::TYPE_ID);

Loading…
Cancel
Save