| 1 | /* fre:ac - free audio converter |
| 2 | * Copyright (C) 2001-2016 Robert Kausch <[email protected]> |
| 3 | * |
| 4 | * This program is free software; you can redistribute it and/or |
| 5 | * modify it under the terms of the GNU General Public License as |
| 6 | * published by the Free Software Foundation, either version 2 of |
| 7 | * the License, or (at your option) any later version. |
| 8 | * |
| 9 | * THIS PACKAGE IS PROVIDED "AS IS" AND WITHOUT ANY EXPRESS OR |
| 10 | * IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED |
| 11 | * WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR A PARTICULAR PURPOSE. */ |
| 12 | |
| 13 | #include "tagspec.h" |
| 14 | |
| 15 | Int BoCA::TagSpec::LoadFromXML(const String &fileName) |
| 16 | { |
| 17 | XML::Document *document = new XML::Document(); |
| 18 | |
| 19 | document->LoadFile(fileName); |
| 20 | |
| 21 | XML::Node *root = document->GetRootNode(); |
| 22 | |
| 23 | for (Int i = 0; i < root->GetNOfNodes(); i++) |
| 24 | { |
| 25 | XML::Node *node = root->GetNthNode(i); |
| 26 | |
| 27 | if (node->GetName() == "name") name = node->GetContent(); |
| 28 | else if (node->GetName() == "fields") |
| 29 | { |
| 30 | for (Int j = 0; j < node->GetNOfNodes(); j++) |
| 31 | { |
| 32 | XML::Node *node2 = node->GetNthNode(j); |
| 33 | |
| 34 | if (node2->GetName() != "field") continue; |
| 35 | |
| 36 | String typeString = node2->GetAttributeByName("type")->GetContent(); |
| 37 | Int type = FIELD_TYPE_UNKNOWN; |
| 38 | |
| 39 | if (typeString == "text") type = FIELD_TYPE_TEXT; |
| 40 | else if (typeString == "integer") type = FIELD_TYPE_INTEGER; |
| 41 | else if (typeString == "data") type = FIELD_TYPE_DATA; |
| 42 | else if (typeString == "genre") type = FIELD_TYPE_GENRE; |
| 43 | else if (typeString == "picture") type = FIELD_TYPE_PICTURE; |
| 44 | |
| 45 | fields.Add(TagField(node2->GetAttributeByName("name")->GetContent(), type, node2->GetContent())); |
| 46 | } |
| 47 | } |
| 48 | } |
| 49 | |
| 50 | delete document; |
| 51 | |
| 52 | return Success(); |
| 53 | } |