Release 0.41.92
[vala-gnome.git] / libvaladoc / api / attribute.vala
blobb80a1b52c90959c858757361295718dee0c18ec3
1 /* attribute.vala
3 * Copyright (C) 2011 Florian Brosch
5 * This library is free software; you can redistribute it and/or
6 * modify it under the terms of the GNU Lesser General Public
7 * License as published by the Free Software Foundation; either
8 * version 2.1 of the License, or (at your option) any later version.
10 * This library is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 * Lesser General Public License for more details.
15 * You should have received a copy of the GNU Lesser General Public
16 * License along with this library; if not, write to the Free Software
17 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
19 * Author:
20 * Florian Brosch <flo.brosch@gmail.com>
24 using Valadoc.Content;
26 public class Valadoc.Api.Attribute : Item {
27 private Vala.ArrayList<AttributeArgument> args = new Vala.ArrayList<AttributeArgument> ();
28 private SourceFile file;
30 public string name {
31 private set;
32 get;
35 public Attribute (Node parent, SourceFile file, string name, Vala.Attribute data) {
36 base (data);
38 this.parent = parent;
39 this.name = name;
40 this.file = file;
43 public AttributeArgument? get_argument (string name) {
44 if (args != null) {
45 foreach (AttributeArgument arg in args) {
46 if (arg.name == name) {
47 return arg;
52 return null;
55 public AttributeArgument add_boolean (string name, bool value, Vala.Attribute data) {
56 AttributeArgument arg = new AttributeArgument.boolean (this, file, name, value, data);
57 args.add (arg);
58 return arg;
61 public AttributeArgument add_integer (string name, int value, Vala.Attribute data) {
62 AttributeArgument arg = new AttributeArgument.integer (this, file, name, value, data);
63 args.add (arg);
64 return arg;
67 public AttributeArgument add_double (string name, double value, Vala.Attribute data) {
68 AttributeArgument arg = new AttributeArgument.double (this, file, name, value, data);
69 args.add (arg);
70 return arg;
73 public AttributeArgument add_string (string name, string value, Vala.Attribute data) {
74 AttributeArgument arg = new AttributeArgument.string (this, file, name, value, data);
75 args.add (arg);
76 return arg;
79 public SourceFile get_source_file () {
80 return file;
83 protected override Inline build_signature () {
84 SignatureBuilder builder = new SignatureBuilder ();
86 builder.append_attribute ("[");
87 builder.append_type_name (name);
89 if (args.size > 0) {
90 builder.append_attribute ("(");
91 bool first = true;
93 foreach (AttributeArgument arg in args) {
94 if (first == false) {
95 builder.append_attribute (", ");
97 builder.append_content (arg.signature);
98 first = false;
100 builder.append_attribute (")");
103 builder.append_attribute ("]");
105 return builder.get ();