Exemple #1
0
 private Stringe(Stringe parent, int relativeOffset, int length)
 {
     _stref     = parent._stref;
     _offset    = parent._offset + relativeOffset;
     _length    = length;
     _substring = null;
 }
Exemple #2
0
 internal Stringe(Stringe value)
 {
     _stref     = value._stref;
     _offset    = value._offset;
     _length    = value._length;
     _offset    = value._offset;
     _substring = value._substring;
 }
Exemple #3
0
 internal Stringe(Stringe value)
 {
     _stref     = value._stref;
     _offset    = value._offset;
     _length    = value._length;
     _line      = value._line;
     _column    = value._column;
     _offset    = value._offset;
     _substring = value._substring;
 }
Exemple #4
0
 /// <summary>
 /// Creates a new stringe from the specified string.
 /// </summary>
 /// <param name="value">The string to turn into a stringe.</param>
 public Stringe(string value)
 {
     if (value == null)
     {
         throw new ArgumentNullException(nameof(value));
     }
     _stref     = new Stref(this, value);
     _offset    = 0;
     _length    = value.Length;
     _substring = null;
 }
Exemple #5
0
 /// <summary>
 /// Creates a new stringe from the specified string.
 /// </summary>
 /// <param name="value">The string to turn into a stringe.</param>
 public Stringe(string value)
 {
     if (value == null)
     {
         throw new ArgumentNullException("value");
     }
     _stref     = new Stref(value);
     _offset    = 0;
     _length    = value.Length;
     _line      = 1;
     _column    = 1;
     _substring = null;
 }
Exemple #6
0
        private Stringe(Stringe parent, int relativeOffset, int length)
        {
            _stref     = parent._stref;
            _offset    = parent._offset + relativeOffset;
            _length    = length;
            _substring = null;

            // Calculate line/col
            _line   = parent._line;
            _column = parent._column;

            // If the offset is to the left, the line/col is already calculated. Fetch it from the Chare cache.
            if (relativeOffset < 0)
            {
                _line   = _stref.Chares[_offset].Line;
                _column = _stref.Chares[_offset].Column;
                return;
            }

            if (relativeOffset == 0)
            {
                return;                      // Do nothing if the offset is the same
            }
            int aOffset;

            for (int i = 0; i < relativeOffset; i++)
            {
                aOffset = parent._offset + i;
                if (_stref.String[aOffset] == '\n')
                {
                    _line++;
                    _column = 1;
                }
                else if (_stref.Bases[i]) // Advance column only for non-combining characters
                {
                    _column++;
                }
                if (_stref.Chares[aOffset] == null)
                {
                    _stref.Chares[aOffset] = new Chare(parent, _stref.String[aOffset], aOffset, _line, _column);
                }
            }
        }