Foxit PDF SDK
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 \
50  ArrayName(const ArrayName& other); \
51 \
56  ArrayName& operator = (const ArrayName& other); \
57 \
61  size_t GetSize() const; \
62 \
67  Type GetAt(size_t index) const; \
68 \
73  Type& operator[](size_t index) const; \
74 \
79  void Add(const Type& element); \
80 \
86  void RemoveAt(size_t index); \
87 \
94  void InsertAt(size_t index, const Type& element); \
95 \
99  void RemoveAll(); \
100  \
101  private: \
102  void* data_; \
103 };
104 
105 namespace std {
106 class exception;
107 }
108 
116 inline CFX_ByteString FX_UTF8Encode(const wchar_t* wstr) {
118 }
119 
128 inline bool operator==(const char* str1, const CFX_ByteString& str2) {
129  return str2.Equal(str1);
130 }
131 
140 inline bool operator!=(const char* str1, const CFX_ByteString& str2) {
141  return !str2.Equal(str1);
142 }
143 
152 inline std::ostream& operator<<(std::ostream& os, const CFX_ByteString& str) {
153  return os << (const char*) str;
154 }
155 
164 inline std::wostream& operator<<(std::wostream& os, const CFX_WideString& str) {
165  return os << (const wchar_t*) str;
166 }
167 
168 #ifndef TRUE
169 
170 #define TRUE true
171 #endif
172 
173 #ifndef FALSE
174 
175 #define FALSE false
176 #endif
177 
178 #ifndef NULL
179 
180 #define NULL ((void*)0)
181 #endif
182 
188 namespace foxit {
190 typedef FX_INT64 int64;
194 typedef FX_INT32 int32;
198 typedef FX_INT16 int16;
202 typedef FX_INT8 int8;
204 typedef FX_UINT8 uint8;
210 typedef uint32 ARGB;
212 typedef uint32 RGB;
214 typedef void* FS_HANDLE;
215 
217 typedef CFX_Object Object;
222 
224 FSDK_DEFINE_ARRAY(WStringArray, WString)
226 FSDK_DEFINE_ARRAY(StringArray, String)
227 
233 typedef enum _ErrorCode {
388 } ErrorCode;
389 
390 
395 
397 class Base : public Object {
398  public:
404  FS_HANDLE Handle() const {
405  return handle_;
406  }
407  virtual ~Base(){}
408 
409  protected:
410  explicit Base(FS_HANDLE handle = NULL) : handle_(handle) {}
411  FS_HANDLE handle_;
412 };
413 
419 typedef PointF Offset;
423 typedef FX_RECT RectI;
428 
430 class DateTime : public Object {
431  public:
437  static DateTime GetUTCTime();
443  static DateTime GetLocalTime();
444 
465  : year(year)
466  , month(month)
467  , day(day)
468  , hour(hour)
469  , minute(minute)
470  , second(second)
474 
477  : year(0)
478  , month(0)
479  , day(0)
480  , hour(0)
481  , minute(0)
482  , second(0)
483  , milliseconds(0)
484  , utc_hour_offset(0)
485  , utc_minute_offset(0) {}
491  explicit DateTime(const FXCRT_DATETIMEZONE& time);
497  DateTime(const DateTime& dt)
498  : year(dt.year)
499  , month(dt.month)
500  , day(dt.day)
501  , hour(dt.hour)
502  , minute(dt.minute)
503  , second(dt.second)
507 
516  year = dt.year;
517  month = dt.month;
518  day = dt.day;
519  hour = dt.hour;
520  minute = dt.minute;
521  second = dt.second;
525  return *this;
526  }
528  operator FXCRT_DATETIMEZONE() const;
529 
530 #if (defined(_WIN32) || defined(_WIN64)) && !defined(SWIG)
531 
536  explicit DateTime(const SYSTEMTIME& systime)
537  : year(systime.wYear)
538  , month(systime.wMonth)
539  , day(systime.wDay)
540  , hour(systime.wHour)
541  , minute(systime.wMinute)
542  , second(systime.wSecond)
543  , milliseconds(systime.wMilliseconds)
544  , utc_hour_offset(0)
545  , utc_minute_offset(0) {}
546 
548  operator SYSTEMTIME() const;
549 #endif // defined(_WIN32) || defined(_WIN64)
550 
573  this->year = year;
574  this->month = month;
575  this->day = day;
576  this->hour = hour;
577  this->minute = minute;
578  this->second = second;
579  this->milliseconds = milliseconds;
580  this->utc_hour_offset = utc_hour_offset;
581  this->utc_minute_offset = utc_minute_offset;
582  }
583 
591  bool IsValid() const;
592 
600  bool operator == (const DateTime& datetime) const;
608  bool operator != (const DateTime& datetime) const;
616  bool operator > (const DateTime& datetime) const;
626  bool operator >= (const DateTime& datetime) const;
634  bool operator < (const DateTime& datetime) const;
645  bool operator <= (const DateTime& datetime) const;
646 
653 
659  DateTime& ToUTCTime();
660 
686 };
687 
688 //#if !defined(_SWIG_ANDROID_) && !defined(_SWIG_IOS_)
689 
691 class Exception : public std::exception , public Object {
692  public:
703  Exception(const char* file_name, int line_number, const char* function_name, ErrorCode error_code);
704 
710  Exception(const Exception& exception)
711  : error_code_(exception.error_code_)
712  , error_message_(exception.error_message_)
713  , name_(exception.name_) {}
714 
722  Exception& operator = (const Exception& exception) {
723  error_code_ = exception.error_code_;
724  error_message_ = exception.error_message_;
725  return *this;
726  }
727 
729  ~Exception() throw() {}
730 
737  return error_code_;
738  }
739 
746  {
747  return error_message_;
748  }
749 
755  String GetName() const
756  { return name_; }
757 
758  private:
759  ErrorCode error_code_;
760  String error_message_;
761  String name_;
762 };
763 
764 #define throw(Exception)
765 //#endif // !defined(_SWIG_ANDROID_) && !defined(_SWIG_IOS_)
766 
767 #if __cpluscplus >= 201103L || (defined(_MSC_VER) && _MSC_VER >= 1700)
768 #define FS_FINAL final
769 #else
770 #define FS_FINAL
771 #endif
772 
773 #if __cpluscplus >= 201103L || (defined(_MSC_VER) && _MSC_VER >= 1600)
774 #define FS_OVERRIDE override
775 #else
776 #define FS_OVERRIDE
777 #endif
778 
779 } // namespace foxit
780 #endif
DateTime & operator=(const DateTime &dt)
Assign operator.
Definition: fs_basictypes.h:515
Invalid or incorrect state.
Definition: fs_basictypes.h:286
ErrorCode GetErrCode() const
Get the error code.
Definition: fs_basictypes.h:736
int16 utc_hour_offset
Hour of time zone. Valid range: from -12 to 12.
Definition: fs_basictypes.h:683
String GetMessage() const
Get the error message string.
Definition: fs_basictypes.h:745
Invalid password. Usually, this error may occur when loading a PDF document with password....
Definition: fs_basictypes.h:244
(For compliance only) Compliance resource file(s) cannot be found or opened. Please check if complian...
Definition: fs_basictypes.h:357
DateTime & ToLocalTime()
Convert current object to local time.
No "Conversion" module right.
Definition: fs_basictypes.h:379
(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:419
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:217
(For compliance only) Invalid unlock code is used to initialize compliance engine.
Definition: fs_basictypes.h:334
DateTime(const DateTime &dt)
Constructor, with another date and time object.
Definition: fs_basictypes.h:497
uint16 minute
Minute. Valid range: from 0 to 59.
Definition: fs_basictypes.h:670
(For compliance only) Fail to initialize compliance engine.
Definition: fs_basictypes.h:336
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:570
(For LTV only) Fail to check DTS.
Definition: fs_basictypes.h:346
No "RMS" module right.
Definition: fs_basictypes.h:369
FX_DWORD FX_UINT32
unsigned 32bits integer.
Definition: fx_system.h:742
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
FX_UINT8 uint8
8-bit unsigned integer.
Definition: fs_basictypes.h:204
Definition: fs_basictypes.h:224
Definition: fs_basictypes.h:430
(For OCR only) Not enough disk space.
Definition: fs_basictypes.h:326
bool operator<(const DateTime &datetime) const
Smaller operator.
File or folder path does not exist.
Definition: fs_basictypes.h:330
uint16 hour
Hour. Valid range: from 0 to 23.
Definition: fs_basictypes.h:668
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:462
uint32 RGB
RGB color type, 24 bits, ((b) | ((g) << 8) | ((r) << 16)))
Definition: fs_basictypes.h:212
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:677
Definition: fx_coordinates.h:30
(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:662
No default server has been set to time stamp server manager yet.
Definition: fs_basictypes.h:359
No "XFA" module right.
Definition: fs_basictypes.h:365
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:664
(For LTV only) Fail to load DSS.
Definition: fs_basictypes.h:348
Error handle.
Definition: fs_basictypes.h:246
PDF document is encrypted by some unsupported security handler.
Definition: fs_basictypes.h:263
No "Compliance" module right.
Definition: fs_basictypes.h:375
Exception & operator=(const Exception &exception)
Assign operator.
Definition: fs_basictypes.h:722
WIDE STRING CLASS.
Definition: fx_string.h:1452
std::ostream & operator<<(std::ostream &os, const CFX_ByteString &str)
Output byte string to std::osstream.
Definition: fs_basictypes.h:152
CFX_WideString WString
Wide string.
Definition: fs_basictypes.h:219
void * FX_POSITION
A value used to denote the position of an element in a collection.
Definition: fx_system.h:636
Cannot use current default time stamp server. Please check if default time stamp server can be used.
Definition: fs_basictypes.h:361
(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:192
(For ConnectedPDF only) The loaded document is not a ConnectedPDF DRM document.
Definition: fs_basictypes.h:288
No "LayoutRecognition" module right.
Definition: fs_basictypes.h:387
(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:666
(For OCR only) OCR engine has not been initialized successfully.
Definition: fs_basictypes.h:324
Structure for date and time.
Definition: fx_process.h:95
Definition: fs_basictypes.h:691
(For Office-to-PDF conversion only) No Microsoft Office is installed in current system.
Definition: fs_basictypes.h:383
No "Optimizer" module right.
Definition: fs_basictypes.h:377
Parameter error: value of any input parameter for a function is invalid.
Definition: fs_basictypes.h:257
__int64 FX_INT64
Signed 64-bit integer.
Definition: fx_system.h:716
static DateTime GetUTCTime()
Get UTC time.
Current object has not been loaded yet.
Definition: fs_basictypes.h:284
No "ConnectedPDF" module right.
Definition: fs_basictypes.h:363
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:661
bool operator >(const DateTime &datetime) const
Greater operator.
(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:404
(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:128
(For Office-to-PDF conversion only) Office COM has not been initialized successfully.
Definition: fs_basictypes.h:381
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:421
uint32 ARGB
ARGB color type, 32 bits, ((b) | ((g) << 8) | ((r) << 16)) | ((a) << 24)
Definition: fs_basictypes.h:210
#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:116
signed char FX_INT8
Signed 8bits integer.
Definition: fx_system.h:639
CFX_PointF PointF
Point information, in float.
Definition: fs_basictypes.h:417
(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:394
(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.
Time stamp server manager has not been initialized successfully.
Definition: fs_basictypes.h:338
bool operator >=(const DateTime &datetime) const
Greater or equal operator.
No "OCR" module right.
Definition: fs_basictypes.h:371
FX_POSITION POSITION
A value used to denote the position of an element in a collection.
Definition: fs_basictypes.h:206
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:190
FX_UINT32 uint32
32-bit unsigned integer.
Definition: fs_basictypes.h:196
(For compliance only) Compliance engine has not been initialized successfully.
Definition: fs_basictypes.h:332
void * FS_HANDLE
Handle type.
Definition: fs_basictypes.h:214
CFX_ByteString String
Byte string.
Definition: fs_basictypes.h:221
(For LTV only) LTV verify mode has not been set.
Definition: fs_basictypes.h:340
FX_INT64 FILESIZE
File size. Support large file directly.
Definition: fs_basictypes.h:208
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:202
unsigned short FX_UINT16
Unsigned 16bits integer.
Definition: fx_system.h:651
(For OCR only) The trial for OCR module is end.
Definition: fs_basictypes.h:328
(For signature only) The signature being operated needs to be signed.
Definition: fs_basictypes.h:352
Definition: fx_coordinates.h:596
CFX_Matrix Matrix
Matrix information, in float.
Definition: fs_basictypes.h:415
DateTime()
Constructor.
Definition: fs_basictypes.h:476
unsigned char FX_UINT8
Unsigned 8bits integer.
Definition: fx_system.h:641
FX_INT32 int32
32-bit signed integer.
Definition: fs_basictypes.h:194
New data conflicts with existed data.
Definition: fs_basictypes.h:271
Definition: fs_basictypes.h:397
(For ConnectedPDF only) Cannot upload ConnectedPDF document info to ConnectedPDF server.
Definition: fs_basictypes.h:310
Definition: fs_basictypes.h:226
String GetName() const
Get the string of error code.
Definition: fs_basictypes.h:755
bool operator !=(const DateTime &datetime) const
Not equal operator.
uint16 second
Second. Valid range: from 0 to 60. 60 for leap second.
Definition: fs_basictypes.h:672
uint16 utc_minute_offset
Minute of time zone. Valid range: from 0 to 59.
Definition: fs_basictypes.h:685
FX_INT16 int16
16-bit signed integer.
Definition: fs_basictypes.h:198
Foxit namespace.
Definition: fs_compare.h:27
XFA loading error.
Definition: fs_basictypes.h:282
unsigned __int64 FX_UINT64
Unsigned 64-bit integer.
Definition: fx_system.h:718
short FX_INT16
Signed 16bits integer.
Definition: fx_system.h:649
(For ConnectedPDF only) Cannot get the ACL from ConnectedPDF server.
Definition: fs_basictypes.h:302
No "Comparison" module right.
Definition: fs_basictypes.h:373
Exception(const Exception &exception)
Constructor, with another exception object.
Definition: fs_basictypes.h:710
BYTE STRING CLASS.
Definition: fx_string.h:317
FX_UINT16 uint16
16-bit unsigned integer.
Definition: fs_basictypes.h:200
Header file for basic data class.
static DateTime GetLocalTime()
Get local time.
(For LTV only) Fail to load DTS.
Definition: fs_basictypes.h:350
#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:140
CFX_ArrayTemplate< PointF > PointFArray
An array of PointF objects.
Definition: fs_basictypes.h:427
Definition: fx_coordinates.h:1076
Success, and no error occurs.
Definition: fs_basictypes.h:235
CFX_ArrayTemplate< RectF > RectFArray
An array of RectF objects.
Definition: fs_basictypes.h:425
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
No "Redaction" module right.
Definition: fs_basictypes.h:367
(For ConnectedPDF only) The rights of Current user has expired.
Definition: fs_basictypes.h:296
(For LTV only) Revocation callback for LTV has not been set.
Definition: fs_basictypes.h:342
~Exception()
Destructor.
Definition: fs_basictypes.h:729
DateTime(const SYSTEMTIME &systime)
Constructor, with SYSTEMTIME in Windows.
Definition: fs_basictypes.h:536
DateTime & ToUTCTime()
Convert current object to UTC time.
(For LTV only) Fail to switch PDF verion.
Definition: fs_basictypes.h:344
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:392
(For Excel-to-PDF conversion only) Excel document does not have any content so it cannot be converted...
Definition: fs_basictypes.h:385
FX_RECT RectI
Rectangle, in integer.
Definition: fs_basictypes.h:423
Definition: fx_coordinates.h:771
Some types are not supported.
Definition: fs_basictypes.h:259