The Birdfont Source Code


All Repositories / birdfont.git / blob – RSS feed

Attributes.vala in libbirdxml

This file is a part of the Birdfont project.

Contributing

Send patches or pull requests to johan.mattsson.m@gmail.com.
Clone this repository: git clone https://github.com/johanmattssonm/birdfont.git

Revisions

View the latest version of libbirdxml/Attributes.vala.
Add a button for closing paths
1 /* 2 Copyright (C) 2014 Johan Mattsson 3 4 This library is free software; you can redistribute it and/or modify 5 it under the terms of the GNU Lesser General Public License as 6 published by the Free Software Foundation; either version 3 of the 7 License, or (at your option) any later version. 8 9 This library is distributed in the hope that it will be useful, but 10 WITHOUT ANY WARRANTY; without even the implied warranty of 11 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 12 Lesser General Public License for more details. 13 */ 14 namespace Bird { 15 16 /** 17 * Iterator for XML attributes. 18 */ 19 public class Attributes : GLib.Object { 20 21 public Tag tag; 22 public int refcount = 1; 23 24 internal Attributes (Tag t) { 25 tag = t; 26 } 27 28 public Iterator iterator () { 29 return new Iterator (tag); 30 } 31 32 public class Iterator : GLib.Object { 33 public Tag tag; 34 public Attribute? next_attribute; 35 public int iterator_refcount = 1; 36 37 internal Iterator (Tag t) { 38 tag = t; 39 next_attribute = null; 40 tag.reparse_attributes (); 41 } 42 43 public bool next () { 44 if (tag.has_more_attributes ()) { 45 next_attribute = tag.get_next_attribute (); 46 } else { 47 next_attribute = null; 48 } 49 50 return next_attribute != null; 51 } 52 53 public new Attribute get () { 54 if (next_attribute == null) { 55 XmlParser.warning ("No attribute is parsed yet."); 56 return new Attribute.empty (); 57 } 58 59 return (!) next_attribute; 60 } 61 } 62 } 63 64 } 65