1 //
2 // Copyright (c) 2010-2018 Antmicro
3 // Copyright (c) 2011-2015 Realtime Embedded
4 //
5 // This file is licensed under the MIT License.
6 // Full license text is available in 'licenses/MIT.txt'.
7 //
8 using System;
9 
10 namespace Antmicro.Renode.UserInterface.Tokenizer
11 {
12 
13     public class StringToken : Token
14     {
StringToken(string value)15         public StringToken(string value):base(value)
16         {
17             var trim = false;
18             if(value.StartsWith("\"", StringComparison.Ordinal))
19             {
20                 trim = true;
21                 value = value.Replace("\\\"", "\"");
22             }
23             else if(value.StartsWith("'", StringComparison.Ordinal))
24             {
25                 trim = true;
26                 value = value.Replace("\\\'", "\'");
27             }
28             if(trim)
29             {
30                 Value = value.Substring(1, value.Length - 2);
31             }
32             else
33             {
34                 Value = value;
35             }
36         }
37 
38         public string Value { get; protected set; }
39 
GetObjectValue()40         public override object GetObjectValue()
41         {
42             return Value;
43         }
44 
ToString()45         public override string ToString()
46         {
47             return string.Format("[StringToken: Value={0}]", Value);
48         }
49     }
50 
51 }
52 
53