5
// Lluis Sanchez Gual <lluis@novell.com>
7
// Copyright (c) 2009 Novell, Inc (http://www.novell.com)
9
// Permission is hereby granted, free of charge, to any person obtaining a copy
10
// of this software and associated documentation files (the "Software"), to deal
11
// in the Software without restriction, including without limitation the rights
12
// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
13
// copies of the Software, and to permit persons to whom the Software is
14
// furnished to do so, subject to the following conditions:
16
// The above copyright notice and this permission notice shall be included in
17
// all copies or substantial portions of the Software.
19
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
20
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
21
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
22
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
23
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
24
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
28
using System.Collections;
29
using System.Collections.Generic;
31
namespace MonoDevelop.Projects.Dom.Parser
33
public class CommentTagSet: IEnumerable<CommentTag>
35
List<CommentTag> list;
37
public CommentTagSet (IEnumerable<CommentTag> tags)
39
list = new List<CommentTag> (tags);
42
public CommentTagSet (string tagListString)
44
list = new List<CommentTag> ();
45
if (string.IsNullOrEmpty (tagListString))
48
string[] tags = tagListString.Split (';');
49
for (int n=0; n<tags.Length; n++) {
50
string[] split = tags [n].Split (':');
52
if (split.Length == 2 && int.TryParse (split[1], out priority))
53
list.Add (new CommentTag (split[0], priority));
55
MonoDevelop.Core.LoggingService.LogWarning ("Invalid tag list in CommentTagSet: '{0}'", tagListString);
59
public IEnumerator<CommentTag> GetEnumerator ()
61
return list.GetEnumerator ();
64
IEnumerator IEnumerable.GetEnumerator ()
66
return ((IEnumerable)list).GetEnumerator ();
69
public string[] GetNames ()
71
string[] names = new string[list.Count];
72
for (int n=0; n<list.Count; n++)
73
names [n] = list [n].Tag;
77
public bool ContainsTag (string name)
79
foreach (CommentTag tag in list)
85
public override string ToString ()
88
for (int n=0; n<list.Count; n++) {
91
res += list [n].Tag + ":" + list [n].Priority;
96
public bool Equals (CommentTagSet other)
98
if (other.list.Count != list.Count)
100
List<CommentTag> otags = new List<CommentTag> (other.list);
101
foreach (CommentTag tag in list) {
103
for (int n=0; n<otags.Count; n++) {
104
CommentTag otag = otags [n];
105
if (otag != null && tag.Tag == otag.Tag && tag.Priority == otag.Priority) {
118
public class CommentTag
120
public CommentTag (string tag, int priority)
126
public string Tag { get; internal set; }
127
public int Priority { get; internal set; }