Class that provides functionality of the standard C library sscanf() function.
Esempio n. 1
0
 public void Set(ScanFormatted scanf, bool use_items)
 {
     if (use_items)
     {
         Set(scanf);
     }
     else if (scanf.Results.Count >= 1)
     {
         Items = null;
         Set(scanf.Results[0]);
     }
 }
Esempio n. 2
0
 internal void Set(ScanFormatted scanf)
 {
     Default();
     if (scanf.Results.Count >= 1)
     {
         Value = (float)scanf.Results[0];
     }
     if (scanf.Results.Count >= 2)
     {
         string unit = (string)scanf.Results[1];
         if (!string.IsNullOrEmpty(unit) && unit.ToLower() == "in")
         {
             Unit = UNIT.inch;
         }
     }
 }
Esempio n. 3
0
File: TinyG.cs Progetto: x893/CNCGUI
 internal void Set(ScanFormatted scanf)
 {
     Default();
     if (scanf.Results.Count >= 1)
         Value = (int)scanf.Results[0];
     if (scanf.Results.Count >= 2)
     {
         string unit = (string)scanf.Results[1];
         if (!string.IsNullOrEmpty(unit) && unit.ToLower() == "in")
             Unit = UNIT.inch;
     }
 }
Esempio n. 4
0
File: TinyG.cs Progetto: x893/CNCGUI
        public void Set(ScanFormatted scanf)
        {
            if (scanf.Results.Count >= 1)
                Set(scanf.Results[0]);

            if (scanf.Results.Count >= 2)
            {
                if (Items == null)
                    Items = new Dictionary<int, string>();
                else
                    Items.Clear();

                foreach (string item in ((string)scanf.Results[1]).Split(Common.CHAR_COMMA))
                {
                    string pair = item.Trim();
                    int value = -1; string key = string.Empty;
                    int idx;
                    if (!string.IsNullOrEmpty(pair))
                    {
                        if ((idx = pair.IndexOf('=')) >= 0)
                        {
                            if (idx > 0)
                            {
                                if (!int.TryParse(pair.Substring(0, idx), NumberStyles.Integer, CultureInfo.InvariantCulture, out value))
                                    continue;
                            }
                            if (idx + 1 >= pair.Length)
                                continue;
                            key = pair.Substring(idx + 1);
                            if (key.Length > 1)
                            {
                                if (key.EndsWith("]"))
                                    key = key.Substring(0, key.Length - 1);
                                if (!Items.ContainsKey(value))
                                    Items.Add(value, key);
                            }
                        }
                        else
                        {
                            if (pair.EndsWith("]"))
                                pair = pair.Substring(0, pair.Length - 1);
                            if (!int.TryParse(pair, NumberStyles.Integer, CultureInfo.InvariantCulture, out value))
                                continue;
                            if (!Items.ContainsKey(value))
                                Items.Add(value, pair);
                        }
                    }
                }
            }
        }
Esempio n. 5
0
File: TinyG.cs Progetto: x893/CNCGUI
 public void Set(ScanFormatted scanf, bool use_items)
 {
     if (use_items)
     {
         Set(scanf);
     }
     else if (scanf.Results.Count >= 1)
     {
         Items = null;
         Set(scanf.Results[0]);
     }
 }
Esempio n. 6
0
        public void Set(ScanFormatted scanf)
        {
            if (scanf.Results.Count >= 1)
            {
                Set(scanf.Results[0]);
            }

            if (scanf.Results.Count >= 2)
            {
                if (Items == null)
                {
                    Items = new Dictionary <int, string>();
                }
                else
                {
                    Items.Clear();
                }

                foreach (string item in ((string)scanf.Results[1]).Split(Common.CHAR_COMMA))
                {
                    string pair = item.Trim();
                    int    value = -1; string key = string.Empty;
                    int    idx;
                    if (!string.IsNullOrEmpty(pair))
                    {
                        if ((idx = pair.IndexOf('=')) >= 0)
                        {
                            if (idx > 0)
                            {
                                if (!int.TryParse(pair.Substring(0, idx), NumberStyles.Integer, CultureInfo.InvariantCulture, out value))
                                {
                                    continue;
                                }
                            }
                            if (idx + 1 >= pair.Length)
                            {
                                continue;
                            }
                            key = pair.Substring(idx + 1);
                            if (key.Length > 1)
                            {
                                if (key.EndsWith("]"))
                                {
                                    key = key.Substring(0, key.Length - 1);
                                }
                                if (!Items.ContainsKey(value))
                                {
                                    Items.Add(value, key);
                                }
                            }
                        }
                        else
                        {
                            if (pair.EndsWith("]"))
                            {
                                pair = pair.Substring(0, pair.Length - 1);
                            }
                            if (!int.TryParse(pair, NumberStyles.Integer, CultureInfo.InvariantCulture, out value))
                            {
                                continue;
                            }
                            if (!Items.ContainsKey(value))
                            {
                                Items.Add(value, pair);
                            }
                        }
                    }
                }
            }
        }