2
#include "CameraMetaData.h"
4
RawSpeed - RAW file decoder.
6
Copyright (C) 2009 Klaus Post
8
This library is free software; you can redistribute it and/or
9
modify it under the terms of the GNU Lesser General Public
10
License as published by the Free Software Foundation; either
11
version 2 of the License, or (at your option) any later version.
13
This library is distributed in the hope that it will be useful,
14
but WITHOUT ANY WARRANTY; without even the implied warranty of
15
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
16
Lesser General Public License for more details.
18
You should have received a copy of the GNU Lesser General Public
19
License along with this library; if not, write to the Free Software
20
Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
22
http://www.klauspost.com
27
CameraMetaData::CameraMetaData() {
30
CameraMetaData::CameraMetaData(char *docname) {
31
ctxt = xmlNewParserCtxt();
33
ThrowCME("CameraMetaData:Could not initialize context.");
37
doc = xmlCtxtReadFile(ctxt, docname, NULL, XML_PARSE_DTDVALID);
40
ThrowCME("CameraMetaData: XML Document could not be parsed successfully. Error was: %s", ctxt->lastError.message);
43
if (ctxt->valid == 0) {
44
if (ctxt->lastError.code == 0x5e) {
45
printf("CameraMetaData: Unable to locate DTD, attempting to ignore.");
47
ThrowCME("CameraMetaData: XML file does not validate. DTD Error was: %s", ctxt->lastError.message);
52
cur = xmlDocGetRootElement(doc);
53
if (xmlStrcmp(cur->name, (const xmlChar *) "Cameras")) {
54
ThrowCME("CameraMetaData: XML document of the wrong type, root node is not cameras.");
58
cur = cur->xmlChildrenNode;
60
if ((!xmlStrcmp(cur->name, (const xmlChar *)"Camera"))) {
61
Camera *camera = new Camera(doc, cur);
64
// Create cameras for aliases.
65
for (uint32 i = 0; i < camera->aliases.size(); i++) {
66
addCamera(new Camera(camera, i));
75
xmlFreeParserCtxt(ctxt);
79
CameraMetaData::~CameraMetaData(void) {
80
map<string, Camera*>::iterator i = cameras.begin();
81
for (; i != cameras.end(); ++i) {
88
xmlFreeParserCtxt(ctxt);
92
Camera* CameraMetaData::getCamera(string make, string model, string mode) {
93
string id = string(make).append(model).append(mode);
94
if (cameras.end() == cameras.find(id))
99
bool CameraMetaData::hasCamera(string make, string model, string mode) {
100
string id = string(make).append(model).append(mode);
101
if (cameras.end() == cameras.find(id))
106
void CameraMetaData::addCamera( Camera* cam )
108
string id = string(cam->make).append(cam->model).append(cam->mode);
109
if (cameras.end() != cameras.find(id))
110
printf("CameraMetaData: Duplicate entry found for camera: %s %s, Skipping!\n", cam->make.c_str(), cam->model.c_str());
115
} // namespace RawSpeed