Home | History | Annotate | Download | only in spellchecker
      1 // Copyright (c) 2011 The Chromium Authors. All rights reserved.
      2 // Use of this source code is governed by a BSD-style license that can be
      3 // found in the LICENSE file.
      4 
      5 #ifndef CHROME_BROWSER_SPELLCHECKER_WORD_TRIMMER_H_
      6 #define CHROME_BROWSER_SPELLCHECKER_WORD_TRIMMER_H_
      7 
      8 #include "base/strings/string16.h"
      9 
     10 // Trims |text| to contain only the range from |start| to |end| and |keep| words
     11 // on either side of the range. The |start| and |end| parameters are character
     12 // indexes into |text|. The |keep| parameter is the number of words to keep on
     13 // either side of the |start|-|end| range. The function updates |start| in
     14 // accordance with the trimming.
     15 //
     16 // Example:
     17 //
     18 //  size_t start = 14;
     19 //  size_t end = 23;
     20 //  string16 text = ASCIIToUTF16("one two three four five six seven eight");
     21 //  int keep = 2;
     22 //  string16 trimmed = TrimWords(&start, end, text, keep);
     23 //  DCHECK(trimmed == ASCIIToUTF16("two three four five six seven"));
     24 //  DCHECK(start == 10);
     25 //
     26 string16 TrimWords(
     27     size_t* start,
     28     size_t end,
     29     const string16& text,
     30     size_t keep);
     31 
     32 #endif  // CHROME_BROWSER_SPELLCHECKER_WORD_TRIMMER_H_
     33