Free cookie consent management tool by TermsFeed Policy Generator

source: branches/HeuristicLab.Problems.GrammaticalOptimization/SharpVectorModel/BasicTypes/SvgNumberList.cs @ 12762

Last change on this file since 12762 was 12762, checked in by aballeit, 9 years ago

#2283 GUI updates, Tree-chart, MCTS Version 2 (prune leaves)

File size: 1.7 KB
Line 
1// <developer>niklas@protocol7.com</developer>
2// <developer>kevin@kevlindev.com</developer>
3// <completed>100</completed>
4
5using System;
6using System.Text;
7using System.Text.RegularExpressions;
8
9using SharpVectors.Dom;
10
11namespace SharpVectors.Dom.Svg
12{
13  /// <summary>
14  /// Summary description for SvgNumberList.
15  /// </summary>
16    public sealed class SvgNumberList : SvgList<ISvgNumber>, ISvgNumberList
17    {
18        #region Private Fields
19
20        private static Regex delim = new Regex(@"\s+,?\s*|,\s*", RegexOptions.Compiled);
21
22        #endregion
23
24        #region Constructors
25
26        public SvgNumberList()
27        {
28        }
29
30        public SvgNumberList(string listString)
31        {
32            this.FromString(listString);
33        }
34
35        #endregion
36
37        #region Public Methods
38
39        public void FromString(string listString)
40    {
41            // remove existing list items
42            Clear();
43
44            if (listString != null)
45            {
46                // remove leading and trailing whitespace
47                // NOTE: Need to check if .NET whitespace = SVG (XML) whitespace
48                listString = listString.Trim();
49
50                if (listString.Length > 0)
51                {
52                    foreach ( string item in delim.Split(listString) )
53                    {
54                        // the following test is needed to catch consecutive commas
55                        // for example, "one,two,,three"
56                        if (item.Length == 0)
57                            throw new DomException(DomExceptionType.SyntaxErr);
58
59                        AppendItem(new SvgNumber(item));
60                    }
61                }
62            }
63        }
64
65        #endregion
66    }
67}
Note: See TracBrowser for help on using the repository browser.