Skip to content
This repository has been archived by the owner on May 19, 2024. It is now read-only.
/ left_pad_cpp Public archive

Unopinionated C++ version of the popular left_pad NPM module

Notifications You must be signed in to change notification settings

arhuaco/left_pad_cpp

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

19 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

left_pad_cpp

Unopinionated C++ version of the popular left_pad.

See: https://www.npmjs.com/package/left-pad

Features

  • In not_kik namespace. Makes it safer from future lawsuits.
  • Two functions provided, as well as object oriented interface.
  • Cheaper than http://left-pad.io
  • Not written in JavaScript.
  • Peer reviewed.

Usage

Copying version.

std::cout << not_kik::LeftPad("foo", 5, '+') << std::endl;
std::cout << not_kik::LeftPad("foo", -1, '+') << std::endl;
// Outputs: "++foo" and "foo".

In-place version.

std::string foo("foo");
not_kik::LeftPad(5, '+', &foo);
std::cout << foo << std::endl;
foo = "foo";
not_kik::LeftPad(-1, '+', &foo);
std::cout << foo << std::endl;
// Outputs: "++foo" and "foo".

Object oriented interface.

not_kik::LeftPadder plus_left_padder('+');
std::cout << plus_left_padder.Pad("foo", 5) << std::endl;
std::cout << plus_left_padder.Pad("foo", -2) << std::endl;
// Outputs: "++foo" and "foo".

Future work

  • Add RightPad.
  • Python bindings.
  • Better unit testing with gtest framework.
  • Algorithmic optimizations.

License

In case you don't like the advertising BSD license, a commercial license is available.

In other languages

About

Unopinionated C++ version of the popular left_pad NPM module

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published