Exemplo n.º 1
0
        public void Parse(string aValue)
        {
            Match m = KRegEx.Match(aValue);

            if (m.Success)
            {
                string min = m.Groups["Min"].Value.Replace("0x", string.Empty);
                string max = m.Groups["Max"].Value.Replace("0x", string.Empty);

                // Also need to know if they are hex or decimal specifiers
                int baseMin = (m.Groups[0].Value == "0x" ? 16 : 10);
                int baseMax = (m.Groups[1].Value == "0x" ? 16 : 10);

                // Now convert
                uint valueMin = System.Convert.ToUInt32(min, baseMin);
                uint valueMax = System.Convert.ToUInt32(max, baseMax);

                // Make range...
                AddressRange transaction = TransactionBegin();
                //
                UpdateMin(valueMin);
                UpdateMin(valueMax);
                //
                TransactionEnd(transaction);
            }
            else
            {
                throw new ArgumentException("Invalid range format - expected [0x]AAA - [0x]BBB");
            }
        }
 public void LoadFromFile(string aFileName)
 {
     using (StreamReader reader = new StreamReader(new FileStream(aFileName, FileMode.Open, FileAccess.Read)))
     {
         string line = reader.ReadLine();
         while (line != null)
         {
             Match m = KRegEx.Match(line);
             if (m.Success)
             {
                 int    scanCode = int.Parse(m.Groups["ScanCode"].Value, System.Globalization.NumberStyles.HexNumber);
                 string value    = m.Groups["Interpretation"].Value;
                 //
                 if (iTable.ContainsKey(scanCode) == false)
                 {
                     iTable.Add(scanCode, value);
                 }
             }
             line = reader.ReadLine();
         }
     }
 }
Exemplo n.º 3
0
 public RegExTranslatorExtractionInfo(string aLine, int aStartPos)
 {
     iMatch = KRegEx.Match(aLine, aStartPos);
 }