DIE Engine
Loading...
Searching...
No Matches
tags.h
Go to the documentation of this file.
1
11
12#ifndef TAGS_H
13#define TAGS_H
14
15#include <QList>
16#include <QString>
17#include <stdio.h>
18#include <stdint.h>
19
20static constexpr int TAG_NAME_MAX = 31;
21static constexpr int TAG_VALUE_MAX = 127;
22static constexpr int TAG_COUNT_MAX = 65535;
23
24/*****************************************************************************/
28typedef struct {
29 char name[TAG_NAME_MAX + 1];
30 char value[TAG_VALUE_MAX + 1];
31} Tag;
32
33/*****************************************************************************/
38class Tags
39{
40public:
41 Tags();
42
44 void init();
45
47 void clear();
48
55 bool load(const QString & filename);
56
62 bool save(const QString & filename);
63
68 int findByName(const char * name) const;
69
74 int findOrAddByName(const char * name);
75
77 const char * nameForTag(uint16_t tag) const;
78
80 const char * valueForTag(uint16_t tag) const;
81
82 QString path;
83 QList<Tag> tags;
84
85private:
86 static void skipLine(FILE * file);
87};
88
89extern Tags tags;
90
91#endif // TAGS_H
Tags database.
Definition tags.h:39
int findOrAddByName(const char *name)
Find a tag by its name, create it when missing.
Definition tags.cpp:104
const char * nameForTag(uint16_t tag) const
Name of a tag, "None" for id 0 or out of range ids.
Definition tags.cpp:121
QString path
Definition tags.h:82
int findByName(const char *name) const
Find a tag by its name.
Definition tags.cpp:95
bool save(const QString &filename)
Save all the tags to a file.
Definition tags.cpp:75
void clear()
Remove all the tags.
Definition tags.cpp:31
bool load(const QString &filename)
Load tags from a file and merge them into the database.
Definition tags.cpp:37
Tags()
Definition tags.cpp:20
const char * valueForTag(uint16_t tag) const
Value of a tag, "" for id 0 or out of range ids.
Definition tags.cpp:127
QList< Tag > tags
Definition tags.h:83
void init()
Clear the database and forget the current path.
Definition tags.cpp:25
A tag: name / value pair (null-terminated strings).
Definition tags.h:28
char name[TAG_NAME_MAX+1]
Definition tags.h:29
char value[TAG_VALUE_MAX+1]
Definition tags.h:30
Tags tags
Definition tags.cpp:17