My Project
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(Type element); \
80 \
86  void RemoveAt(size_t index); \
87 \
94  void InsertAt(size_t index, 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 #if !defined(_SWIG_ANDROID_) && !defined(_SWIG_IOS_) && !defined(_SWIG_JAVA_)
169 #ifndef TRUE
170 
171 #define TRUE true
172 #endif
173 
174 #ifndef FALSE
175 
176 #define FALSE false
177 #endif
178 
179 #ifndef NULL
180 
181 #define NULL ((void*)0)
182 #endif
183 #endif
184 
190 namespace foxit {
192 typedef FX_INT64 int64;
194 typedef FX_UINT64 uint64;
196 typedef FX_INT32 int32;
200 typedef FX_INT16 int16;
204 typedef FX_INT8 int8;
206 typedef FX_UINT8 uint8;
212 typedef uint32 ARGB;
214 typedef uint32 RGB;
216 typedef void* FS_HANDLE;
217 
219 typedef CFX_Object Object;
224 
226 FSDK_DEFINE_ARRAY(WStringArray, WString)
228 FSDK_DEFINE_ARRAY(StringArray, String)
229 
230 #if !defined(_SWIG_ANDROID_) && !defined(_SWIG_JAVA_)
231 
236 typedef enum _ErrorCode {
332 } ErrorCode;
333 
334 #endif
335 
340 
342 class Base : public Object {
343  public:
349  FS_HANDLE Handle() const {
350  return handle_;
351  }
352  virtual ~Base(){}
353 
354  protected:
355  explicit Base(FS_HANDLE handle = NULL) : handle_(handle) {}
356  FS_HANDLE handle_;
357 };
358 
364 typedef PointF Offset;
368 typedef FX_RECT RectI;
373 
375 class DateTime : public Object {
376  public:
382  static DateTime GetUTCTime();
388  static DateTime GetLocalTime();
389 
410  : year(year)
411  , month(month)
412  , day(day)
413  , hour(hour)
414  , minute(minute)
415  , second(second)
419 
422  : year(0)
423  , month(0)
424  , day(0)
425  , hour(0)
426  , minute(0)
427  , second(0)
428  , milliseconds(0)
429  , utc_hour_offset(0)
430  , utc_minute_offset(0) {}
436  explicit DateTime(const FXCRT_DATETIMEZONE& time);
442  DateTime(const DateTime& dt)
443  : year(dt.year)
444  , month(dt.month)
445  , day(dt.day)
446  , hour(dt.hour)
447  , minute(dt.minute)
448  , second(dt.second)
452 
461  year = dt.year;
462  month = dt.month;
463  day = dt.day;
464  hour = dt.hour;
465  minute = dt.minute;
466  second = dt.second;
470  return *this;
471  }
473  operator FXCRT_DATETIMEZONE() const;
474 
475 #if (defined(_WIN32) || defined(_WIN64)) && !defined(SWIG)
476 
481  explicit DateTime(const SYSTEMTIME& systime)
482  : year(systime.wYear)
483  , month(systime.wMonth)
484  , day(systime.wDay)
485  , hour(systime.wHour)
486  , minute(systime.wMinute)
487  , second(systime.wSecond)
488  , milliseconds(systime.wMilliseconds)
489  , utc_hour_offset(0)
490  , utc_minute_offset(0) {}
491 
493  operator SYSTEMTIME() const;
494 #endif // defined(_WIN32) || defined(_WIN64)
495 
518  this->year = year;
519  this->month = month;
520  this->day = day;
521  this->hour = hour;
522  this->minute = minute;
523  this->second = second;
524  this->milliseconds = milliseconds;
525  this->utc_hour_offset = utc_hour_offset;
526  this->utc_minute_offset = utc_minute_offset;
527  }
528 
536  bool IsValid() const;
537 
545  bool operator == (const DateTime& datetime) const;
553  bool operator != (const DateTime& datetime) const;
561  bool operator > (const DateTime& datetime) const;
571  bool operator >= (const DateTime& datetime) const;
579  bool operator < (const DateTime& datetime) const;
590  bool operator <= (const DateTime& datetime) const;
591 
598 
604  DateTime& ToUTCTime();
605 
631 };
632 
633 //#if !defined(_SWIG_ANDROID_) && !defined(_SWIG_IOS_)
634 
636 class Exception : public std::exception, public Object {
637  public:
648  Exception(const char* file_name, int line_number, const char* function_name, ErrorCode error_code);
649 
655  Exception(const Exception& exception)
656  : error_code_(exception.error_code_)
657  , error_message_(exception.error_message_)
658  , name_(exception.name_) {}
659 
667  Exception& operator = (const Exception& exception) {
668  error_code_ = exception.error_code_;
669  error_message_ = exception.error_message_;
670  return *this;
671  }
672 
674  ~Exception() throw() {}
675 
682  return error_code_;
683  }
684 
690  String GetMessage() const {
691  return error_message_;
692  }
693 
699  String GetName() const { return name_; }
700 
701  private:
702  ErrorCode error_code_;
703  String error_message_;
704  String name_;
705 };
706 
707 #define throw(Exception)
708 //#endif // !defined(_SWIG_ANDROID_) && !defined(_SWIG_IOS_)
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
FX_INT64 int64
Signed 64-bit integer.
Definition: fs_basictypes.h:192
bool operator<=(const DateTime &datetime) const
Smaller or equal operator.
void * FS_HANDLE
Handle type.
Definition: fs_basictypes.h:216
New data conflicts with existed data.
Definition: fs_basictypes.h:274
uint16 year
Year. It should be a four-digit number, such as 2014.
Definition: fs_basictypes.h:607
Error handle.
Definition: fs_basictypes.h:249
static DateTime GetLocalTime()
Get local time.
Definition: fs_basictypes.h:375
(For ConnectedPDF only) Cannot get client ID from ConnectedPDF server.
Definition: fs_basictypes.h:319
Definition: fs_basictypes.h:228
DateTime & operator=(const DateTime &dt)
Assign operator.
Definition: fs_basictypes.h:460
FX_UINT16 uint16
16-bit unsigned integer.
Definition: fs_basictypes.h:202
uint16 month
Month. Valid range: from 1 to 12.
Definition: fs_basictypes.h:609
Current object has not been loaded yet.
Definition: fs_basictypes.h:287
(For ConnectedPDF only) The loaded document is not a ConnectedPDF DRM document.
Definition: fs_basictypes.h:291
CFX_Object Object
Object type.
Definition: fs_basictypes.h:219
CFX_ArrayTemplate< float > FloatArray
An array of float values.
Definition: fs_basictypes.h:337
FX_POSITION POSITION
A value used to denote the position of an element in a collection.
Definition: fs_basictypes.h:208
Any unknown error occurs.
Definition: fs_basictypes.h:256
(For ConnectedPDF only) Cannot remove the security from ConnectedPDF server.
Definition: fs_basictypes.h:303
(For ConnectedPDF only) Current device is limited to open the ConnectedPDF DRM document.
Definition: fs_basictypes.h:301
(For ConnectedPDF only) Loaded document is already a ConnectedPDF document.
Definition: fs_basictypes.h:309
(For ConnectedPDF only) Cannot upload ConnectedPDF document info to ConnectedPDF server.
Definition: fs_basictypes.h:313
Expected data or object is not found.
Definition: fs_basictypes.h:270
DateTime(const DateTime &dt)
Constructor, with another date and time object.
Definition: fs_basictypes.h:442
Invalid password. Usually, this error may occur when loading a PDF document with password....
Definition: fs_basictypes.h:247
uint16 minute
Minute. Valid range: from 0 to 59.
Definition: fs_basictypes.h:615
bool Equal(FX_BSTR str) const
Check if current string is equal to another one. Case-sensitive.
int FX_STRSIZE
String size is limited to 2^31-1.
Definition: fx_string.h:35
DateTime & ToUTCTime()
Convert current object to UTC time.
FX_UINT8 uint8
8-bit unsigned integer.
Definition: fs_basictypes.h:206
bool operator >(const DateTime &datetime) const
Greater operator.
bool IsValid() const
Check whether current object is valid or not.
Definition: fs_basictypes.h:636
(For ConnectedPDF only) Input ACL is invalid.
Definition: fs_basictypes.h:323
FX_INT16 int16
16-bit signed integer.
Definition: fs_basictypes.h:200
uint16 hour
Hour. Valid range: from 0 to 23.
Definition: fs_basictypes.h:613
(For ConnectedPDF only) Input client ID is invalid.
Definition: fs_basictypes.h:325
uint32 ARGB
ARGB color type, 32 bits, ((b) | ((g) << 8) | ((r) << 16)) | ((a) << 24)
Definition: fs_basictypes.h:212
Out-of-memory error occurs.
Definition: fs_basictypes.h:264
ErrorCode
Enumeration for error code.
Definition: fs_basictypes.h:236
Header file for coordinate system.
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:622
Any unknown state occurs.
Definition: fs_basictypes.h:276
(For OCR only) OCR engine has not been initialized successfully.
Definition: fs_basictypes.h:329
uint16 day
Day of month. Valid range: from 1 to 31.
Definition: fs_basictypes.h:611
PDF document is encrypted by some unsupported security handler.
Definition: fs_basictypes.h:266
#define FXSYS_wcslen
Get the length of a wide-character string.
Definition: fx_system.h:1009
void * FX_POSITION
A value used to denote the position of an element in a collection.
Definition: fx_system.h:637
(For ConnectedPDF only) Input user token is invalid.
Definition: fs_basictypes.h:295
static DateTime GetUTCTime()
Get UTC time.
FX_RECT RectI
Rectangle, in integer.
Definition: fs_basictypes.h:368
int FX_INT32
32-bit signed integer.
Definition: fx_system.h:662
std::ostream & operator<<(std::ostream &os, const CFX_ByteString &str)
Output byte string to std::osstream.
Definition: fs_basictypes.h:152
bool operator >=(const DateTime &datetime) const
Greater or equal operator.
(For ConnectedPDF only) Current user has no right to open the ConnectedPDF DRM document.
Definition: fs_basictypes.h:297
BYTE STRING CLASS.
Definition: fx_string.h:317
wchar_t const * FX_LPCWSTR
Pointer to constant Unicode characters.
Definition: fx_system.h:717
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:407
(For ConnectedPDF only) Cannot connect to ConnectedPDF server.
Definition: fs_basictypes.h:293
(For ConnectedPDF only) Cannot set the ACL to ConnectedPDF server.
Definition: fs_basictypes.h:307
FX_INT8 int8
8-bit signed integer.
Definition: fs_basictypes.h:204
Some types are not supported.
Definition: fs_basictypes.h:262
int16 utc_hour_offset
Hour of time zone. Valid range: from -12 to 12.
Definition: fs_basictypes.h:628
~Exception()
Destructor.
Definition: fs_basictypes.h:674
Definition: fx_coordinates.h:30
PointF Offset
Offset information, in float.
Definition: fs_basictypes.h:364
(For ConnectedPDF only) Loaded document is already a ConnectedPDF DRM document.
Definition: fs_basictypes.h:311
bool operator==(const char *str1, const CFX_ByteString &str2)
Check if two byte strings are equal.
Definition: fs_basictypes.h:128
CFX_ArrayTemplate< int32 > Int32Array
An array of integer values.
Definition: fs_basictypes.h:339
String GetName() const
Get the string of error code.
Definition: fs_basictypes.h:699
#define FX_FILESIZE
Support large file directly.
Definition: fx_stream.h:138
CFX_WideString WString
Wide string.
Definition: fs_basictypes.h:221
bool operator==(const DateTime &datetime) const
Equal operator.
ErrorCode GetErrCode() const
Get the error code.
Definition: fs_basictypes.h:681
Data of current object is invalid.
Definition: fs_basictypes.h:283
Foxit namespace.
Definition: fs_connectedpdf.h:26
FS_HANDLE Handle() const
Get the handle of current object.
Definition: fs_basictypes.h:349
DateTime()
Constructor.
Definition: fs_basictypes.h:421
(For ConnectedPDF only) Cannot get the ACL from ConnectedPDF server.
Definition: fs_basictypes.h:305
The type of input object or current object is invalid.
Definition: fs_basictypes.h:272
bool operator !=(const DateTime &datetime) const
Not equal operator.
CFX_ByteString FX_UTF8Encode(const wchar_t *wstr)
Convert wide string to UTF-8 encoding byte string.
Definition: fs_basictypes.h:116
CFX_ArrayTemplate< PointF > PointFArray
An array of PointF objects.
Definition: fs_basictypes.h:372
(For OCR only) Invalid license (for ABBYY FineReader Engine) is used for OCR engine.
Definition: fs_basictypes.h:327
Certificate error: PDF document is encrypted by digital certificate but current user does not have th...
Definition: fs_basictypes.h:254
(For ConnectedPDF only) The input ConnectedPDF DRM wrapper document is invalid.
Definition: fs_basictypes.h:317
Parameter error: value of any input parameter for a function is invalid.
Definition: fs_basictypes.h:260
FX_DWORD FX_UINT32
unsigned 32bits integer.
Definition: fx_system.h:748
bool operator!=(const char *str1, const CFX_ByteString &str2)
Check if two byte strings are not equal.
Definition: fs_basictypes.h:140
Exception(const Exception &exception)
Constructor, with another exception object.
Definition: fs_basictypes.h:655
uint16 second
Second. Valid range: from 0 to 60. 60 for leap second.
Definition: fs_basictypes.h:617
(For OCR only) Not enough disk space.
Definition: fs_basictypes.h:331
Data is not ready. Usually this is used as an exception error code when loading document in asynchron...
Definition: fs_basictypes.h:281
unsigned short FX_UINT16
Unsigned 16bits integer.
Definition: fx_system.h:652
bool operator<(const DateTime &datetime) const
Smaller operator.
Exception(const char *file_name, int line_number, const char *function_name, ErrorCode error_code)
Constructor, with parameters.
signed char FX_INT8
Signed 8bits integer.
Definition: fx_system.h:640
String GetMessage() const
Get the error message string.
Definition: fs_basictypes.h:690
#define NULL
The null-pointer value.
Definition: fx_system.h:773
unsigned char FX_UINT8
Unsigned 8bits integer.
Definition: fx_system.h:642
Definition: fx_coordinates.h:763
uint32 RGB
RGB color type, 24 bits, ((b) | ((g) << 8) | ((r) << 16)))
Definition: fs_basictypes.h:214
DateTime & ToLocalTime()
Convert current object to local time.
Content has not been parsed yet. Usually, this represents PDF page has not been parsed yet.
Definition: fs_basictypes.h:268
short FX_INT16
Signed 16bits integer.
Definition: fx_system.h:650
Header file for basic data class.
Exception & operator=(const Exception &exception)
Assign operator.
Definition: fs_basictypes.h:667
FX_INT64 FILESIZE
File size. Support large file directly.
Definition: fs_basictypes.h:210
Structure for date and time.
Definition: fx_process.h:95
XFA loading error.
Definition: fs_basictypes.h:285
FX_INT32 int32
32-bit signed integer.
Definition: fs_basictypes.h:196
Header file for Process & thread related definitions and classes.
Definition: fs_basictypes.h:226
CFX_PointF PointF
Point information, in float.
Definition: fs_basictypes.h:362
Invalid or incorrect state.
Definition: fs_basictypes.h:289
Definition: fx_coordinates.h:594
(For ConnectedPDF only) Cannot get user token from ConnectedPDF server.
Definition: fs_basictypes.h:321
Definition: fx_coordinates.h:1053
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:515
uint16 utc_minute_offset
Minute of time zone. Valid range: from 0 to 59.
Definition: fs_basictypes.h:630
Invalid license is used to initialize Foxit PDF SDK library.
Definition: fs_basictypes.h:258
Success, and no error occurs.
Definition: fs_basictypes.h:238
Format is invalid. For files, this may also mean that file is corrupted.
Definition: fs_basictypes.h:242
(For ConnectedPDF only) The rights of Current user has expired.
Definition: fs_basictypes.h:299
File cannot be found or could not be opened.
Definition: fs_basictypes.h:240
WIDE STRING CLASS.
Definition: fx_string.h:1470
CFX_ByteString String
Byte string.
Definition: fs_basictypes.h:223
CFX_FloatRect RectF
Rectangle, in float.
Definition: fs_basictypes.h:366
(For ConnectedPDF only) Cannot upload ConnectedPDF DRM document info to ConnectedPDF server.
Definition: fs_basictypes.h:315
CFX_ArrayTemplate< RectF > RectFArray
An array of RectF objects.
Definition: fs_basictypes.h:370
FX_UINT32 uint32
32-bit unsigned integer.
Definition: fs_basictypes.h:198
CFX_Matrix Matrix
Matrix information, in float.
Definition: fs_basictypes.h:360
FX_UINT64 uint64
Unsigned 64-bit integer.
Definition: fs_basictypes.h:194
Definition: fs_basictypes.h:342

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