summary refs log tree commit diff stats
diff options
context:
space:
mode:
-rw-r--r--lib/token.cpp32
1 files changed, 30 insertions, 2 deletions
diff --git a/lib/token.cpp b/lib/token.cpp index ce201b4..2fd6d44 100644 --- a/lib/token.cpp +++ b/lib/token.cpp
@@ -344,12 +344,26 @@ namespace verbly {
344 } 344 }
345 } 345 }
346 346
347 if ((capitalization == casing::capitalize) || (capitalization == casing::title_case)) 347 if (capitalization == casing::capitalize)
348 { 348 {
349 if (std::isalpha(result[0])) 349 if (std::isalpha(result[0]))
350 { 350 {
351 result[0] = std::toupper(result[0]); 351 result[0] = std::toupper(result[0]);
352 } 352 }
353 } else if (capitalization == casing::title_case)
354 {
355 std::list<std::string> swords =
356 split<std::list<std::string>>(result, " ");
357
358 for (std::string& sword : swords)
359 {
360 if (std::isalpha(sword[0]))
361 {
362 sword[0] = std::toupper(sword[0]);
363 }
364 }
365
366 result = implode(std::begin(swords), std::end(swords), " ");
353 } else if (capitalization == casing::all_caps) 367 } else if (capitalization == casing::all_caps)
354 { 368 {
355 for (char& ch : result) 369 for (char& ch : result)
@@ -381,12 +395,26 @@ namespace verbly {
381 } 395 }
382 } 396 }
383 397
384 if ((capitalization == casing::capitalize) || (capitalization == casing::title_case)) 398 if (capitalization == casing::capitalize)
385 { 399 {
386 if (std::isalpha(result[0])) 400 if (std::isalpha(result[0]))
387 { 401 {
388 result[0] = std::toupper(result[0]); 402 result[0] = std::toupper(result[0]);
389 } 403 }
404 } else if (capitalization == casing::title_case)
405 {
406 std::list<std::string> swords =
407 split<std::list<std::string>>(result, " ");
408
409 for (std::string& sword : swords)
410 {
411 if (std::isalpha(sword[0]))
412 {
413 sword[0] = std::toupper(sword[0]);
414 }
415 }
416
417 result = implode(std::begin(swords), std::end(swords), " ");
390 } else if (capitalization == casing::all_caps) 418 } else if (capitalization == casing::all_caps)
391 { 419 {
392 for (char& ch : result) 420 for (char& ch : result)