1 #pragma once
2
3 #ifndef TFILETYPE_INCLUDED
4 #define TFILETYPE_INCLUDED
5
6 //#include "tfilepath.h"
7 #include "tcommon.h"
8
9 class TFilePath;
10 class QString;
11
12 #undef DVAPI
13 #undef DVVAR
14 #ifdef TSYSTEM_EXPORTS
15 #define DVAPI DV_EXPORT_API
16 #define DVVAR DV_EXPORT_VAR
17 #else
18 #define DVAPI DV_IMPORT_API
19 #define DVVAR DV_IMPORT_VAR
20 #endif
21
22 namespace TFileType {
23
24 enum Type {
25
26 UNKNOW_FILE = 0,
27 LEVEL = 0x1,
28 SCENE = 0x1000,
29
30 RASTER_IMAGE = 0x2,
31 RASTER_LEVEL = RASTER_IMAGE | LEVEL,
32 VECTOR_IMAGE = 0x4,
33 VECTOR_LEVEL = VECTOR_IMAGE | LEVEL,
34 CMAPPED_IMAGE = 0x8,
35 CMAPPED_LEVEL = CMAPPED_IMAGE | LEVEL,
36 MESH_IMAGE = 0x10,
37 MESH_LEVEL = MESH_IMAGE | LEVEL,
38
39 IMAGE = RASTER_IMAGE | VECTOR_IMAGE | CMAPPED_IMAGE | MESH_IMAGE,
40
41 AUDIO_LEVEL = 0x20 | LEVEL,
42 PALETTE_LEVEL = 0x40 | LEVEL,
43
44 TABSCENE = 0x2000 | SCENE,
45 TOONZSCENE = 0x4000 | SCENE,
46
47 VIEWABLE = RASTER_IMAGE | VECTOR_IMAGE | CMAPPED_IMAGE
48 };
49
50 /*!
51 * getInfo() returns the TFileType::Type of the filepath.
52 * e.g. 'a.tif' => RASTER_IMAGE, 'a..tif' => RASTER_LEVEL, 'a.mov' =>
53 * RASTER_LEVEL, 'a.tlv' => CMAPPED_LEVEL, etc.
54 * Note!!: in the current implementation, a.0001.tif => RASTER_LEVEL,
55 * (probably a bad choice: should be RASTER IMAGE)
56 */
57 //!
58 DVAPI Type getInfo(const TFilePath &fp);
59
60 /*!
61 * getInfoFromExtension() returns the TFileType::Type "naturally" associated
62 * to a given type (file extension)
63 * e.g. 'tif' => RASTER_IMAGE, 'mov' => RASTER_LEVEL, 'tlv' => CMAPPED_LEVEL,
64 * etc.
65 */
66 //!
67 DVAPI Type getInfoFromExtension(const std::string &ext);
68 DVAPI Type getInfoFromExtension(const QString &ext);
69
70 DVAPI void declare(std::string extension, Type type);
71
isResource(Type type)72 inline bool isResource(Type type) { return (type != UNKNOW_FILE); }
isViewable(Type type)73 inline bool isViewable(Type type) { return (type & VIEWABLE) != 0; }
isLevel(Type type)74 inline bool isLevel(Type type) { return (type & LEVEL) != 0; }
isScene(Type type)75 inline bool isScene(Type type) { return (type & SCENE) != 0; }
isFullColor(Type type)76 inline bool isFullColor(Type type) { return (type & RASTER_IMAGE) != 0; }
isVector(Type type)77 inline bool isVector(Type type) { return (type & VECTOR_IMAGE) != 0; }
78
isLevelExtension(const std::string & fileExtension)79 inline bool isLevelExtension(const std::string &fileExtension) {
80 return (getInfoFromExtension(fileExtension) & LEVEL) != 0;
81 }
isLevelExtension(const QString & fileExtension)82 inline bool isLevelExtension(const QString &fileExtension) {
83 return (getInfoFromExtension(fileExtension) & LEVEL) != 0;
84 }
85
isLevelFilePath(const TFilePath & fp)86 inline bool isLevelFilePath(const TFilePath &fp) {
87 return (getInfo(fp) & LEVEL) != 0;
88 }
89
90 } // namespace
91
92 #endif
93