GDAL
gdal_openinfo.h
1/******************************************************************************
2 *
3 * Name: gdal_openinfo.h
4 * Project: GDAL Core
5 * Purpose: Declaration of GDALOpenInfo class
6 * Author: Frank Warmerdam, warmerdam@pobox.com
7 *
8 ******************************************************************************
9 * Copyright (c) 1998, Frank Warmerdam
10 * Copyright (c) 2007-2014, Even Rouault <even dot rouault at spatialys.com>
11 *
12 * SPDX-License-Identifier: MIT
13 ****************************************************************************/
14
15#ifndef GDALOPENINFO_H_INCLUDED
16#define GDALOPENINFO_H_INCLUDED
17
18#include "cpl_port.h"
19
20#include "gdal.h"
21
22/* ******************************************************************** */
23/* GDALOpenInfo */
24/* ******************************************************************** */
25
27class CPL_DLL GDALOpenInfo
28{
29 bool bHasGotSiblingFiles = false;
30 char **papszSiblingFiles = nullptr;
31 int nHeaderBytesTried = 0;
32
33 public:
34 GDALOpenInfo(const char *pszFile, int nOpenFlagsIn,
35 const char *const *papszSiblingFiles = nullptr);
36 ~GDALOpenInfo(void);
37
39 char *pszFilename = nullptr;
40
42 std::string osExtension{};
43
45 char **papszOpenOptions = nullptr;
46
50 int nOpenFlags = 0;
51
53 bool bStatOK = false;
55 bool bIsDirectory = false;
56
58 VSILFILE *fpL = nullptr;
59
61 int nHeaderBytes = 0;
63 GByte *pabyHeader = nullptr;
64
66 const char *const *papszAllowedDrivers = nullptr;
67
68 int TryToIngest(int nBytes);
69 char **GetSiblingFiles();
70 char **StealSiblingFiles();
71 bool AreSiblingFilesLoaded() const;
72
73 bool IsSingleAllowedDriver(const char *pszDriverName) const;
74
78 inline bool IsExtensionEqualToCI(const char *pszExt) const
79 {
80 return EQUAL(osExtension.c_str(), pszExt);
81 }
82
83 private:
85};
86
87#endif
Class for dataset open functions.
Definition gdal_openinfo.h:28
GByte * pabyHeader
Buffer with first bytes of the file.
Definition gdal_openinfo.h:63
bool bIsDirectory
Whether the file is a directory.
Definition gdal_openinfo.h:55
char ** GetSiblingFiles()
Return sibling files.
Definition gdalopeninfo.cpp:396
char ** papszOpenOptions
Open options.
Definition gdal_openinfo.h:45
GDALOpenInfo(const char *pszFile, int nOpenFlagsIn, const char *const *papszSiblingFiles=nullptr)
Constructor/.
Definition gdalopeninfo.cpp:152
GDALAccess eAccess
Access flag.
Definition gdal_openinfo.h:48
int nOpenFlags
Open flags.
Definition gdal_openinfo.h:50
bool IsExtensionEqualToCI(const char *pszExt) const
Return whether the extension of the file is equal to pszExt, using case-insensitive comparison.
Definition gdal_openinfo.h:78
bool AreSiblingFilesLoaded() const
Return whether sibling files have been loaded.
Definition gdalopeninfo.cpp:449
std::string osExtension
Result of CPLGetExtension(pszFilename);.
Definition gdal_openinfo.h:42
VSILFILE * fpL
Pointer to the file.
Definition gdal_openinfo.h:58
char * pszFilename
Filename.
Definition gdal_openinfo.h:39
bool bStatOK
Whether stat()'ing the file was successful.
Definition gdal_openinfo.h:53
int TryToIngest(int nBytes)
Ingest bytes from the file.
Definition gdalopeninfo.cpp:462
char ** StealSiblingFiles()
Return sibling files and steal reference.
Definition gdalopeninfo.cpp:435
bool IsSingleAllowedDriver(const char *pszDriverName) const
Returns true if the driver name is the single in the list of allowed drivers.
Definition gdalopeninfo.cpp:490
int nHeaderBytes
Number of bytes in pabyHeader.
Definition gdal_openinfo.h:61
const char *const * papszAllowedDrivers
Allowed drivers (NULL for all).
Definition gdal_openinfo.h:66
Core portability definitions for CPL.
#define EQUAL(a, b)
Alias for strcasecmp() == 0.
Definition cpl_port.h:541
#define CPL_DISALLOW_COPY_ASSIGN(ClassName)
Helper to remove the copy and assignment constructors so that the compiler will not generate the defa...
Definition cpl_port.h:936
unsigned char GByte
Unsigned byte type.
Definition cpl_port.h:175
struct VSIVirtualHandle VSILFILE
Opaque type for a FILE that implements the VSIVirtualHandle API.
Definition cpl_vsi.h:141
Public (C callable) GDAL entry points.
GDALAccess
Definition gdal.h:118
@ GA_ReadOnly
Definition gdal.h:119