fs_basictypes.h
Go to the documentation of this file.
1 
16 #ifndef FS_BASIC_TYPES_H_
17 #define FS_BASIC_TYPES_H_
18 
19 #include <cstddef>
20 #include <fstream>
21 #include <iostream>
22 #include <string>
23 #include <memory>
24 #include <vector>
25 #include <exception>
26 #include <cmath>
27 #include <cfloat>
28 #include <stdlib.h>
29 #include <string.h>
30 
31 #include "common/fxcrt/fx_basic.h"
34 
35 #if defined(_WIN32) || defined(_WIN64)
36 #include <Windows.h>
37 #endif // defined(_WIN32) || defined(_WIN64)
38 
39 #define FSDK_DEFINE_ARRAY(ArrayName, Type) \
40 class ArrayName : public Object { \
41  public: \
42 \
43  ArrayName(); \
44 \
45  ~ArrayName(); \
46 \
47  ArrayName(const ArrayName&); \
48 \
53  ArrayName& operator = (const ArrayName& other); \
54 \
58  size_t GetSize() const; \
59 \
64  Type GetAt(size_t index) const; \
65 \
70  Type& operator[](size_t index) const; \
71 \
76  void Add(Type element); \
77 \
83  void RemoveAt(size_t index); \
84 \
91  void InsertAt(size_t index, Type element); \
92 \
96  void RemoveAll(); \
97  \
98  private: \
99  void* data_; \
100 };
101 
102 namespace std {
103 class exception;
104 }
105 
113 inline CFX_ByteString FX_UTF8Encode(const wchar_t* wstr) {
115 }
116 
125 inline bool operator==(const char* str1, const CFX_ByteString& str2) {
126  return str2.Equal(str1);
127 }
128 
137 inline bool operator!=(const char* str1, const CFX_ByteString& str2) {
138  return !str2.Equal(str1);
139 }
140 
149 inline std::ostream& operator<<(std::ostream& os, const CFX_ByteString& str) {
150  return os << (const char*) str;
151 }
152 
161 inline std::wostream& operator<<(std::wostream& os, const CFX_WideString& str) {
162  return os << (const wchar_t*) str;
163 }
164 
165 #if !defined(_SWIG_ANDROID_) && !defined(_SWIG_IOS_) && !defined(_SWIG_JAVA_)
166 #ifndef TRUE
167 
168 #define TRUE true
169 #endif
170 
171 #ifndef FALSE
172 
173 #define FALSE false
174 #endif
175 
176 #ifndef NULL
177 
178 #define NULL ((void*)0)
179 #endif
180 #endif
181 
187 namespace foxit {
189 typedef FX_INT64 int64;
191 typedef FX_UINT64 uint64;
193 typedef FX_INT32 int32;
197 typedef FX_INT16 int16;
201 typedef FX_INT8 int8;
203 typedef FX_UINT8 uint8;
209 typedef uint32 ARGB;
211 typedef uint32 RGB;
213 typedef void* FS_HANDLE;
214 
216 typedef CFX_Object Object;
221 
223 FSDK_DEFINE_ARRAY(WStringArray, WString)
225 FSDK_DEFINE_ARRAY(StringArray, String)
226 
227 #if !defined(_SWIG_ANDROID_) && !defined(_SWIG_JAVA_)
228 
233 typedef enum _ErrorCode {
323 } ErrorCode;
324 
325 #endif
326 
331 
333 class Base : public Object {
334  public:
340  FS_HANDLE Handle() const {
341  return handle_;
342  }
343  virtual ~Base(){}
344 
345  protected:
346  explicit Base(FS_HANDLE handle = NULL) : handle_(handle) {}
347  FS_HANDLE handle_;
348 };
349 
355 typedef PointF Offset;
359 typedef FX_RECT RectI;
364 
366 class DateTime : public Object {
367  public:
373  static DateTime GetUTCTime();
379  static DateTime GetLocalTime();
380 
401  : year(year)
402  , month(month)
403  , day(day)
404  , hour(hour)
405  , minute(minute)
406  , second(second)
410 
413  : year(0)
414  , month(0)
415  , day(0)
416  , hour(0)
417  , minute(0)
418  , second(0)
419  , milliseconds(0)
420  , utc_hour_offset(0)
421  , utc_minute_offset(0) {}
427  explicit DateTime(const FXCRT_DATETIMEZONE& time);
433  DateTime(const DateTime& dt)
434  : year(dt.year)
435  , month(dt.month)
436  , day(dt.day)
437  , hour(dt.hour)
438  , minute(dt.minute)
439  , second(dt.second)
443 
452  year = dt.year;
453  month = dt.month;
454  day = dt.day;
455  hour = dt.hour;
456  minute = dt.minute;
457  second = dt.second;
461  return *this;
462  }
464  operator FXCRT_DATETIMEZONE() const;
465 
466 #if (defined(_WIN32) || defined(_WIN64)) && !defined(SWIG)
467 
472  explicit DateTime(const SYSTEMTIME& systime)
473  : year(systime.wYear)
474  , month(systime.wMonth)
475  , day(systime.wDay)
476  , hour(systime.wHour)
477  , minute(systime.wMinute)
478  , second(systime.wSecond)
479  , milliseconds(systime.wMilliseconds)
480  , utc_hour_offset(0)
481  , utc_minute_offset(0) {}
482 
484  operator SYSTEMTIME() const;
485 #endif // defined(_WIN32) || defined(_WIN64)
486 
509  this->year = year;
510  this->month = month;
511  this->day = day;
512  this->hour = hour;
513  this->minute = minute;
514  this->second = second;
515  this->milliseconds = milliseconds;
516  this->utc_hour_offset = utc_hour_offset;
517  this->utc_minute_offset = utc_minute_offset;
518  }
519 
527  bool IsValid() const;
528 
536  bool operator == (const DateTime& datetime) const;
544  bool operator != (const DateTime& datetime) const;
552  bool operator > (const DateTime& datetime) const;
562  bool operator >= (const DateTime& datetime) const;
570  bool operator < (const DateTime& datetime) const;
581  bool operator <= (const DateTime& datetime) const;
582 
589 
595  DateTime& ToUTCTime();
596 
622 };
623 
624 //#if !defined(_SWIG_ANDROID_) && !defined(_SWIG_IOS_)
625 
627 class Exception : public std::exception, public Object {
628  public:
639  Exception(const char* file_name, int line_number, const char* function_name, ErrorCode error_code);
640 
646  Exception(const Exception& exception)
647  : error_code_(exception.error_code_)
648  , error_message_(exception.error_message_)
649  , name_(exception.name_) {}
650 
658  Exception& operator = (const Exception& exception) {
659  error_code_ = exception.error_code_;
660  error_message_ = exception.error_message_;
661  return *this;
662  }
663 
665  ~Exception() throw() {}
666 
673  return error_code_;
674  }
675 
681  String GetMessage() const {
682  return error_message_;
683  }
684 
690  String GetName() const { return name_; }
691 
692  private:
693  ErrorCode error_code_;
694  String error_message_;
695  String name_;
696 };
697 
698 #define throw(Exception)
699 //#endif // !defined(_SWIG_ANDROID_) && !defined(_SWIG_IOS_)
700 
701 /*#if defined(SWIG) || defined(_MOBILE_PLATFORM_)
702 #undef
703 #define
704 #endif *///defined(SWIG) || defined(_MOBILE_PLATFORM_)
705 
706 #ifndef override
707 #define override
708 #endif //override
709 
710 #if __cpluscplus >= 201103L || (defined(_MSC_VER) && _MSC_VER >= 1700)
711 #define FS_FINAL final
712 #else
713 #define FS_FINAL
714 #endif
715 
716 #if __cpluscplus >= 201103L || (defined(_MSC_VER) && _MSC_VER >= 1600)
717 #define FS_OVERRIDE override
718 #else
719 #define FS_OVERRIDE
720 #endif
721 
722 } // namespace foxit
723 #endif
DateTime & operator=(const DateTime &dt)
Assign operator.
Definition: fs_basictypes.h:451
Invalid or incorrect state.
Definition: fs_basictypes.h:286
ErrorCode GetErrCode() const
Get the error code.
Definition: fs_basictypes.h:672
int16 utc_hour_offset
Hour of time zone. Valid range: from -12 to 12.
Definition: fs_basictypes.h:619
String GetMessage() const
Get the error message string.
Definition: fs_basictypes.h:681
Invalid password. Usually, this error may occur when loading a PDF document with password. When meet this, user should load document again with correct password.
Definition: fs_basictypes.h:244
DateTime & ToLocalTime()
Convert current object to local time.
(For ConnectedPDF only) Cannot set the ACL to ConnectedPDF server.
Definition: fs_basictypes.h:304
(For ConnectedPDF only) Cannot get client ID from ConnectedPDF server.
Definition: fs_basictypes.h:316
PointF Offset
Offset information, in float.
Definition: fs_basictypes.h:355
Format is invalid. For files, this may also mean that file is corrupted.
Definition: fs_basictypes.h:239
CFX_Object Object
Object type.
Definition: fs_basictypes.h:216
DateTime(const DateTime &dt)
Constructor, with another DateTime.
Definition: fs_basictypes.h:433
uint16 minute
Minute. Valid range: from 0 to 59.
Definition: fs_basictypes.h:606
void Set(uint16 year, uint16 month, uint16 day, uint16 hour, uint16 minute, uint16 second, uint16 milliseconds, int16 utc_hour_offset, uint16 utc_minute_offset)
Set value.
Definition: fs_basictypes.h:506
FX_DWORD FX_UINT32
unsigned 32bits integer.
Definition: fx_system.h:744
Data of current object is invalid.
Definition: fs_basictypes.h:280
wchar_t const * FX_LPCWSTR
Pointer to constant Unicode characters.
Definition: fx_system.h:712
bool operator!=(const DateTime &datetime) const
Not equal operator.
FX_UINT8 uint8
8-bit unsigned integer.
Definition: fs_basictypes.h:203
Definition: fs_basictypes.h:223
Definition: fs_basictypes.h:366
bool operator<(const DateTime &datetime) const
Smaller operator.
uint16 hour
Hour. Valid range: from 0 to 23.
Definition: fs_basictypes.h:604
DateTime(uint16 year, uint16 month, uint16 day, uint16 hour, uint16 minute, uint16 second, uint16 milliseconds, int16 utc_hour_offset, uint16 utc_minute_offset)
Constructor, with parameters.
Definition: fs_basictypes.h:398
uint32 RGB
RGB color type, 24 bits, ((b) | ((g) << 8) | ((r) << 16)))
Definition: fs_basictypes.h:211
uint16 milliseconds
Millisecond. Valid range: from 0 to 999. PDF standard does not support now, this can be omitted if it...
Definition: fs_basictypes.h:613
(For ConnectedPDF only) The input ConnectedPDF DRM wrapper document is invalid.
Definition: fs_basictypes.h:314
uint16 year
Year. It should be a four-digit number, such as 2014.
Definition: fs_basictypes.h:598
File cannot be found or could not be opened.
Definition: fs_basictypes.h:237
(For ConnectedPDF only) Cannot connect to ConnectedPDF server.
Definition: fs_basictypes.h:290
uint16 month
Month. Valid range: from 1 to 12.
Definition: fs_basictypes.h:600
Error handle.
Definition: fs_basictypes.h:246
Definition: fs_basictypes.h:102
PDF document is encrypted by some unsupported security handler.
Definition: fs_basictypes.h:263
Exception & operator=(const Exception &exception)
Assign operator.
Definition: fs_basictypes.h:658
WIDE STRING CLASS.
Definition: fx_string.h:1463
std::ostream & operator<<(std::ostream &os, const CFX_ByteString &str)
Output byte string to std::osstream.
Definition: fs_basictypes.h:149
CFX_WideString WString
Wide string.
Definition: fs_basictypes.h:218
void * FX_POSITION
A value used to denote the position of an element in a collection.
Definition: fx_system.h:637
(For ConnectedPDF only) Current user has no right to open the ConnectedPDF DRM document.
Definition: fs_basictypes.h:294
FX_UINT64 uint64
Unsigned 64-bit integer.
Definition: fs_basictypes.h:191
(For ConnectedPDF only) The loaded document is not a ConnectedPDF DRM document.
Definition: fs_basictypes.h:288
(For ConnectedPDF only) Cannot get user token from ConnectedPDF server.
Definition: fs_basictypes.h:318
bool operator==(const DateTime &datetime) const
Equal operator.
uint16 day
Day of month. Valid range: from 1 to 31.
Definition: fs_basictypes.h:602
Structure for date and time.
Definition: fx_process.h:95
Definition: fs_basictypes.h:627
Parameter error: value of any input parameter for a function is invalid.
Definition: fs_basictypes.h:257
static DateTime GetUTCTime()
Get UTC time.
Current object has not been loaded yet.
Definition: fs_basictypes.h:284
Invalid license is used to initialize Foxit PDF SDK library.
Definition: fs_basictypes.h:255
int FX_INT32
32-bit signed integer.
Definition: fx_system.h:662
(For ConnectedPDF only) Cannot remove the security from ConnectedPDF server.
Definition: fs_basictypes.h:300
int FX_STRSIZE
String size is limited to 2^31-1.
Definition: fx_string.h:35
FS_HANDLE Handle() const
Get the handle of current object.
Definition: fs_basictypes.h:340
(For ConnectedPDF only) Input ACL is invalid.
Definition: fs_basictypes.h:320
bool operator==(const char *str1, const CFX_ByteString &str2)
Check if two byte strings are equal.
Definition: fs_basictypes.h:125
The type of input object or current object is invalid.
Definition: fs_basictypes.h:269
(For ConnectedPDF only) Cannot upload ConnectedPDF DRM document info to ConnectedPDF server...
Definition: fs_basictypes.h:312
Data is not ready. Usually this is used as an exception error code when loading document in asynchron...
Definition: fs_basictypes.h:278
Content has not been parsed yet. Usually, this represents PDF page has not been parsed yet...
Definition: fs_basictypes.h:265
Certificate error: PDF document is encrypted by digital certificate but current user does not have th...
Definition: fs_basictypes.h:251
CFX_FloatRect RectF
Rectangle, in float.
Definition: fs_basictypes.h:357
uint32 ARGB
ARGB color type, 32 bits, ((b) | ((g) << 8) | ((r) << 16)) | ((a) << 24)
Definition: fs_basictypes.h:209
#define FXSYS_wcslen
Get the length of a wide-character string.
Definition: fx_system.h:1003
ErrorCode
Enumeration for error code.
Definition: fs_basictypes.h:233
CFX_ByteString FX_UTF8Encode(const wchar_t *wstr)
Convert wide string to UTF-8 encoding byte string.
Definition: fs_basictypes.h:113
signed char FX_INT8
Signed 8bits integer.
Definition: fx_system.h:640
bool operator>(const DateTime &datetime) const
Greater operator.
bool operator>=(const DateTime &datetime) const
Greater or equal operator.
CFX_PointF PointF
Point information, in float.
Definition: fs_basictypes.h:353
(For ConnectedPDF only) Loaded document is already a ConnectedPDF document.
Definition: fs_basictypes.h:306
CFX_ArrayTemplate< int32 > Int32Array
An array of integer values.
Definition: fs_basictypes.h:330
(For ConnectedPDF only) Loaded document is already a ConnectedPDF DRM document.
Definition: fs_basictypes.h:308
Any unknown state occurs.
Definition: fs_basictypes.h:273
(For ConnectedPDF only) Current device is limited to open the ConnectedPDF DRM document.
Definition: fs_basictypes.h:298
bool operator<=(const DateTime &datetime) const
Smaller or equal operator.
FX_POSITION POSITION
A value used to denote the position of an element in a collection.
Definition: fs_basictypes.h:205
Exception(const char *file_name, int line_number, const char *function_name, ErrorCode error_code)
Constructor, with parameters.
FX_INT64 int64
Signed 64-bit integer.
Definition: fs_basictypes.h:189
FX_UINT32 uint32
32-bit unsigned integer.
Definition: fs_basictypes.h:195
void * FS_HANDLE
Handle type.
Definition: fs_basictypes.h:213
CFX_ByteString String
Byte string.
Definition: fs_basictypes.h:220
FX_INT64 FILESIZE
File size. Support large file directly.
Definition: fs_basictypes.h:207
Header file for Process & thread related definitions and classes.
(For ConnectedPDF only) Input client ID is invalid.
Definition: fs_basictypes.h:322
FX_INT8 int8
8-bit signed integer.
Definition: fs_basictypes.h:201
unsigned short FX_UINT16
Unsigned 16bits integer.
Definition: fx_system.h:652
Definition: fx_coordinates.h:458
CFX_Matrix Matrix
Matrix information, in float.
Definition: fs_basictypes.h:351
DateTime()
Constructor.
Definition: fs_basictypes.h:412
unsigned char FX_UINT8
Unsigned 8bits integer.
Definition: fx_system.h:642
FX_INT32 int32
32-bit signed integer.
Definition: fs_basictypes.h:193
New data conflicts with existed data.
Definition: fs_basictypes.h:271
Definition: fs_basictypes.h:333
(For ConnectedPDF only) Cannot upload ConnectedPDF document info to ConnectedPDF server.
Definition: fs_basictypes.h:310
Definition: fs_basictypes.h:225
String GetName() const
Get the string of error code.
Definition: fs_basictypes.h:690
uint16 second
Second. Valid range: from 0 to 60. 60 for leap second.
Definition: fs_basictypes.h:608
uint16 utc_minute_offset
Minute of time zone. Valid range: from 0 to 59.
Definition: fs_basictypes.h:621
FX_INT16 int16
16-bit signed integer.
Definition: fs_basictypes.h:197
Foxit namespace.
Definition: fs_connectedpdf.h:26
XFA loading error.
Definition: fs_basictypes.h:282
short FX_INT16
Signed 16bits integer.
Definition: fx_system.h:650
(For ConnectedPDF only) Cannot get the ACL from ConnectedPDF server.
Definition: fs_basictypes.h:302
Exception(const Exception &exception)
Constructor, with another Exception object.
Definition: fs_basictypes.h:646
BYTE STRING CLASS.
Definition: fx_string.h:317
FX_UINT16 uint16
16-bit unsigned integer.
Definition: fs_basictypes.h:199
CFX_PSVTemplate< FX_FLOAT > CFX_PointF
Type definition for point class for float.
Definition: fx_coordinates.h:78
Header file for basic data class.
static DateTime GetLocalTime()
Get local time.
#define NULL
The null-pointer value.
Definition: fx_system.h:767
bool operator!=(const char *str1, const CFX_ByteString &str2)
Check if two byte strings are not equal.
Definition: fs_basictypes.h:137
CFX_ArrayTemplate< PointF > PointFArray
An array of PointF objects.
Definition: fs_basictypes.h:363
Definition: fx_coordinates.h:914
Success, and no error occurs.
Definition: fs_basictypes.h:235
CFX_ArrayTemplate< RectF > RectFArray
An array of RectF objects.
Definition: fs_basictypes.h:361
bool Equal(FX_BSTR str) const
Check if current string is equal to another one. Case-sensitive.
Any unknown error occurs.
Definition: fs_basictypes.h:253
#define FX_FILESIZE
Support large file directly.
Definition: fx_stream.h:138
Expected data or object is not found.
Definition: fs_basictypes.h:267
Header file for coordinate system.
(For ConnectedPDF only) Input user token is invalid.
Definition: fs_basictypes.h:292
(For ConnectedPDF only) The rights of Current user has expired.
Definition: fs_basictypes.h:296
~Exception()
Destructor.
Definition: fs_basictypes.h:665
DateTime & ToUTCTime()
Convert current object to UTC time.
Out-of-memory error occurs.
Definition: fs_basictypes.h:261
bool IsValid() const
Check whether current object is valid or not.
CFX_ArrayTemplate< float > FloatArray
An array of float values.
Definition: fs_basictypes.h:328
FX_RECT RectI
Rectangle, in integer.
Definition: fs_basictypes.h:359
Definition: fx_coordinates.h:627
Some types are not supported.
Definition: fs_basictypes.h:259

Foxit Software Corporation Logo
@2018 Foxit Software Incorporated. All rights reserved.