aboutsummaryrefslogtreecommitdiff
path: root/dw/hyphenator.cc
diff options
context:
space:
mode:
authorsgeerken <devnull@localhost>2012-06-27 23:08:21 +0200
committersgeerken <devnull@localhost>2012-06-27 23:08:21 +0200
commita8b898689f534f8218d707aa4c41292903126b27 (patch)
tree23ab3bae65a384b5b0c581c8f390cd63941f92ad /dw/hyphenator.cc
parentd3dd7eb3379c495cfd9a138d36e40a410188f202 (diff)
Changed interface (but not yet implementation) of Hyphenator.
Diffstat (limited to 'dw/hyphenator.cc')
-rw-r--r--dw/hyphenator.cc21
1 files changed, 20 insertions, 1 deletions
diff --git a/dw/hyphenator.cc b/dw/hyphenator.cc
index b617993a..f6f85009 100644
--- a/dw/hyphenator.cc
+++ b/dw/hyphenator.cc
@@ -130,7 +130,7 @@ bool Hyphenator::isHyphenationCandidate (const char *word)
* Given a word, returns a list of pieces, broken at the possible
* hyphenation points.
*/
-Vector <String> *Hyphenator::hyphenateWord(const char *word)
+Vector <String> *Hyphenator::_hyphenateWord(const char *word)
{
Vector <String> *pieces = new Vector <String> (1, true);
@@ -207,4 +207,23 @@ Vector <String> *Hyphenator::hyphenateWord(const char *word)
return pieces;
}
+int *Hyphenator::hyphenateWord(const char *word, int *numBreaks)
+{
+ Vector <String> *pieces = _hyphenateWord (word);
+ *numBreaks = pieces->size () - 1;
+ int *breakPos;
+ if (numBreaks == 0)
+ breakPos = NULL;
+ else {
+ breakPos = new int[*numBreaks];
+
+ for (int i = 0; i < *numBreaks; i++)
+ breakPos[i] =
+ strlen (pieces->get(i)->chars()) + (i == 0 ? 0 : breakPos[i - 1]);
+ }
+
+ delete pieces;
+ return breakPos;
+}
+
} // namespace dw