mirror of
https://github.com/Alfresco/alfresco-community-repo.git
synced 2025-07-24 17:32:48 +00:00
Merged enterprise features
git-svn-id: https://svn.alfresco.com/repos/alfresco-enterprise/alfresco/HEAD/root@2746 c4b6b30b-aa2e-2d43-bbcb-ca4b014f7261
This commit is contained in:
302
source/cpp/CAlfrescoApp/includes/alfresco/Alfresco.hpp
Normal file
302
source/cpp/CAlfrescoApp/includes/alfresco/Alfresco.hpp
Normal file
@@ -0,0 +1,302 @@
|
||||
/*
|
||||
* Copyright (C) 2005 Alfresco, Inc.
|
||||
*
|
||||
* Licensed under the Alfresco Network License. You may obtain a
|
||||
* copy of the License at
|
||||
*
|
||||
* http://www.alfrescosoftware.com/legal/
|
||||
*
|
||||
* Please view the license relevant to your network subscription.
|
||||
*
|
||||
* BY CLICKING THE "I UNDERSTAND AND ACCEPT" BOX, OR INSTALLING,
|
||||
* READING OR USING ALFRESCO'S Network SOFTWARE (THE "SOFTWARE"),
|
||||
* YOU ARE AGREEING ON BEHALF OF THE ENTITY LICENSING THE SOFTWARE
|
||||
* ("COMPANY") THAT COMPANY WILL BE BOUND BY AND IS BECOMING A PARTY TO
|
||||
* THIS ALFRESCO NETWORK AGREEMENT ("AGREEMENT") AND THAT YOU HAVE THE
|
||||
* AUTHORITY TO BIND COMPANY. IF COMPANY DOES NOT AGREE TO ALL OF THE
|
||||
* TERMS OF THIS AGREEMENT, DO NOT SELECT THE "I UNDERSTAND AND AGREE"
|
||||
* BOX AND DO NOT INSTALL THE SOFTWARE OR VIEW THE SOURCE CODE. COMPANY
|
||||
* HAS NOT BECOME A LICENSEE OF, AND IS NOT AUTHORIZED TO USE THE
|
||||
* SOFTWARE UNLESS AND UNTIL IT HAS AGREED TO BE BOUND BY THESE LICENSE
|
||||
* TERMS. THE "EFFECTIVE DATE" FOR THIS AGREEMENT SHALL BE THE DAY YOU
|
||||
* CHECK THE "I UNDERSTAND AND ACCEPT" BOX.
|
||||
*/
|
||||
|
||||
#ifndef _Alfresco_H
|
||||
#define _Alfresco_H
|
||||
|
||||
// Includes
|
||||
|
||||
#include <windows.h>
|
||||
#include <WinIOCtl.h>
|
||||
|
||||
#include <vector>
|
||||
#include <algorithm>
|
||||
#include "util\Exception.h"
|
||||
#include "util\String.h"
|
||||
#include "util\DataBuffer.h"
|
||||
|
||||
// Classes defined in this header file
|
||||
|
||||
namespace Alfresco {
|
||||
class AlfrescoInterface;
|
||||
class AlfrescoFileInfo;
|
||||
class AlfrescoFileInfoList;
|
||||
typedef std::auto_ptr<AlfrescoFileInfo> PTR_AlfrescoFileInfo;
|
||||
}
|
||||
|
||||
// Constants
|
||||
|
||||
namespace Alfresco {
|
||||
|
||||
// Alfresco I/O control codes
|
||||
|
||||
#define FSCTL_ALFRESCO_PROBE CTL_CODE(FILE_DEVICE_FILE_SYSTEM, 0x800, METHOD_BUFFERED, FILE_ANY_ACCESS)
|
||||
#define FSCTL_ALFRESCO_FILESTS CTL_CODE(FILE_DEVICE_FILE_SYSTEM, 0x801, METHOD_BUFFERED, FILE_ANY_ACCESS)
|
||||
#define FSCTL_ALFRESCO_CHECKOUT CTL_CODE(FILE_DEVICE_FILE_SYSTEM, 0x802, METHOD_BUFFERED, FILE_WRITE_DATA)
|
||||
#define FSCTL_ALFRESCO_CHECKIN CTL_CODE(FILE_DEVICE_FILE_SYSTEM, 0x803, METHOD_BUFFERED, FILE_WRITE_DATA)
|
||||
|
||||
// Request signature bytes
|
||||
|
||||
#define IOSignature "ALFRESCO"
|
||||
#define IOSignatureLen 8
|
||||
|
||||
// Path prefixes/components
|
||||
|
||||
#define UNCPathPrefix L"\\\\"
|
||||
#define PathSeperator L"\\"
|
||||
|
||||
// I/O control status codes
|
||||
|
||||
#define StsSuccess 0
|
||||
|
||||
#define StsError 1
|
||||
#define StsFileNotFound 2
|
||||
#define StsAccessDenied 3
|
||||
#define StsBadParameter 4
|
||||
#define StsNotWorkingCopy 5
|
||||
|
||||
// Boolean field values
|
||||
|
||||
#define True 1
|
||||
#define False 0
|
||||
|
||||
// File status field values
|
||||
//
|
||||
// Node type
|
||||
|
||||
#define TypeFile 0
|
||||
#define TypeFolder 1
|
||||
|
||||
// Lock status
|
||||
|
||||
#define LockNone 0
|
||||
#define LockRead 1
|
||||
#define LockWrite 2
|
||||
}
|
||||
|
||||
// Define Alfresco interface exceptions
|
||||
|
||||
DEFINE_EXCEPTION(Alfresco, BadInterfaceException);
|
||||
|
||||
/**
|
||||
* Alfresco API Class
|
||||
*
|
||||
* Provides the interface to an Alfresco CIFS server to perform Alfresco specific functions
|
||||
* not available via the normal file I/O functions.
|
||||
*/
|
||||
class Alfresco::AlfrescoInterface {
|
||||
public:
|
||||
// Class constructors
|
||||
|
||||
AlfrescoInterface(String& path);
|
||||
|
||||
// Class destructor
|
||||
|
||||
~AlfrescoInterface();
|
||||
|
||||
// Return the UNC path and root path
|
||||
|
||||
inline const String& getUNCPath( void) const { return m_uncPath; }
|
||||
inline const String& getRootPath( void) const { return m_rootPath; }
|
||||
|
||||
// Check if the application is running from a mapped drive, return the drive path
|
||||
|
||||
inline bool isMappedDrive( void) const { return m_mappedDrive.length() > 0 ? true : false; }
|
||||
inline const String& getDrivePath( void) const { return m_mappedDrive; }
|
||||
|
||||
// Check if the path is on an Alfresco CIFS server
|
||||
|
||||
bool isAlfrescoFolder( void);
|
||||
|
||||
// Return the Alfresco file information for a file/folder within the current folder
|
||||
|
||||
PTR_AlfrescoFileInfo getFileInformation(const wchar_t* fileName);
|
||||
|
||||
// Check in a working copy file
|
||||
|
||||
void checkIn( const wchar_t* fileName, bool keepCheckedOut = false);
|
||||
|
||||
// Check out a file
|
||||
|
||||
void checkOut( const wchar_t* fileName, String& workingCopy);
|
||||
|
||||
private:
|
||||
// Send an I/O control request, receive and validate the response
|
||||
|
||||
void sendIOControl( const unsigned int ctlCode, DataBuffer& reqbuf, DataBuffer& respbuf);
|
||||
|
||||
private:
|
||||
// Hide the copy constructor
|
||||
|
||||
AlfrescoInterface(const AlfrescoInterface& alfresco) {};
|
||||
|
||||
private:
|
||||
// Instance variables
|
||||
//
|
||||
// UNC path and root path
|
||||
|
||||
String m_uncPath;
|
||||
String m_rootPath;
|
||||
|
||||
// Local path letter if running from a mapped drive
|
||||
|
||||
String m_mappedDrive;
|
||||
|
||||
// Handle to folder
|
||||
|
||||
HANDLE m_handle;
|
||||
|
||||
};
|
||||
|
||||
/**
|
||||
* Alfresco File Information Class
|
||||
*
|
||||
* Contains Alfresco specific file information for a file/folder on an Alfresco CIFS server.
|
||||
*/
|
||||
class Alfresco::AlfrescoFileInfo {
|
||||
public:
|
||||
// Class constructor
|
||||
|
||||
AlfrescoFileInfo( const wchar_t* fName);
|
||||
|
||||
// Return the file/folder name
|
||||
|
||||
inline const String& getName( void) const { return m_name; }
|
||||
|
||||
// Determine if the file is a file or folder
|
||||
|
||||
inline unsigned int isType( void) const { return m_type; }
|
||||
|
||||
// Return the working copy status, owner, copied from
|
||||
|
||||
inline bool isWorkingCopy( void) const { return m_workingCopy; }
|
||||
inline const String& getCopyOwner( void) const { return m_workOwner; }
|
||||
inline const String& getCopiedFrom( void) const { return m_copiedFrom; }
|
||||
|
||||
// Return the lock status
|
||||
|
||||
inline unsigned int getLockType( void) const { return m_lockType; }
|
||||
inline const String& getLockOwner( void) const { return m_lockOwner; }
|
||||
|
||||
// Return the content details
|
||||
|
||||
inline bool hasContent( void) const { return m_hasContent; }
|
||||
inline LONG64 getContentLength( void) const { return m_contentLen; }
|
||||
inline const String& getContentType( void) const { return m_contentMimeType; }
|
||||
|
||||
// Set the file/folder type
|
||||
|
||||
inline void setType( unsigned int typ) { m_type = typ; }
|
||||
|
||||
// Set the working copy owner and copied from
|
||||
|
||||
void setWorkingCopy( const wchar_t* owner, const wchar_t* copiedFrom);
|
||||
|
||||
// Set the lock type and owner
|
||||
|
||||
void setLockType( unsigned int typ, const wchar_t* owner = L"");
|
||||
|
||||
// Set the content length and type
|
||||
|
||||
void setContent( LONG64 siz, const wchar_t* mimeType);
|
||||
|
||||
// Operators
|
||||
|
||||
bool operator==( const AlfrescoFileInfo& finfo);
|
||||
bool operator<( const AlfrescoFileInfo& finfo);
|
||||
|
||||
private:
|
||||
// Hide the copy constructor
|
||||
|
||||
AlfrescoFileInfo(const AlfrescoFileInfo& aInfo) {};
|
||||
|
||||
private:
|
||||
// Instance variables
|
||||
//
|
||||
// File/folder name
|
||||
|
||||
String m_name;
|
||||
unsigned int m_type;
|
||||
|
||||
// Working copy flag, owner and copied from
|
||||
|
||||
bool m_workingCopy;
|
||||
String m_workOwner;
|
||||
String m_copiedFrom;
|
||||
|
||||
// Lock type and owner
|
||||
|
||||
unsigned int m_lockType;
|
||||
String m_lockOwner;
|
||||
|
||||
// Content mime-type and length
|
||||
|
||||
bool m_hasContent;
|
||||
LONG64 m_contentLen;
|
||||
String m_contentMimeType;
|
||||
};
|
||||
|
||||
/**
|
||||
* Alfresco File Info List Class
|
||||
*/
|
||||
class Alfresco::AlfrescoFileInfoList {
|
||||
public:
|
||||
// Class constructor
|
||||
|
||||
AlfrescoFileInfoList( void) {};
|
||||
|
||||
// Add a file information object to the list
|
||||
|
||||
inline void addInfo( AlfrescoFileInfo* pInfo) { m_list.push_back( pInfo); }
|
||||
inline void addInfo( PTR_AlfrescoFileInfo pInfo) { if ( pInfo.get() != NULL) m_list.push_back( pInfo.release()); }
|
||||
|
||||
// Return the number of objects in the list
|
||||
|
||||
inline size_t size( void) const { return m_list.size(); }
|
||||
|
||||
// Return the specified file information
|
||||
|
||||
inline const AlfrescoFileInfo* getInfoAt( unsigned int idx) const { return m_list[idx]; }
|
||||
|
||||
// Assignment operator
|
||||
|
||||
inline AlfrescoFileInfo*& operator[] ( const unsigned int idx) { return m_list[idx]; }
|
||||
|
||||
// Remove all objects from the list
|
||||
|
||||
inline void clear( void) { for ( unsigned int i = 0; i < m_list.size(); delete m_list[i++]); m_list.clear(); }
|
||||
|
||||
// Return the vector
|
||||
|
||||
std::vector<AlfrescoFileInfo*> getList( void) { return m_list; }
|
||||
|
||||
private:
|
||||
// Instance variables
|
||||
//
|
||||
// List of file information objects
|
||||
|
||||
std::vector<AlfrescoFileInfo*> m_list;
|
||||
};
|
||||
|
||||
#endif
|
109
source/cpp/CAlfrescoApp/includes/util/ByteArray.h
Normal file
109
source/cpp/CAlfrescoApp/includes/util/ByteArray.h
Normal file
@@ -0,0 +1,109 @@
|
||||
/*
|
||||
* Copyright (C) 2005 Alfresco, Inc.
|
||||
*
|
||||
* Licensed under the Alfresco Network License. You may obtain a
|
||||
* copy of the License at
|
||||
*
|
||||
* http://www.alfrescosoftware.com/legal/
|
||||
*
|
||||
* Please view the license relevant to your network subscription.
|
||||
*
|
||||
* BY CLICKING THE "I UNDERSTAND AND ACCEPT" BOX, OR INSTALLING,
|
||||
* READING OR USING ALFRESCO'S Network SOFTWARE (THE "SOFTWARE"),
|
||||
* YOU ARE AGREEING ON BEHALF OF THE ENTITY LICENSING THE SOFTWARE
|
||||
* ("COMPANY") THAT COMPANY WILL BE BOUND BY AND IS BECOMING A PARTY TO
|
||||
* THIS ALFRESCO NETWORK AGREEMENT ("AGREEMENT") AND THAT YOU HAVE THE
|
||||
* AUTHORITY TO BIND COMPANY. IF COMPANY DOES NOT AGREE TO ALL OF THE
|
||||
* TERMS OF THIS AGREEMENT, DO NOT SELECT THE "I UNDERSTAND AND AGREE"
|
||||
* BOX AND DO NOT INSTALL THE SOFTWARE OR VIEW THE SOURCE CODE. COMPANY
|
||||
* HAS NOT BECOME A LICENSEE OF, AND IS NOT AUTHORIZED TO USE THE
|
||||
* SOFTWARE UNLESS AND UNTIL IT HAS AGREED TO BE BOUND BY THESE LICENSE
|
||||
* TERMS. THE "EFFECTIVE DATE" FOR THIS AGREEMENT SHALL BE THE DAY YOU
|
||||
* CHECK THE "I UNDERSTAND AND ACCEPT" BOX.
|
||||
*/
|
||||
|
||||
#ifndef _ByteArray_H
|
||||
#define _ByteArray_H
|
||||
|
||||
// Includes
|
||||
|
||||
#include <memory>
|
||||
#include <string>
|
||||
|
||||
#include "util\Types.h"
|
||||
|
||||
// Classes defined in this header file
|
||||
|
||||
namespace Alfresco {
|
||||
class ByteArray;
|
||||
|
||||
typedef std::auto_ptr<ByteArray> PTR_ByteArray;
|
||||
}
|
||||
|
||||
/**
|
||||
* Byte Array Class
|
||||
*
|
||||
* Provides a byte array object similar to Javas byte[].
|
||||
*/
|
||||
class Alfresco::ByteArray {
|
||||
public:
|
||||
// Constructors
|
||||
|
||||
ByteArray( BUFLEN len = 0, bool clearMem = false);
|
||||
ByteArray( CBUFPTR data, BUFLEN len);
|
||||
ByteArray( const char* data, BUFLEN len);
|
||||
|
||||
// Copy constructor
|
||||
|
||||
ByteArray( const ByteArray& byts);
|
||||
|
||||
// Class destructor
|
||||
|
||||
~ByteArray();
|
||||
|
||||
// Return the data/length
|
||||
|
||||
inline CBUFPTR getData( void) const { return m_data; }
|
||||
inline BUFPTR getData( void) { return m_data; }
|
||||
inline BUFLEN getLength( void) const { return m_length; }
|
||||
|
||||
// Set the array length
|
||||
|
||||
void setLength( BUFLEN len, bool clearMem = false);
|
||||
|
||||
// Set a byte
|
||||
|
||||
void setByte( unsigned int idx, unsigned char val);
|
||||
|
||||
// Subscript operator
|
||||
|
||||
unsigned char& operator[](const unsigned int idx);
|
||||
|
||||
// Assignment operator
|
||||
|
||||
ByteArray& operator=( const ByteArray& byts);
|
||||
ByteArray& operator=( std::string& byts);
|
||||
|
||||
// Equality operator
|
||||
|
||||
bool operator== ( const ByteArray& byts);
|
||||
|
||||
// Return the start address of the byte array
|
||||
|
||||
operator const unsigned char* ( void) { return m_data; }
|
||||
|
||||
protected:
|
||||
// Set the byte array and length
|
||||
|
||||
void setData( CBUFPTR data, BUFLEN len);
|
||||
|
||||
private:
|
||||
// Instance variables
|
||||
//
|
||||
// Byte data and length
|
||||
|
||||
BUFPTR m_data;
|
||||
BUFLEN m_length;
|
||||
};
|
||||
|
||||
#endif
|
157
source/cpp/CAlfrescoApp/includes/util/DataBuffer.h
Normal file
157
source/cpp/CAlfrescoApp/includes/util/DataBuffer.h
Normal file
@@ -0,0 +1,157 @@
|
||||
/*
|
||||
* Copyright (C) 2005 Alfresco, Inc.
|
||||
*
|
||||
* Licensed under the Alfresco Network License. You may obtain a
|
||||
* copy of the License at
|
||||
*
|
||||
* http://www.alfrescosoftware.com/legal/
|
||||
*
|
||||
* Please view the license relevant to your network subscription.
|
||||
*
|
||||
* BY CLICKING THE "I UNDERSTAND AND ACCEPT" BOX, OR INSTALLING,
|
||||
* READING OR USING ALFRESCO'S Network SOFTWARE (THE "SOFTWARE"),
|
||||
* YOU ARE AGREEING ON BEHALF OF THE ENTITY LICENSING THE SOFTWARE
|
||||
* ("COMPANY") THAT COMPANY WILL BE BOUND BY AND IS BECOMING A PARTY TO
|
||||
* THIS ALFRESCO NETWORK AGREEMENT ("AGREEMENT") AND THAT YOU HAVE THE
|
||||
* AUTHORITY TO BIND COMPANY. IF COMPANY DOES NOT AGREE TO ALL OF THE
|
||||
* TERMS OF THIS AGREEMENT, DO NOT SELECT THE "I UNDERSTAND AND AGREE"
|
||||
* BOX AND DO NOT INSTALL THE SOFTWARE OR VIEW THE SOURCE CODE. COMPANY
|
||||
* HAS NOT BECOME A LICENSEE OF, AND IS NOT AUTHORIZED TO USE THE
|
||||
* SOFTWARE UNLESS AND UNTIL IT HAS AGREED TO BE BOUND BY THESE LICENSE
|
||||
* TERMS. THE "EFFECTIVE DATE" FOR THIS AGREEMENT SHALL BE THE DAY YOU
|
||||
* CHECK THE "I UNDERSTAND AND ACCEPT" BOX.
|
||||
*/
|
||||
|
||||
#ifndef _DataBuffer_H
|
||||
#define _DataBuffer_H
|
||||
|
||||
// Includes
|
||||
|
||||
#include "util\DataPacker.h"
|
||||
|
||||
// Classes defined in this header file
|
||||
|
||||
namespace Alfresco {
|
||||
class DataBuffer;
|
||||
typedef std::auto_ptr<DataBuffer> PTR_DataBuffer;
|
||||
}
|
||||
|
||||
// Constants
|
||||
|
||||
namespace Alfresco {
|
||||
|
||||
// Default data buffer size
|
||||
|
||||
#define DataBufferDefaultSize 256
|
||||
}
|
||||
|
||||
/**
|
||||
* Data Buffer Class
|
||||
*
|
||||
* Dynamic buffer for getting/setting data blocks.
|
||||
*/
|
||||
class Alfresco::DataBuffer {
|
||||
public:
|
||||
// Class constructors
|
||||
|
||||
DataBuffer( unsigned int siz = DataBufferDefaultSize);
|
||||
DataBuffer( BUFPTR buf, BUFPOS off, BUFLEN len);
|
||||
|
||||
// Class destructor
|
||||
|
||||
~DataBuffer();
|
||||
|
||||
// Getter methods
|
||||
|
||||
inline BUFPTR getBuffer( void) { return m_buf; }
|
||||
|
||||
BUFLEN getLength( void) const;
|
||||
unsigned int getLengthInWords( void) const;
|
||||
BUFLEN getAvailableLength( void) const;
|
||||
inline BUFLEN getBufferLength(void) const { return m_buflen; }
|
||||
|
||||
inline unsigned int getDisplacement( void) const { return m_pos - m_offset; }
|
||||
inline BUFPOS getOffset( void) { return m_offset; }
|
||||
inline BUFPOS getPosition( void) { return m_pos; }
|
||||
|
||||
// Get data items from the buffer
|
||||
|
||||
unsigned char getByte( void);
|
||||
unsigned int getShort( void);
|
||||
unsigned int getInt( void);
|
||||
LONG64 getLong( void);
|
||||
String getString( bool uni = true);
|
||||
String getString( unsigned int maxLen, bool uni = true);
|
||||
|
||||
unsigned int getShortAt( unsigned int idx);
|
||||
unsigned int getIntAt( unsigned int idx);
|
||||
LONG64 getLongAt( unsigned int idx);
|
||||
|
||||
// Put data items into the buffer
|
||||
|
||||
void putByte( unsigned char byt);
|
||||
void putShort( unsigned int sval);
|
||||
void putInt( unsigned int ival);
|
||||
void putLong( LONG64 lval);
|
||||
|
||||
void putShortAt( unsigned int idx, unsigned int sval);
|
||||
void putIntAt( unsigned int idx, unsigned int ival);
|
||||
void putLongAt( unsigned int idx, LONG64 lval);
|
||||
|
||||
void putString( const String& str, bool uni = true, bool nulTerm = true);
|
||||
void putFixedString( const String& str, unsigned int len);
|
||||
BUFPOS putStringAt( const String& str, BUFPOS pos, bool uni = true, bool nulTerm = true);
|
||||
BUFPOS putFixedStringAt( const String& str, unsigned int len, BUFPOS pos);
|
||||
|
||||
void putStringPointer( unsigned int off);
|
||||
void putZeros( unsigned int cnt);
|
||||
|
||||
// Align the buffer position
|
||||
|
||||
void wordAlign( void);
|
||||
void longwordAlign( void);
|
||||
|
||||
// Append a raw data block to the buffer
|
||||
|
||||
void appendData( BUFPTR buf, BUFPOS off, BUFLEN len);
|
||||
|
||||
// Copy the data to the user buffer and update the read position
|
||||
|
||||
unsigned int copyData( BUFPTR buf, BUFPOS pos, unsigned int cnt);
|
||||
|
||||
// Skip data items in the buffer
|
||||
|
||||
void skipBytes( unsigned int len);
|
||||
|
||||
// Setter methods
|
||||
|
||||
inline void setPosition( BUFPOS pos) { m_pos = pos; }
|
||||
void setEndOfBuffer( void);
|
||||
void setLength( BUFLEN len);
|
||||
|
||||
private:
|
||||
// Extend the buffer
|
||||
|
||||
void extendBuffer( BUFLEN ext);
|
||||
void extendBuffer( void);
|
||||
|
||||
protected:
|
||||
// Instance variables
|
||||
//
|
||||
// Data buffer
|
||||
|
||||
BUFPTR m_buf;
|
||||
unsigned int m_buflen;
|
||||
|
||||
// Flag to indicate if the buffer is owned by this object
|
||||
|
||||
bool m_owner;
|
||||
|
||||
// Buffer positions/offsets
|
||||
|
||||
BUFPOS m_pos;
|
||||
BUFPOS m_endpos;
|
||||
BUFPOS m_offset;
|
||||
};
|
||||
|
||||
#endif
|
93
source/cpp/CAlfrescoApp/includes/util/DataPacker.h
Normal file
93
source/cpp/CAlfrescoApp/includes/util/DataPacker.h
Normal file
@@ -0,0 +1,93 @@
|
||||
/*
|
||||
* Copyright (C) 2005 Alfresco, Inc.
|
||||
*
|
||||
* Licensed under the Alfresco Network License. You may obtain a
|
||||
* copy of the License at
|
||||
*
|
||||
* http://www.alfrescosoftware.com/legal/
|
||||
*
|
||||
* Please view the license relevant to your network subscription.
|
||||
*
|
||||
* BY CLICKING THE "I UNDERSTAND AND ACCEPT" BOX, OR INSTALLING,
|
||||
* READING OR USING ALFRESCO'S Network SOFTWARE (THE "SOFTWARE"),
|
||||
* YOU ARE AGREEING ON BEHALF OF THE ENTITY LICENSING THE SOFTWARE
|
||||
* ("COMPANY") THAT COMPANY WILL BE BOUND BY AND IS BECOMING A PARTY TO
|
||||
* THIS ALFRESCO NETWORK AGREEMENT ("AGREEMENT") AND THAT YOU HAVE THE
|
||||
* AUTHORITY TO BIND COMPANY. IF COMPANY DOES NOT AGREE TO ALL OF THE
|
||||
* TERMS OF THIS AGREEMENT, DO NOT SELECT THE "I UNDERSTAND AND AGREE"
|
||||
* BOX AND DO NOT INSTALL THE SOFTWARE OR VIEW THE SOURCE CODE. COMPANY
|
||||
* HAS NOT BECOME A LICENSEE OF, AND IS NOT AUTHORIZED TO USE THE
|
||||
* SOFTWARE UNLESS AND UNTIL IT HAS AGREED TO BE BOUND BY THESE LICENSE
|
||||
* TERMS. THE "EFFECTIVE DATE" FOR THIS AGREEMENT SHALL BE THE DAY YOU
|
||||
* CHECK THE "I UNDERSTAND AND ACCEPT" BOX.
|
||||
*/
|
||||
|
||||
#ifndef _DataPacker_H
|
||||
#define _DataPacker_H
|
||||
|
||||
// Includes
|
||||
|
||||
#include "util\String.h"
|
||||
#include "util\Types.h"
|
||||
#include "util\JavaTypes.h"
|
||||
|
||||
// Classes defined in this header file
|
||||
|
||||
namespace Alfresco {
|
||||
class DataPacker;
|
||||
}
|
||||
|
||||
/**
|
||||
* DataPacker Class
|
||||
*
|
||||
* The DataPacker class provides methods for packing and unpacking of various data types from a buffer.
|
||||
*/
|
||||
class Alfresco::DataPacker {
|
||||
private:
|
||||
// Hide constructors
|
||||
|
||||
DataPacker( void) {};
|
||||
DataPacker(const DataPacker& dp) {};
|
||||
|
||||
public:
|
||||
// Unpack data types from a buffer
|
||||
|
||||
static int getShort(CBUFPTR buf, BUFPOS pos);
|
||||
static int getInt(CBUFPTR buf, BUFPOS pos);
|
||||
static LONG64 getLong(CBUFPTR buf, BUFPOS pos);
|
||||
|
||||
static int getIntelShort(CBUFPTR buf, BUFPOS pos);
|
||||
static int getIntelInt(CBUFPTR buf, BUFPOS pos);
|
||||
static LONG64 getIntelLong(CBUFPTR buf, BUFPOS pos);
|
||||
|
||||
static String getString(CBUFPTR buf, BUFPOS pos, const unsigned int maxLen, const bool isUni = false);
|
||||
static String getUnicodeString(CBUFPTR buf, BUFPOS pos, const unsigned int maxLen);
|
||||
|
||||
// Pack data types into a buffer
|
||||
|
||||
static void putShort(const int val, BUFPTR buf, BUFPOS pos);
|
||||
static void putInt(const int val, BUFPTR buf, BUFPOS pos);
|
||||
static void putLong(const LONG64 val, BUFPTR buf, BUFPOS pos);
|
||||
|
||||
static void putIntelShort(const int val, BUFPTR buf, BUFPOS pos);
|
||||
static void putIntelInt(const int val, BUFPTR buf, BUFPOS pos);
|
||||
static void putIntelLong(const LONG64 val, BUFPTR buf, BUFPOS pos);
|
||||
|
||||
static unsigned int putString(const String& str, BUFPTR buf, BUFPOS pos, bool nullTerm = true, bool isUni = false);
|
||||
static unsigned int putString(const char* str, BUFLEN len, BUFPTR buf, BUFPOS pos, bool nullTerm = true);
|
||||
static unsigned int putString(const wchar_t* str, BUFLEN len, BUFPTR buf, BUFPOS pos, bool nullTerm = true);
|
||||
|
||||
static void putZeros(BUFPTR buf, BUFPOS pos, const unsigned int count);
|
||||
|
||||
// Calculate buffer positions
|
||||
|
||||
static unsigned int getStringLength(const String& str, const bool isUni = false, const bool nulTerm = false);
|
||||
static unsigned int getBufferPosition(BUFPOS pos, const String& str, const bool isUni = false, const bool nulTerm = false);
|
||||
|
||||
// Align a buffer offset
|
||||
|
||||
static inline BUFPOS longwordAlign( BUFPOS pos) { return ( pos + 3) & 0xFFFFFFFC; }
|
||||
static inline BUFPOS wordAlign( BUFPOS pos) { return ( pos + 1) & 0xFFFFFFFE; }
|
||||
};
|
||||
|
||||
#endif
|
130
source/cpp/CAlfrescoApp/includes/util/Exception.h
Normal file
130
source/cpp/CAlfrescoApp/includes/util/Exception.h
Normal file
@@ -0,0 +1,130 @@
|
||||
/*
|
||||
* Copyright (C) 2005 Alfresco, Inc.
|
||||
*
|
||||
* Licensed under the Alfresco Network License. You may obtain a
|
||||
* copy of the License at
|
||||
*
|
||||
* http://www.alfrescosoftware.com/legal/
|
||||
*
|
||||
* Please view the license relevant to your network subscription.
|
||||
*
|
||||
* BY CLICKING THE "I UNDERSTAND AND ACCEPT" BOX, OR INSTALLING,
|
||||
* READING OR USING ALFRESCO'S Network SOFTWARE (THE "SOFTWARE"),
|
||||
* YOU ARE AGREEING ON BEHALF OF THE ENTITY LICENSING THE SOFTWARE
|
||||
* ("COMPANY") THAT COMPANY WILL BE BOUND BY AND IS BECOMING A PARTY TO
|
||||
* THIS ALFRESCO NETWORK AGREEMENT ("AGREEMENT") AND THAT YOU HAVE THE
|
||||
* AUTHORITY TO BIND COMPANY. IF COMPANY DOES NOT AGREE TO ALL OF THE
|
||||
* TERMS OF THIS AGREEMENT, DO NOT SELECT THE "I UNDERSTAND AND AGREE"
|
||||
* BOX AND DO NOT INSTALL THE SOFTWARE OR VIEW THE SOURCE CODE. COMPANY
|
||||
* HAS NOT BECOME A LICENSEE OF, AND IS NOT AUTHORIZED TO USE THE
|
||||
* SOFTWARE UNLESS AND UNTIL IT HAS AGREED TO BE BOUND BY THESE LICENSE
|
||||
* TERMS. THE "EFFECTIVE DATE" FOR THIS AGREEMENT SHALL BE THE DAY YOU
|
||||
* CHECK THE "I UNDERSTAND AND ACCEPT" BOX.
|
||||
*/
|
||||
|
||||
#ifndef _JavaException_H
|
||||
#define _JavaException_H
|
||||
|
||||
// Includes
|
||||
|
||||
#include "util\String.h"
|
||||
|
||||
// Classes defined in this header file
|
||||
|
||||
namespace Alfresco {
|
||||
class Exception;
|
||||
class IOException;
|
||||
}
|
||||
|
||||
// Macro to check for null and throw a null pointer exception
|
||||
|
||||
#define NULL_POINTER_CHECK(p,m) if(p==NULL) throw NullPointerException(m)
|
||||
|
||||
/**
|
||||
* Java-like Exception Class
|
||||
*
|
||||
* Used as a base class for all Java-like exception classes.
|
||||
*/
|
||||
class Alfresco::Exception {
|
||||
public:
|
||||
// Constructors
|
||||
|
||||
Exception( const wchar_t* msg = NULL, const wchar_t* msg2 = NULL, const wchar_t* msg3 = NULL, const wchar_t* msg4 = NULL, const wchar_t* msg5 = NULL);
|
||||
Exception( const char* moduleName, unsigned int lineNum, const wchar_t* msg = NULL, const wchar_t* msg2 = NULL, const wchar_t* msg3 = NULL, const wchar_t* msg4 = NULL, const wchar_t* msg5 = NULL);
|
||||
|
||||
// Copy constructor
|
||||
|
||||
Exception( const Exception& ex);
|
||||
|
||||
// Class destructor
|
||||
|
||||
~Exception();
|
||||
|
||||
// Return the exception message
|
||||
|
||||
inline const String& getMessage( void) const { return m_msg; }
|
||||
|
||||
// Return the exception as a string
|
||||
|
||||
inline const String& toString( void) const { return m_msg; }
|
||||
|
||||
private:
|
||||
// Instance variables
|
||||
//
|
||||
// Exception message
|
||||
|
||||
String m_msg;
|
||||
};
|
||||
|
||||
// Macros to declare an exception class
|
||||
|
||||
#define DEFINE_EXCEPTION(ns,ex) namespace ns { class ex : public Exception { \
|
||||
public: \
|
||||
ex( const char* modName, unsigned int lineNum, const wchar_t* msg = NULL, const wchar_t* msg2 = NULL, const wchar_t* msg3 = NULL, const wchar_t* msg4 = NULL, const wchar_t* msg5 = NULL); \
|
||||
ex( const wchar_t* msg = NULL, const wchar_t* msg2 = NULL, const wchar_t* msg3 = NULL, const wchar_t* msg4 = NULL, const wchar_t* msg5 = NULL); }; }
|
||||
|
||||
#define DEFINE_IOEXCEPTION(ns,ex) namespace ns { class ex : public IOException { \
|
||||
public: \
|
||||
ex( const char* modName, unsigned int lineNum, const wchar_t* msg = NULL, const wchar_t* msg2 = NULL, const wchar_t* msg3 = NULL, const wchar_t* msg4 = NULL, const wchar_t* msg5 = NULL); \
|
||||
ex( const wchar_t* msg = NULL, const wchar_t* msg2 = NULL, const wchar_t* msg3 = NULL, const wchar_t* msg4 = NULL, const wchar_t* msg5 = NULL); }; }
|
||||
|
||||
// Macros to define new exception class code, should be used in a module not a header
|
||||
|
||||
#define EXCEPTION_CLASS(ns,ex) \
|
||||
ex :: ex( const char* modName, unsigned int lineNum, const wchar_t* msg, const wchar_t* msg2, const wchar_t* msg3, const wchar_t* msg4, const wchar_t* msg5) : \
|
||||
Exception(modName,lineNum,msg,msg2,msg3,msg4,msg5) {} \
|
||||
ex :: ex( const wchar_t* msg, const wchar_t* msg2, const wchar_t* msg3, const wchar_t* msg4, const wchar_t* msg5) : \
|
||||
Exception(msg,msg2,msg3,msg4,msg5) {}
|
||||
|
||||
// Define the IOException class
|
||||
|
||||
DEFINE_EXCEPTION(Alfresco,IOException);
|
||||
|
||||
// Define the macro create new IOException based exceptions
|
||||
|
||||
#define IOEXCEPTION_CLASS(ns,ex) \
|
||||
ex :: ex( const char* modName, unsigned int lineNum, const wchar_t* msg, const wchar_t* msg2, const wchar_t* msg3, const wchar_t* msg4, const wchar_t* msg5) : \
|
||||
IOException(modName,lineNum,msg,msg2,msg3,msg4,msg5) {} \
|
||||
ex :: ex( const wchar_t* msg, const wchar_t* msg2, const wchar_t* msg3, const wchar_t* msg4, const wchar_t* msg5) : \
|
||||
IOException(msg,msg2,msg3,msg4,msg5) {}
|
||||
|
||||
// Define standard exceptions
|
||||
|
||||
DEFINE_EXCEPTION(Alfresco,NullPointerException);
|
||||
DEFINE_EXCEPTION(Alfresco,ArrayIndexOutOfBoundsException);
|
||||
DEFINE_EXCEPTION(Alfresco,NumberFormatException);
|
||||
|
||||
DEFINE_IOEXCEPTION(Alfresco, AccessDeniedException);
|
||||
DEFINE_IOEXCEPTION(Alfresco, DirectoryNotEmptyException);
|
||||
DEFINE_IOEXCEPTION(Alfresco, DiskFullException);
|
||||
DEFINE_IOEXCEPTION(Alfresco, FileExistsException);
|
||||
DEFINE_IOEXCEPTION(Alfresco, FileOfflineException);
|
||||
DEFINE_IOEXCEPTION(Alfresco, FileSharingException);
|
||||
DEFINE_IOEXCEPTION(Alfresco, FileNotFoundException);
|
||||
DEFINE_IOEXCEPTION(Alfresco, PathNotFoundException);
|
||||
DEFINE_IOEXCEPTION(Alfresco, FileLockException);
|
||||
DEFINE_IOEXCEPTION(Alfresco, FileUnlockException);
|
||||
DEFINE_IOEXCEPTION(Alfresco, LockConflictException);
|
||||
DEFINE_IOEXCEPTION(Alfresco, NotLockedException);
|
||||
|
||||
#endif
|
100
source/cpp/CAlfrescoApp/includes/util/FileName.h
Normal file
100
source/cpp/CAlfrescoApp/includes/util/FileName.h
Normal file
@@ -0,0 +1,100 @@
|
||||
/*
|
||||
* Copyright (C) 2005 Alfresco, Inc.
|
||||
*
|
||||
* Licensed under the Alfresco Network License. You may obtain a
|
||||
* copy of the License at
|
||||
*
|
||||
* http://www.alfrescosoftware.com/legal/
|
||||
*
|
||||
* Please view the license relevant to your network subscription.
|
||||
*
|
||||
* BY CLICKING THE "I UNDERSTAND AND ACCEPT" BOX, OR INSTALLING,
|
||||
* READING OR USING ALFRESCO'S Network SOFTWARE (THE "SOFTWARE"),
|
||||
* YOU ARE AGREEING ON BEHALF OF THE ENTITY LICENSING THE SOFTWARE
|
||||
* ("COMPANY") THAT COMPANY WILL BE BOUND BY AND IS BECOMING A PARTY TO
|
||||
* THIS ALFRESCO NETWORK AGREEMENT ("AGREEMENT") AND THAT YOU HAVE THE
|
||||
* AUTHORITY TO BIND COMPANY. IF COMPANY DOES NOT AGREE TO ALL OF THE
|
||||
* TERMS OF THIS AGREEMENT, DO NOT SELECT THE "I UNDERSTAND AND AGREE"
|
||||
* BOX AND DO NOT INSTALL THE SOFTWARE OR VIEW THE SOURCE CODE. COMPANY
|
||||
* HAS NOT BECOME A LICENSEE OF, AND IS NOT AUTHORIZED TO USE THE
|
||||
* SOFTWARE UNLESS AND UNTIL IT HAS AGREED TO BE BOUND BY THESE LICENSE
|
||||
* TERMS. THE "EFFECTIVE DATE" FOR THIS AGREEMENT SHALL BE THE DAY YOU
|
||||
* CHECK THE "I UNDERSTAND AND ACCEPT" BOX.
|
||||
*/
|
||||
|
||||
#ifndef _FileName_H
|
||||
#define _FileName_H
|
||||
|
||||
// Includes
|
||||
|
||||
#include "util\String.h"
|
||||
|
||||
// Classes defined in this header file
|
||||
|
||||
namespace Alfresco {
|
||||
class FileName;
|
||||
}
|
||||
|
||||
/**
|
||||
* File Naming Utility Class
|
||||
*
|
||||
* Contains various utility methods for building and splitting file paths.
|
||||
*/
|
||||
class Alfresco::FileName {
|
||||
public:
|
||||
// Build a path using the specified components
|
||||
|
||||
static const String buildPath( const String& dev, const String& path, const String& fileName, wchar_t sep = L'\\');
|
||||
|
||||
// Check if a file name contains a stream name
|
||||
|
||||
static bool containsStreamName( const String& fileName);
|
||||
|
||||
// Convert path separator characters
|
||||
|
||||
static const String convertSeperators( const String& path, wchar_t sep);
|
||||
|
||||
// Make a relative path
|
||||
|
||||
static const String makeRelativePath( const String& basePath, const String& fullPath);
|
||||
|
||||
// Map an input path to a real path
|
||||
|
||||
static const String mapPath(const String& base, const String& path);
|
||||
|
||||
// Normalize a path converting all directories to uppercase and keeping the file name as is
|
||||
|
||||
static const String normalizePath(const String& path);
|
||||
|
||||
// Remove the file name from the path
|
||||
|
||||
static const String removeFileName(const String& path);
|
||||
|
||||
// Split the path into all the component directories and filename
|
||||
|
||||
static StringList splitAllPaths(const String& path);
|
||||
|
||||
// Split the path into separate directory path and file name strings
|
||||
|
||||
static StringList splitPath( const String& path, wchar_t sep = L'\\');
|
||||
|
||||
// Split a path string into directory path, file name and stream name components
|
||||
|
||||
static StringList splitPathStream( const String& path);
|
||||
|
||||
public:
|
||||
// Constant values
|
||||
|
||||
static String& DosSeperator;
|
||||
static String& NTFSStreamSeperator;
|
||||
|
||||
static wchar_t DOS_SEPERATOR;
|
||||
|
||||
private:
|
||||
// Hide constructors, static only class
|
||||
|
||||
FileName( void) {};
|
||||
FileName( const FileName& fname) {};
|
||||
};
|
||||
|
||||
#endif
|
67
source/cpp/CAlfrescoApp/includes/util/Integer.h
Normal file
67
source/cpp/CAlfrescoApp/includes/util/Integer.h
Normal file
@@ -0,0 +1,67 @@
|
||||
/*
|
||||
* Copyright (C) 2005 Alfresco, Inc.
|
||||
*
|
||||
* Licensed under the Alfresco Network License. You may obtain a
|
||||
* copy of the License at
|
||||
*
|
||||
* http://www.alfrescosoftware.com/legal/
|
||||
*
|
||||
* Please view the license relevant to your network subscription.
|
||||
*
|
||||
* BY CLICKING THE "I UNDERSTAND AND ACCEPT" BOX, OR INSTALLING,
|
||||
* READING OR USING ALFRESCO'S Network SOFTWARE (THE "SOFTWARE"),
|
||||
* YOU ARE AGREEING ON BEHALF OF THE ENTITY LICENSING THE SOFTWARE
|
||||
* ("COMPANY") THAT COMPANY WILL BE BOUND BY AND IS BECOMING A PARTY TO
|
||||
* THIS ALFRESCO NETWORK AGREEMENT ("AGREEMENT") AND THAT YOU HAVE THE
|
||||
* AUTHORITY TO BIND COMPANY. IF COMPANY DOES NOT AGREE TO ALL OF THE
|
||||
* TERMS OF THIS AGREEMENT, DO NOT SELECT THE "I UNDERSTAND AND AGREE"
|
||||
* BOX AND DO NOT INSTALL THE SOFTWARE OR VIEW THE SOURCE CODE. COMPANY
|
||||
* HAS NOT BECOME A LICENSEE OF, AND IS NOT AUTHORIZED TO USE THE
|
||||
* SOFTWARE UNLESS AND UNTIL IT HAS AGREED TO BE BOUND BY THESE LICENSE
|
||||
* TERMS. THE "EFFECTIVE DATE" FOR THIS AGREEMENT SHALL BE THE DAY YOU
|
||||
* CHECK THE "I UNDERSTAND AND ACCEPT" BOX.
|
||||
*/
|
||||
|
||||
#ifndef _JavaInteger_H
|
||||
#define _JavaInteger_H
|
||||
|
||||
// Includes
|
||||
|
||||
#include "util\String.h"
|
||||
#include "util\Exception.h"
|
||||
#include "util\Types.h"
|
||||
|
||||
// Classes defined in this header file
|
||||
|
||||
namespace Alfresco {
|
||||
class Integer;
|
||||
}
|
||||
|
||||
/**
|
||||
* Java-like Integer Class
|
||||
*
|
||||
* Provides static methods to convert integer values to strings.
|
||||
*/
|
||||
class Alfresco::Integer {
|
||||
public:
|
||||
// Convert an integer to a hexadecimal string
|
||||
|
||||
static String toHexString( const unsigned int ival);
|
||||
static String toHexString( BUFPTR ptr);
|
||||
|
||||
// Convert an integer value to a string
|
||||
|
||||
static String toString( unsigned int ival, unsigned int radix = 10);
|
||||
|
||||
// Parse a string to generate an integer value
|
||||
|
||||
static unsigned int parseInt( const String& str, unsigned int radix = 10);
|
||||
|
||||
private:
|
||||
// Hide constructors, static only class
|
||||
|
||||
Integer( void);
|
||||
Integer(Integer& ival);
|
||||
};
|
||||
|
||||
#endif
|
32
source/cpp/CAlfrescoApp/includes/util/JavaTypes.h
Normal file
32
source/cpp/CAlfrescoApp/includes/util/JavaTypes.h
Normal file
@@ -0,0 +1,32 @@
|
||||
/*
|
||||
* Copyright (C) 2005 Alfresco, Inc.
|
||||
*
|
||||
* Licensed under the Alfresco Network License. You may obtain a
|
||||
* copy of the License at
|
||||
*
|
||||
* http://www.alfrescosoftware.com/legal/
|
||||
*
|
||||
* Please view the license relevant to your network subscription.
|
||||
*
|
||||
* BY CLICKING THE "I UNDERSTAND AND ACCEPT" BOX, OR INSTALLING,
|
||||
* READING OR USING ALFRESCO'S Network SOFTWARE (THE "SOFTWARE"),
|
||||
* YOU ARE AGREEING ON BEHALF OF THE ENTITY LICENSING THE SOFTWARE
|
||||
* ("COMPANY") THAT COMPANY WILL BE BOUND BY AND IS BECOMING A PARTY TO
|
||||
* THIS ALFRESCO NETWORK AGREEMENT ("AGREEMENT") AND THAT YOU HAVE THE
|
||||
* AUTHORITY TO BIND COMPANY. IF COMPANY DOES NOT AGREE TO ALL OF THE
|
||||
* TERMS OF THIS AGREEMENT, DO NOT SELECT THE "I UNDERSTAND AND AGREE"
|
||||
* BOX AND DO NOT INSTALL THE SOFTWARE OR VIEW THE SOURCE CODE. COMPANY
|
||||
* HAS NOT BECOME A LICENSEE OF, AND IS NOT AUTHORIZED TO USE THE
|
||||
* SOFTWARE UNLESS AND UNTIL IT HAS AGREED TO BE BOUND BY THESE LICENSE
|
||||
* TERMS. THE "EFFECTIVE DATE" FOR THIS AGREEMENT SHALL BE THE DAY YOU
|
||||
* CHECK THE "I UNDERSTAND AND ACCEPT" BOX.
|
||||
*/
|
||||
|
||||
#ifndef _JavaTypes_H
|
||||
#define _JavaTypes_H
|
||||
|
||||
// Typedefs for Java primitive types
|
||||
|
||||
typedef __int64 LONG64;
|
||||
|
||||
#endif
|
84
source/cpp/CAlfrescoApp/includes/util/Long.h
Normal file
84
source/cpp/CAlfrescoApp/includes/util/Long.h
Normal file
@@ -0,0 +1,84 @@
|
||||
/*
|
||||
* Copyright (C) 2005 Alfresco, Inc.
|
||||
*
|
||||
* Licensed under the Alfresco Network License. You may obtain a
|
||||
* copy of the License at
|
||||
*
|
||||
* http://www.alfrescosoftware.com/legal/
|
||||
*
|
||||
* Please view the license relevant to your network subscription.
|
||||
*
|
||||
* BY CLICKING THE "I UNDERSTAND AND ACCEPT" BOX, OR INSTALLING,
|
||||
* READING OR USING ALFRESCO'S Network SOFTWARE (THE "SOFTWARE"),
|
||||
* YOU ARE AGREEING ON BEHALF OF THE ENTITY LICENSING THE SOFTWARE
|
||||
* ("COMPANY") THAT COMPANY WILL BE BOUND BY AND IS BECOMING A PARTY TO
|
||||
* THIS ALFRESCO NETWORK AGREEMENT ("AGREEMENT") AND THAT YOU HAVE THE
|
||||
* AUTHORITY TO BIND COMPANY. IF COMPANY DOES NOT AGREE TO ALL OF THE
|
||||
* TERMS OF THIS AGREEMENT, DO NOT SELECT THE "I UNDERSTAND AND AGREE"
|
||||
* BOX AND DO NOT INSTALL THE SOFTWARE OR VIEW THE SOURCE CODE. COMPANY
|
||||
* HAS NOT BECOME A LICENSEE OF, AND IS NOT AUTHORIZED TO USE THE
|
||||
* SOFTWARE UNLESS AND UNTIL IT HAS AGREED TO BE BOUND BY THESE LICENSE
|
||||
* TERMS. THE "EFFECTIVE DATE" FOR THIS AGREEMENT SHALL BE THE DAY YOU
|
||||
* CHECK THE "I UNDERSTAND AND ACCEPT" BOX.
|
||||
*/
|
||||
|
||||
#ifndef _JavaLong_H
|
||||
#define _JavaLong_H
|
||||
|
||||
// Includes
|
||||
|
||||
#include <windows.h>
|
||||
|
||||
#include "util\String.h"
|
||||
#include "util\Exception.h"
|
||||
#include "util\JavaTypes.h"
|
||||
|
||||
// Classes defined in this header file
|
||||
|
||||
namespace Alfresco {
|
||||
class Long;
|
||||
}
|
||||
|
||||
/**
|
||||
* Java-like Long Class
|
||||
*
|
||||
* Provides static methods to convert long/64 bit values to strings.
|
||||
*/
|
||||
class Alfresco::Long {
|
||||
public:
|
||||
// Convert a long/64 bit integer to a hexadecimal string
|
||||
|
||||
static String toHexString( const LONG64 lval);
|
||||
|
||||
// Convert a long/64 bit integer to a decimal string
|
||||
|
||||
static String toString( const LONG64 lval);
|
||||
|
||||
// Make a long/64bit value from the low/high 32bit values
|
||||
|
||||
static LONG64 makeLong( unsigned int lowPart, unsigned int highPart);
|
||||
static LONG64 makeLong( FILETIME fTime);
|
||||
|
||||
// Get the low/high 32bit values from a 64bit value
|
||||
|
||||
static bool hasHighPart( LONG64 lval) { return ( lval > 0xFFFFFFFF) ? true : false; }
|
||||
|
||||
static unsigned int getLowPart( LONG64 lval) { return (unsigned int) lval & 0xFFFFFFFF; }
|
||||
static unsigned int getHighPart( LONG64 lval) { return (unsigned int) ((lval >> 32) & 0xFFFFFFFF); }
|
||||
|
||||
// Parse a string to generate a long/64 bit integer value
|
||||
|
||||
static LONG64 parseLong( const String& str, unsigned int radix = 10);
|
||||
|
||||
// Copy a long/64bit value to a FILETIME structure
|
||||
|
||||
static void copyTo( LONG64 lval, FILETIME& ftime);
|
||||
|
||||
private:
|
||||
// Hide constructors, static only class
|
||||
|
||||
Long( void);
|
||||
Long(Long& ival);
|
||||
};
|
||||
|
||||
#endif
|
268
source/cpp/CAlfrescoApp/includes/util/String.h
Normal file
268
source/cpp/CAlfrescoApp/includes/util/String.h
Normal file
@@ -0,0 +1,268 @@
|
||||
/*
|
||||
* Copyright (C) 2005 Alfresco, Inc.
|
||||
*
|
||||
* Licensed under the Alfresco Network License. You may obtain a
|
||||
* copy of the License at
|
||||
*
|
||||
* http://www.alfrescosoftware.com/legal/
|
||||
*
|
||||
* Please view the license relevant to your network subscription.
|
||||
*
|
||||
* BY CLICKING THE "I UNDERSTAND AND ACCEPT" BOX, OR INSTALLING,
|
||||
* READING OR USING ALFRESCO'S Network SOFTWARE (THE "SOFTWARE"),
|
||||
* YOU ARE AGREEING ON BEHALF OF THE ENTITY LICENSING THE SOFTWARE
|
||||
* ("COMPANY") THAT COMPANY WILL BE BOUND BY AND IS BECOMING A PARTY TO
|
||||
* THIS ALFRESCO NETWORK AGREEMENT ("AGREEMENT") AND THAT YOU HAVE THE
|
||||
* AUTHORITY TO BIND COMPANY. IF COMPANY DOES NOT AGREE TO ALL OF THE
|
||||
* TERMS OF THIS AGREEMENT, DO NOT SELECT THE "I UNDERSTAND AND AGREE"
|
||||
* BOX AND DO NOT INSTALL THE SOFTWARE OR VIEW THE SOURCE CODE. COMPANY
|
||||
* HAS NOT BECOME A LICENSEE OF, AND IS NOT AUTHORIZED TO USE THE
|
||||
* SOFTWARE UNLESS AND UNTIL IT HAS AGREED TO BE BOUND BY THESE LICENSE
|
||||
* TERMS. THE "EFFECTIVE DATE" FOR THIS AGREEMENT SHALL BE THE DAY YOU
|
||||
* CHECK THE "I UNDERSTAND AND ACCEPT" BOX.
|
||||
*/
|
||||
|
||||
#ifndef _JavaString_H
|
||||
#define _JavaString_H
|
||||
|
||||
// Includes
|
||||
|
||||
#include <string>
|
||||
#include <vector>
|
||||
#include <iostream>
|
||||
|
||||
#include "util\ByteArray.h"
|
||||
#include "util\Types.h"
|
||||
|
||||
// Classes defined in this header file
|
||||
|
||||
namespace Alfresco {
|
||||
class String;
|
||||
class StringList;
|
||||
}
|
||||
|
||||
/**
|
||||
* Java-like String Class
|
||||
*/
|
||||
class Alfresco::String {
|
||||
public:
|
||||
// Constructors
|
||||
|
||||
String();
|
||||
String(const unsigned int alloc);
|
||||
String(const char* str);
|
||||
String(const unsigned char* str);
|
||||
String(const char* buf, const unsigned int offset, const unsigned int len);
|
||||
String(const wchar_t* str);
|
||||
String(const wchar_t* buf, const unsigned int offset, const unsigned int len);
|
||||
String(const String& str);
|
||||
String(const std::wstring& str);
|
||||
String(ByteArray& byts);
|
||||
|
||||
// Return the string length
|
||||
|
||||
inline unsigned int length( void) const { return ( unsigned int) m_string.length(); }
|
||||
|
||||
// Check if a string is empty
|
||||
|
||||
inline bool isNull( void) const { return m_string.length() > 0 ? false : true; }
|
||||
inline bool isNotEmpty( void) const { return m_string.length() > 0 ? true : false; }
|
||||
|
||||
// Compare strings for equality
|
||||
|
||||
bool equals(const wchar_t* str) const;
|
||||
bool equals(const String& str) const;
|
||||
|
||||
bool equalsIgnoreCase(const wchar_t* str) const;
|
||||
bool equalsIgnoreCase(const String& str) const;
|
||||
|
||||
// Compare strings
|
||||
|
||||
int compareTo( const String& str) const;
|
||||
int compareTo( const wchar_t* pStr) const;
|
||||
|
||||
// Convert to lowercase/uppercase returning the new string
|
||||
|
||||
String toLowerCase() const;
|
||||
String toUpperCase() const;
|
||||
|
||||
// Search for the occurrence of a character or string
|
||||
|
||||
int indexOf(const wchar_t ch, int startIndex = 0) const;
|
||||
int indexOf(const wchar_t* str, int startIndex = 0) const;
|
||||
int indexOf(const String& str, int startIndex = 0) const;
|
||||
|
||||
// Search for the occurrence of a character or string
|
||||
|
||||
int lastIndexOf(const wchar_t ch, int startIndex = -1) const;
|
||||
int lastIndexOf(const wchar_t* str, int startIndex = -1) const;
|
||||
int lastIndexOf(const String& str, int startIndex = -1) const;
|
||||
|
||||
// Check if the string starts with the specified string
|
||||
|
||||
bool startsWith(const wchar_t* str) const;
|
||||
bool startsWith(const String& str) const;
|
||||
|
||||
bool startsWithIgnoreCase(const wchar_t* str) const;
|
||||
bool startsWithIgnoreCase(const String& str) const;
|
||||
|
||||
// Check if the string ends with the specified string
|
||||
|
||||
bool endsWith(const wchar_t* str) const;
|
||||
bool endsWith(const String& str) const;
|
||||
|
||||
// Replace all occurrences of the specified character in the string
|
||||
|
||||
void replace( wchar_t oldCh, wchar_t newCh);
|
||||
|
||||
// Append character, string, integer values to the string
|
||||
|
||||
void append( wchar_t ch);
|
||||
void append( const char* str);
|
||||
void append( const wchar_t* str);
|
||||
void append( const String& str);
|
||||
void append( const unsigned int ival);
|
||||
void append( const unsigned long lval);
|
||||
void append( const LONG64 l64val);
|
||||
|
||||
// Get the character at the specified position in the string
|
||||
|
||||
inline wchar_t charAt(const unsigned int idx) const { return m_string[idx]; }
|
||||
|
||||
// Set the string length
|
||||
|
||||
inline void setLength( unsigned int len) { m_string.resize( len, 0); }
|
||||
|
||||
// Trim leading and trailing whitespace from the string
|
||||
|
||||
String trim( void) const;
|
||||
|
||||
// Return the substring of this string
|
||||
|
||||
String substring( unsigned int beginIndex) const;
|
||||
String substring( unsigned int beginIndex, unsigned int endIndex) const;
|
||||
|
||||
// Set the allocated capacity for the string by allocating or shrinking the current string buffer
|
||||
|
||||
inline void reserve( const unsigned int capacity = 0) { m_string.reserve( capacity); }
|
||||
|
||||
// Assignment operator
|
||||
|
||||
String& operator=(const wchar_t* str);
|
||||
String& operator=(const String& str);
|
||||
|
||||
// Append operator
|
||||
|
||||
inline String& operator+=(wchar_t ch) { append( ch); return *this; }
|
||||
inline String& operator+=(const char* str) { append( str); return *this; }
|
||||
inline String& operator+=(const wchar_t* str) { append( str); return *this; }
|
||||
inline String& operator+=(const String& str) { append( str); return *this; }
|
||||
inline String& operator+=(const unsigned int ival) { append( ival); return *this; }
|
||||
inline String& operator+=(const unsigned long lval) { append( lval); return *this; }
|
||||
inline String& operator+=(const LONG64 l64val) { append( l64val); return *this; }
|
||||
|
||||
// Equality operator
|
||||
|
||||
bool operator== ( const String& str) const;
|
||||
bool operator== ( const wchar_t* str) const;
|
||||
bool operator== ( const char* str) const;
|
||||
|
||||
// Less than operator
|
||||
|
||||
bool operator< ( const String& str) const;
|
||||
|
||||
// Return the string data
|
||||
|
||||
inline const wchar_t* data() const { return m_string.data(); }
|
||||
|
||||
// Conversion operator
|
||||
|
||||
inline operator const wchar_t* ( void) const { return m_string.data(); }
|
||||
|
||||
// Return the string as an array of bytes
|
||||
|
||||
ByteArray getBytes( ByteArray& byts) const;
|
||||
ByteArray getBytes( void) const;
|
||||
|
||||
// Split the string into tokens using the specified delimiters
|
||||
|
||||
StringList tokenize( const String& delims) const;
|
||||
|
||||
// Streaming operators
|
||||
|
||||
friend std::wostream& operator<<(std::wostream& out, const String& str);
|
||||
friend std::ostream& operator<<(std::ostream& out, const String& str);
|
||||
|
||||
// Access the internal string object
|
||||
|
||||
inline std::wstring getString( void) { return m_string; }
|
||||
inline const std::wstring getString( void) const { return m_string; }
|
||||
|
||||
private:
|
||||
// String data
|
||||
|
||||
std::wstring m_string;
|
||||
};
|
||||
|
||||
/**
|
||||
* String List Class
|
||||
*/
|
||||
class Alfresco::StringList {
|
||||
public:
|
||||
// Class constructor
|
||||
|
||||
StringList( void);
|
||||
StringList( unsigned int reserve);
|
||||
StringList( const StringList& strList);
|
||||
|
||||
// Add a string to the list
|
||||
|
||||
inline void addString( const String& str) { m_list.push_back( str); }
|
||||
|
||||
// Check if the list contains the specified string
|
||||
|
||||
bool containsString( const String& str);
|
||||
bool containsStringCaseless ( const String& str);
|
||||
|
||||
// Return the index of the specified string, or -1 if not found
|
||||
|
||||
int indexOf( const String& str) const;
|
||||
|
||||
// Remove a string from the list
|
||||
|
||||
void removeString( const String& str);
|
||||
void removeStringCaseless( const String& str);
|
||||
|
||||
// Return the number of strings in the list
|
||||
|
||||
inline size_t numberOfStrings( void) const { return m_list.size(); }
|
||||
|
||||
// Return the specified string
|
||||
|
||||
inline const String& getStringAt( unsigned int idx) const { return m_list[idx]; }
|
||||
|
||||
// Assignment operator
|
||||
|
||||
inline String& operator[] ( const unsigned int idx) { return m_list[idx]; }
|
||||
|
||||
// Remove all strings from the list
|
||||
|
||||
inline void removeAllStrings( void) { m_list.clear(); }
|
||||
|
||||
// Copy the string list
|
||||
|
||||
void copyFrom( const StringList& strList);
|
||||
|
||||
// Return the string list as a comma separated list
|
||||
|
||||
String toString( void) const;
|
||||
|
||||
private:
|
||||
// Instance variables
|
||||
//
|
||||
// List of strings
|
||||
|
||||
std::vector<String> m_list;
|
||||
};
|
||||
|
||||
#endif
|
55
source/cpp/CAlfrescoApp/includes/util/System.h
Normal file
55
source/cpp/CAlfrescoApp/includes/util/System.h
Normal file
@@ -0,0 +1,55 @@
|
||||
/*
|
||||
* Copyright (C) 2005 Alfresco, Inc.
|
||||
*
|
||||
* Licensed under the Alfresco Network License. You may obtain a
|
||||
* copy of the License at
|
||||
*
|
||||
* http://www.alfrescosoftware.com/legal/
|
||||
*
|
||||
* Please view the license relevant to your network subscription.
|
||||
*
|
||||
* BY CLICKING THE "I UNDERSTAND AND ACCEPT" BOX, OR INSTALLING,
|
||||
* READING OR USING ALFRESCO'S Network SOFTWARE (THE "SOFTWARE"),
|
||||
* YOU ARE AGREEING ON BEHALF OF THE ENTITY LICENSING THE SOFTWARE
|
||||
* ("COMPANY") THAT COMPANY WILL BE BOUND BY AND IS BECOMING A PARTY TO
|
||||
* THIS ALFRESCO NETWORK AGREEMENT ("AGREEMENT") AND THAT YOU HAVE THE
|
||||
* AUTHORITY TO BIND COMPANY. IF COMPANY DOES NOT AGREE TO ALL OF THE
|
||||
* TERMS OF THIS AGREEMENT, DO NOT SELECT THE "I UNDERSTAND AND AGREE"
|
||||
* BOX AND DO NOT INSTALL THE SOFTWARE OR VIEW THE SOURCE CODE. COMPANY
|
||||
* HAS NOT BECOME A LICENSEE OF, AND IS NOT AUTHORIZED TO USE THE
|
||||
* SOFTWARE UNLESS AND UNTIL IT HAS AGREED TO BE BOUND BY THESE LICENSE
|
||||
* TERMS. THE "EFFECTIVE DATE" FOR THIS AGREEMENT SHALL BE THE DAY YOU
|
||||
* CHECK THE "I UNDERSTAND AND ACCEPT" BOX.
|
||||
*/
|
||||
|
||||
#ifndef _JavaSystem_H
|
||||
#define _JavaSystem_H
|
||||
|
||||
// Includes
|
||||
|
||||
#include "util\Types.h"
|
||||
|
||||
// Classes defined in this header file
|
||||
|
||||
namespace Alfresco {
|
||||
class System;
|
||||
}
|
||||
|
||||
/**
|
||||
* Java-like System Class
|
||||
*/
|
||||
class Alfresco::System {
|
||||
public:
|
||||
|
||||
// Get the current system time in milliseconds
|
||||
|
||||
static DATETIME currentTimeMillis( void);
|
||||
|
||||
private:
|
||||
// Hide constructors, static only class
|
||||
|
||||
System( void) {};
|
||||
System ( const System& sys) {};
|
||||
};
|
||||
|
||||
#endif
|
57
source/cpp/CAlfrescoApp/includes/util/Types.h
Normal file
57
source/cpp/CAlfrescoApp/includes/util/Types.h
Normal file
@@ -0,0 +1,57 @@
|
||||
/*
|
||||
* Copyright (C) 2005 Alfresco, Inc.
|
||||
*
|
||||
* Licensed under the Alfresco Network License. You may obtain a
|
||||
* copy of the License at
|
||||
*
|
||||
* http://www.alfrescosoftware.com/legal/
|
||||
*
|
||||
* Please view the license relevant to your network subscription.
|
||||
*
|
||||
* BY CLICKING THE "I UNDERSTAND AND ACCEPT" BOX, OR INSTALLING,
|
||||
* READING OR USING ALFRESCO'S Network SOFTWARE (THE "SOFTWARE"),
|
||||
* YOU ARE AGREEING ON BEHALF OF THE ENTITY LICENSING THE SOFTWARE
|
||||
* ("COMPANY") THAT COMPANY WILL BE BOUND BY AND IS BECOMING A PARTY TO
|
||||
* THIS ALFRESCO NETWORK AGREEMENT ("AGREEMENT") AND THAT YOU HAVE THE
|
||||
* AUTHORITY TO BIND COMPANY. IF COMPANY DOES NOT AGREE TO ALL OF THE
|
||||
* TERMS OF THIS AGREEMENT, DO NOT SELECT THE "I UNDERSTAND AND AGREE"
|
||||
* BOX AND DO NOT INSTALL THE SOFTWARE OR VIEW THE SOURCE CODE. COMPANY
|
||||
* HAS NOT BECOME A LICENSEE OF, AND IS NOT AUTHORIZED TO USE THE
|
||||
* SOFTWARE UNLESS AND UNTIL IT HAS AGREED TO BE BOUND BY THESE LICENSE
|
||||
* TERMS. THE "EFFECTIVE DATE" FOR THIS AGREEMENT SHALL BE THE DAY YOU
|
||||
* CHECK THE "I UNDERSTAND AND ACCEPT" BOX.
|
||||
*/
|
||||
|
||||
#ifndef _AlfrescoTypes_H
|
||||
#define _AlfrescoTypes_H
|
||||
|
||||
// Includes
|
||||
|
||||
#include "util\JavaTypes.h"
|
||||
|
||||
namespace Alfresco {
|
||||
|
||||
// Type definitions
|
||||
//
|
||||
// Data buffer pointer, position and length
|
||||
|
||||
typedef unsigned char* BUFPTR;
|
||||
typedef unsigned int BUFPOS;
|
||||
typedef unsigned int BUFLEN;
|
||||
|
||||
typedef const unsigned char* CBUFPTR;
|
||||
typedef const unsigned int CBUFPOS;
|
||||
typedef const unsigned int CBUFLEN;
|
||||
|
||||
// File position and length
|
||||
|
||||
typedef LONG64 FILEPOS;
|
||||
typedef LONG64 FILELEN;
|
||||
|
||||
// Date/time
|
||||
|
||||
typedef LONG64 DATETIME;
|
||||
#define NULL_DATETIME ((DATETIME) 0)
|
||||
}
|
||||
|
||||
#endif
|
Reference in New Issue
Block a user