📄 metadata.h
字号:
/*
This file is part of KCeasy (http://www.kceasy.com)
Copyright (C) 2002-2004 Markus Kern <mkern@kceasy.com>
This program is free software; you can redistribute it and/or
modify it under the terms of the GNU General Public License
as published by the Free Software Foundation; either version 2
of the License, or (at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
*/
//---------------------------------------------------------------------------
#ifndef MetaDataH
#define MetaDataH
#include <map>
#include "istring.h"
//---------------------------------------------------------------------------
namespace KCeasyEngine {
using std::map;
// mime type handling
typedef enum
{
FTUnknown = 0xF0,
FTAudio = 0xF1,
FTVideo = 0xF2,
FTImage = 0xF3,
FTDocument = 0xF4,
FTSoftware = 0xF5,
FTTorrent = 0xF6
} TFileType;
TFileType FileTypeFromMime(const string& MimeType);
// meta data handling
class TMetaDataPair
{
public:
TMetaDataPair(string& NName, string& NValue) : Name(NName), Value(NValue) {}
TMetaDataPair(const TMetaDataPair& Org) : Name(Org.Name), Value(Org.Value) {}
TMetaDataPair& operator =(const TMetaDataPair& Org) { Name = Org.Name; Value = Org.Value; return *this; }
string Name;
string Value;
};
class TMetaData
{
public:
class Iterator : public map<string,TMetaDataPair>::const_iterator
{
public:
Iterator(map<string,TMetaDataPair>::const_iterator itr) : map<string,TMetaDataPair>::const_iterator(itr) {}
const TMetaDataPair& operator *() { return (map<string,TMetaDataPair>::const_iterator::operator*()).second; }
};
TMetaData();
TMetaData(const TMetaData& Org);
TMetaData& operator =(const TMetaData& Org);
const string& Get(const char* Name) const;
int GetInt(const char* Name) const;
void Set(string& Name, string& Value);
void SetInt(string& Name, int Value);
bool Exists(const char* Name) const { return (pair_map.find(Name) != pair_map.end()); }
void Remove(const char* Name) { pair_map.erase(Name); }
bool Empty() const { return pair_map.empty(); }
int NoOfPairs() const { return pair_map.size(); }
Iterator Begin() { return (map<string,TMetaDataPair>::const_iterator)pair_map.begin(); }
Iterator End() { return (map<string,TMetaDataPair>::const_iterator)pair_map.end(); }
private:
map<string,TMetaDataPair> pair_map;
};
} // namespace KCeasyEngine
#endif
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -