• Main Page
  • Related Pages
  • Namespaces
  • Classes
  • Files
  • File List
  • File Members

ut_types.h

Go to the documentation of this file.
00001 /* -*- mode: C++; tab-width: 4; c-basic-offset: 4; -*- */
00002 
00003 /* AbiSource Program Utilities
00004  * Copyright (C) 1998 AbiSource, Inc.
00005  *
00006  * This program is free software; you can redistribute it and/or
00007  * modify it under the terms of the GNU General Public License
00008  * as published by the Free Software Foundation; either version 2
00009  * of the License, or (at your option) any later version.
00010  *
00011  * This program is distributed in the hope that it will be useful,
00012  * but WITHOUT ANY WARRANTY; without even the implied warranty of
00013  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00014  * GNU General Public License for more details.
00015  *
00016  * You should have received a copy of the GNU General Public License
00017  * along with this program; if not, write to the Free Software
00018  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
00019  * 02110-1301 USA.
00020  */
00021 
00022 #ifndef UT_TYPES_H
00023 #define UT_TYPES_H
00024 
00025 #ifdef HAVE_CONFIG_H
00026 #include "config.h"
00027 #endif
00028 
00029 #include <stdlib.h>
00030 #include <glib.h>
00031 
00032 /*
00033  *  This macro allow using GNUC extension with -pedantic
00034  */
00035 #if     __GNUC__ > 2 || (__GNUC__ == 2 && __GNUC_MINOR__ >= 8)
00036 #  define GNUC_EXTENSION __extension__
00037 #else
00038 #  define GNUC_EXTENSION
00039 #endif
00040 
00041 typedef guint8      UT_Byte;
00042 
00043 typedef gunichar        UT_UCS4Char;
00044 typedef guint16      UT_UCS2Char;
00045 typedef gint32          UT_GrowBufElement;
00046 
00047 /* NOTA BENE: UT_UCSChar is deprecated; all new code must use
00048    UT_UCS4Char instead !!! */
00049 typedef UT_UCS4Char     UT_UCSChar; /* Unicode */
00050 
00051 typedef guint8       UT_uint8;
00052 typedef gint8        UT_sint8;
00053 
00054 typedef guint16     UT_uint16;
00055 typedef gint16       UT_sint16;
00056 
00057 typedef guint32     UT_uint32;
00058 typedef gint32          UT_sint32;
00059 
00060 typedef guint64 UT_uint64;
00061 typedef gint64 UT_sint64;
00062 
00063 #ifdef _WIN64
00064 typedef guint64     UT_uintptr;
00065 typedef gint64  UT_sintptr;
00066 #else
00067 typedef unsigned long UT_uintptr;
00068 typedef long        UT_sintptr;
00069 #endif
00070 
00072 #define UT_UNUSED(x) (void)(x);
00073 
00078 #ifdef DEBUG
00079 #define UT_DEBUG_ONLY_ARG(x)
00080 #else
00081 #define UT_DEBUG_ONLY_ARG(x) (void)(x);
00082 #endif
00083 
00088 typedef UT_uint8 UT_Confidence_t;
00089 
00090 #define UT_CONFIDENCE_PERFECT 255
00091 #define UT_CONFIDENCE_GOOD    170
00092 #define UT_CONFIDENCE_SOSO    127
00093 #define UT_CONFIDENCE_POOR     85
00094 #define UT_CONFIDENCE_ZILCH     0
00095 
00096 #include "ut_export.h" // ABI_EXPORT is defined in there.
00097 
00098 #if __GNUC__
00099   #define ABI_NORETURN __attribute__((noreturn))
00100   #define ABI_PRINTF_FORMAT(f,a) __attribute__ ((format (printf, f, a)))
00101 #else
00102   #define ABI_NORETURN
00103   #define ABI_PRINTF_FORMAT(f,a)
00104 #endif
00105 
00106 /* ABI_FAR_CALL: C function that we want to expose across plugin boundaries */
00107 #define ABI_FAR_CALL extern "C" ABI_PLUGIN_EXPORT
00108 
00109 #define _abi_callonce /* only call me once! */
00110 
00111 /*
00112     UT_Error should be used far more than it is.  Any function
00113     which reasonably could fail at runtime for anything other than
00114     a coding error or bug should return an error code.  Error codes
00115     should be propogated properly.
00116 
00117     Addendum: 1-23-99
00118     If you have any problems with or suggestions for error codes,
00119     please send them to Sam Tobin-Hochstadt (sytobinh@uchicago.edu).
00120     I am the person that has worked the most with them.
00121 */
00122 typedef UT_sint32       UT_Error;
00123 #define UT_OK           ((UT_Error) 0)
00124 #define UT_ERROR                ((UT_Error) -1)     /* VERY generic */
00125 #define UT_OUTOFMEM     ((UT_Error) -100)
00126 #define UT_SAVE_WRITEERROR      ((UT_Error) -201)
00127 #define UT_SAVE_NAMEERROR       ((UT_Error) -202)
00128 #define UT_SAVE_EXPORTERROR     ((UT_Error) -203)
00129 #define UT_EXTENSIONERROR       ((UT_Error) -204)
00130 #define UT_SAVE_CANCELLED       ((UT_Error) -205)
00131 #define UT_SAVE_OTHERERROR      ((UT_Error) -200)   /* This should eventually dissapear. */
00132 #define UT_IE_FILENOTFOUND      ((UT_Error) -301)
00133 #define UT_IE_NOMEMORY          ((UT_Error) -302)
00134 #define UT_IE_UNKNOWNTYPE       ((UT_Error) -303)
00135 #define UT_IE_BOGUSDOCUMENT     ((UT_Error) -304)
00136 #define UT_IE_COULDNOTOPEN      ((UT_Error) -305)
00137 #define UT_IE_COULDNOTWRITE     ((UT_Error) -306)
00138 #define UT_IE_FAKETYPE          ((UT_Error) -307)
00139 #define UT_INVALIDFILENAME      ((UT_Error) -308)
00140 #define UT_NOPIECETABLE         ((UT_Error) -309)
00141 #define UT_IE_ADDLISTENERERROR  ((UT_Error) -310)
00142 #define UT_IE_UNSUPTYPE         ((UT_Error) -311)
00143 #define UT_IE_PROTECTED         ((UT_Error) -312)       // (pass) protected doc
00144 #define UT_IE_SKIPINVALID       ((UT_Error) -313)       // (pass) protected doc
00145 #define UT_IE_IMPORTERROR       ((UT_Error) -300)   /* The general case */
00146 #define UT_IE_IMPSTYLEUNSUPPORTED  ((UT_Error) -314)
00147 #define UT_IE_XMLNOANGLEBRACKET    ((UT_Error) -360)
00148 #define UT_IE_TRY_RECOVER          ((UT_Error) -350)    // try recovering the document. ie, we have
00149                                                         // imported something
00150 
00151 #define UT_IS_IE_SUCCESS(x) (((x) == UT_OK) || ((x) == UT_IE_TRY_RECOVER))
00152 
00153 ABI_EXPORT UT_Error UT_errnoToUTError (void);
00154 
00155 /* defined in ut_misc.cpp */
00156 ABI_EXPORT void * UT_calloc ( UT_uint32 nmemb, UT_uint32 size );
00157 
00158 /*
00159     The MSVC debug runtime library can track leaks back to the
00160     original allocation via the following black magic.
00161 */
00162 #if defined(_MSC_VER) && defined(_DEBUG) && defined(_CRTDBG_MAP_ALLOC)
00163 #include <crtdbg.h>
00164 #define UT_DEBUG_NEW new(_NORMAL_BLOCK, __FILE__, __LINE__)
00165 #define new UT_DEBUG_NEW
00166 #endif /* _MSC_VER && _DEBUG && _CRTDBG_MAP_ALLOC */
00167 
00168 
00169 /* Unicode character constants.  Try to use these rather than
00170 ** decimal or hex constants throughout the code.  See also bug
00171 ** 512.
00172 */
00173 
00174 /* When objects (fields, etc) must be represented in unicode, use the
00175    BELL code and let UT_isWordDelimiter recognize it as a word
00176    character. See bug 223.  */
00177 #define UCS_ABI_OBJECT  ((UT_UCSChar)0x0007)
00178 
00179 #define UCS_TAB         ((UT_UCSChar)0x0009)
00180 #define UCS_LF          ((UT_UCSChar)0x000a)
00181 #define UCS_VTAB        ((UT_UCSChar)0x000b)
00182 #define UCS_FF          ((UT_UCSChar)0x000c)
00183 #define UCS_CR          ((UT_UCSChar)0x000d)
00184 #define UCS_SPACE       ((UT_UCSChar)0x0020)
00185 #define UCS_NBSP        ((UT_UCSChar)0x00a0)
00186 #define UCS_PILCROW     ((UT_UCSChar)0x00b6)
00187 #define UCS_LINESEP     ((UT_UCSChar)0x2028)            /* Unicode line separator */
00188 #define UCS_PARASEP     ((UT_UCSChar)0x2029)            /* Unicode paragraph separator */
00189 #define UCS_BOM         ((UT_UCSChar)0xFEFF)            /* Byte order mark */
00190 #define UCS_REPLACECHAR ((UT_UCSChar)0xFFFD)
00191 #define UCS_HYPHEN      ((UT_UCSChar)0x2010)
00192 #define UCS_MINUS       ((UT_UCSChar)0x2d)
00193 
00194 /* Note: the following are our interpretations, not Unicode's */
00195 /* Note: use Unicode Private Use Area 0xE000 - 0xF8FF         */
00196 /* Note: GB18030 mandates U+E000 - U+E765 for UDAs 1, 2 and 3 */
00197 /* Note: BIG5-HKSCS uses U+E000 - U+F848                      */
00198 /* Note: Please update UCS_ABICONTROL_START/END if more       */
00199 /* Note: special values are added.  We need to watch out for  */
00200 /* Note: them during import                                   */
00201 #define UCS_ABICONTROL_START    (UCS_FIELDSTART)
00202 #define UCS_FIELDSTART      ((UT_UCSChar)0xF850)
00203 #define UCS_FIELDEND        ((UT_UCSChar)0xF851)
00204 #define UCS_BOOKMARKSTART   ((UT_UCSChar)0xF852)
00205 #define UCS_BOOKMARKEND     ((UT_UCSChar)0xF853)
00206 #define UCS_LIGATURE_PLACEHOLDER ((UT_UCS4Char)0xF854)
00207 #define UCS_ABICONTROL_END  (UCS_LIGATURE_PLACEHOLDER)
00208 
00209 
00210 #if 1 /* try to use the unicode values for special chars */
00211 #define UCS_EN_SPACE        ((UT_UCSChar)0x2002)
00212 #define UCS_EM_SPACE        ((UT_UCSChar)0x2003)
00213 #define UCS_EN_DASH     ((UT_UCSChar)0x2013)
00214 #define UCS_EM_DASH     ((UT_UCSChar)0x2014)
00215 #define UCS_BULLET      ((UT_UCSChar)0x2022)
00216 /* TODO Quote marks need to be localized - not hard-coded */
00217 #define UCS_LQUOTE      ((UT_UCSChar)0x2018)
00218 #define UCS_RQUOTE      ((UT_UCSChar)0x2019)
00219 #define UCS_LDBLQUOTE       ((UT_UCSChar)0x201c)
00220 #define UCS_RDBLQUOTE       ((UT_UCSChar)0x201d)
00221 
00222 /* Note: the following is our interpretation, not Unicode's */
00223 #define UCS_UNKPUNK         ((UT_UCSChar)0xFFFF)  /* "unknown punctuation" used with UT_isWordDelimiter() */
00224 
00225 #else /* see bug 512 */
00226 
00227 #define UCS_EN_SPACE        ((UT_UCSChar)0x0020)
00228 #define UCS_EM_SPACE        ((UT_UCSChar)0x0020)
00229 #define UCS_EN_DASH     ((UT_UCSChar)0x002d)
00230 #define UCS_EM_DASH     ((UT_UCSChar)0x002d)
00231 #define UCS_BULLET      ((UT_UCSChar)0x0095)
00232 #define UCS_LQUOTE      ((UT_UCSChar)0x0027)
00233 #define UCS_RQUOTE      ((UT_UCSChar)0x0027)
00234 #define UCS_LDBLQUOTE       ((UT_UCSChar)0x0022)
00235 #define UCS_RDBLQUOTE       ((UT_UCSChar)0x0022)
00236 #define UCS_UNKPUNK         ((UT_UCSChar)0x00FF)
00237 
00238 #endif
00239 
00240 /* direction markers */
00241 #define UCS_LRM 0x200E
00242 #define UCS_RLM 0x200F
00243 #define UCS_LRE 0x202a
00244 #define UCS_RLE 0x202b
00245 #define UCS_PDF 0x202c
00246 #define UCS_LRO 0x202d
00247 #define UCS_RLO 0x202e
00248 
00249 /*
00250 ** Some useful macros that we use throughout
00251 */
00252 
00253 #define FREEP(p)        do { if (p) { g_free((void *)p); (p)=NULL; } } while (0)
00254 #define DELETEP(p)      do { if (p) { delete(p); (p)=NULL; } } while (0)
00255 #define DELETEPV(pa)    do { if (pa) { delete [] (pa); (pa)=NULL; } } while (0)
00256 #define REPLACEP(p,q)       do { if (p) delete p; p = q; } while (0)
00257 #define REFP(p)         ((p)->ref(), (p))
00258 #define UNREFP(p)       do { if (p) { (p)->unref(); (p)=NULL; } } while (0)
00259 #define CLONEP(p,q)     do { FREEP(p); if (q && *q) p = g_strdup(q); } while (0)
00260 
00261 #define E2B(err)        ((err) == UT_OK)
00262 
00263 /* This is a value from the private-use space of FriBidi */
00264 #define FRIBIDI_TYPE_UNSET -1
00265 #define FRIBIDI_TYPE_IGNORE -2
00266 
00267 // this is maximum revision level; it is intentionally not defined as
00268 // 0xffffffff to avoid problems with bad 64-bit compilers
00269 
00270 #define PD_MAX_REVISION 0x0fffffff
00271 
00272 #endif /* UT_TYPES_H */

Generated on Sun Feb 14 2021 for AbiWord by  doxygen 1.7.1