Line data Source code
1 : /******************************************************************************
2 : *
3 : * Purpose: PCIDSK library utility functions - private
4 : *
5 : ******************************************************************************
6 : * Copyright (c) 2009
7 : * PCI Geomatics, 90 Allstate Parkway, Markham, Ontario, Canada.
8 : *
9 : * SPDX-License-Identifier: MIT
10 : ****************************************************************************/
11 : #ifndef INCLUDE_CORE_PCIDSK_UTILS_H
12 : #define INCLUDE_CORE_PCIDSK_UTILS_H
13 :
14 : #include "pcidsk_config.h"
15 : #include "pcidsk_types.h"
16 : #include <string>
17 : #include <vector>
18 :
19 : namespace PCIDSK
20 : {
21 : class IOInterfaces;
22 :
23 : /************************************************************************/
24 : /* Utility functions. */
25 : /************************************************************************/
26 :
27 : std::string &UCaseStr( std::string & );
28 : uint64 atouint64( const char *);
29 : int64 atoint64( const char *);
30 : int pci_strcasecmp( const char *, const char * );
31 : int pci_strncasecmp( const char *, const char *, size_t );
32 :
33 : #ifndef EQUAL
34 : #define EQUAL(x,y) (pci_strcasecmp(x,y) == 0)
35 : #define EQUALN(x,y,n) (pci_strncasecmp(x,y,n) == 0)
36 : #endif
37 : #ifndef STARTS_WITH_CI
38 : #define STARTS_WITH_CI(x,y) EQUALN(x,y,strlen(y))
39 : #define STARTS_WITH(x,y) (std::strncmp(x,y,strlen(y)) == 0)
40 : #endif
41 :
42 : void SwapData( void* const data, const int size, const int wcount );
43 : bool BigEndianSystem(void);
44 : void GetCurrentDateTime( char *out_datetime );
45 :
46 : void ParseTileFormat(const std::string& oOptions, int & nTileSize,
47 : std::string & oCompress);
48 :
49 : void SwapPixels(void* const data,
50 : const eChanType type,
51 : const std::size_t count);
52 :
53 : std::string ParseLinkedFilename(std::string oOptions);
54 :
55 : std::vector<double> ProjParamsFromText( std::string geosys,
56 : std::string params );
57 : std::string ProjParamsToText( std::vector<double> );
58 :
59 : std::string DefaultMergeRelativePath(const PCIDSK::IOInterfaces *,
60 : const std::string& base,
61 : const std::string& src_filename);
62 : std::string ExtractPath( std::string );
63 :
64 : void LibJPEG_DecompressBlock(
65 : uint8 *src_data, int src_bytes, uint8 *dst_data, int dst_bytes,
66 : int xsize, int ysize, eChanType pixel_type );
67 : void LibJPEG_CompressBlock(
68 : uint8 *src_data, int src_bytes, uint8 *dst_data, int &dst_bytes,
69 : int xsize, int ysize, eChanType pixel_type, int quality );
70 :
71 : void LibKAKADU_DecompressBlock
72 : (PCIDSK::eChanType eChanType,
73 : uint8 * pabySrcBuffer, int nSrcBufferSize,
74 : uint8 * pabyDstBuffer, int nDstBufXSize,
75 : int nXSize, int nYSize, int nChanCount);
76 : void LibKAKADU_CompressBlock
77 : (PCIDSK::eChanType eChanType,
78 : uint8 * pabyDstBuffer, int nDstBufferSize,
79 : uint8 * pabySrcBuffer, int nSrcBufXSize,
80 : int nXSize, int nYSize, int nChanCount,
81 : int & nCompressSize, double dfQuality);
82 :
83 : void DefaultDebug( const char * );
84 : void Debug( void (*)(const char *), const char *fmt, ... ) PCIDSK_PRINT_FUNC_FORMAT(2,3);
85 :
86 : /************************************************************************/
87 : /* DIV_ROUND_UP() */
88 : /************************************************************************/
89 :
90 399 : template <class T, class U> inline T DIV_ROUND_UP(T a, U b)
91 : {
92 399 : return static_cast<T>(a / b + (((a % b) == 0) ? 0 : 1));
93 : }
94 :
95 : } // end namespace PCIDSK
96 :
97 : #endif // INCLUDE_CORE_PCIDSK_UTILS_H
|