-
Notifications
You must be signed in to change notification settings - Fork 0
Methods
Below is every new method added with NStrings.
| Method Name | Short Explanation |
|---|---|
sheer() |
Cuts a set amount data from one string and saves it to another |
sheerUntilDelim() |
Cuts all data before set delimiter from one string and saves it to another |
autoForm() |
Removes marked characters and replaces spaces with underscores |
divideByDelim() |
Breaks up a string into a vector using a set delimiter |
baseLaw() |
Sets a basic rule set for AutoForm |
addLaw() |
Adds a charecter to the ruleset used by AutoForm to be removed |
rmvLaw() |
Removes a charecter to the ruleset used by AutoForm |
getLaws() |
Prints the ruleset used by AutoForm to console |
has() |
Returns true or false if a string contains a specific charecter |
howMany() |
Returns an int of how many of a specific charecter a string has |
sheer(); removes designated characters from a string and adds them to another.
The syntax is:
nstring1 = nstring2.sheer(int star, int amt);
| VarName | Use |
|---|---|
| star | int value indicate the index that the sheer(); method should start at |
| amt | int value representing how many characters from the starting position should be sheered |
#include "nstring.h"
#include <iostream>
/*output of the code below:
* hello
* 987489
*/
using namesapce std;
int main()
{
nstring myStr;
nstring save;
myStr.append("98749hello");
save = myStr.sheer(0, 5);
cout << myStr << endl;
cout << save << endl;
return 0;
}sheerUntilDelim(); removes designated characters from a string and adds them to another using a marking character to indicate when the sheering should stop.
The syntax is:
nstring1 = nstring2.sheerUntilDelim(char m, int star, bool remMar);
| VarName | Use |
|---|---|
| m | character meant to mark where the function should stop |
| star | int value indicate the index that the method should start at |
| remMar | bool value indicating if the marking character should be deleted after the sheer |
#include "nstring.h"
#include <iostream>
/*The output of the code below:
* hello
* 98749
*/
using namesapce std;
int main()
{
nstring myStr;
nstring save;
myStr.append("98749_hello");
save = myStr.sheerUntilDelim('_', 0, true);
cout << myStr << endl;
cout << save << endl;
return 0;
}autoForm(), standing for automatic format, is useful to make any string follow general legality that is used in things like filenames. It removes all characters that are marked in the private vector illegalChars and replaces spaces with underscores.
! YOU MUST SET ILLEGALCHARS IN ORDER FOR AUTOFORM TO CHANGE ANYTHING OUT SIDE OF SPACES ! see legal family
The syntax is:
nstringObj.autoForm();autoForm() takes no parameters.
#include "nstring.h"
#include <iostream>
/*The output of the code below:
* example_File_Name.txt
*/
using namesapce std;
int main()
{
nstring myStr
myStr.append("example File Name!!!");
myStr.autoForm();
myStr.append(".txt")
std::cout << myStr << std::endl;
return 0;
}divideByDelim(); breaks a string into separate parts based on a provided delimitator. It also can erase the data of the base string if that is deemed as necessary.
The syntax is:
nstringObj.divideByDelim(char delim, bool clear);
| VarName | Use |
|---|---|
| delim | The delimitator to divide by |
| clear | Dictates if the base string should be erased or not |
#include "nstring.h"
#include <iostream>
/*The output of the code below:
* 280 039 459
* 280.039.459
*/
using namesapce std;
int main()
{
nstring test;
vector<nstring> divd;
test = "280.039.459";
divd = test.divideByDelim('.',false);
cout << divd[0] << ' ' << divd[1] << ' ' << divd[2] << endl;
cout << test;
}baseLaw() populates sets illegalChars to very common characters that are illegal to have in things like file names. Below is a list of all charecters included in baseLaw():
# % & { } \ < > * ? / $ ! ' " : @ + ` \ =
The syntax is:
nstringObj.baseLaw();baseLaw() takes no parameters.
#include "nstring.h"
#include <iostream>
using namesapce std;
int main()
{
nstring myStr
myStr.append("example");
myStr.baseLaw();
return 0;
}addLaw() adds the specified character to illegalChars.
The syntax is:
nstringObj.addLaw(char outlaw);| VarName | Use |
|---|---|
| outlaw | character to be added to illegalChars |
#include "nstring.h"
#include <iostream>
using namesapce std;
/* output:
* xampl
*/
int main()
{
nstring myStr
myStr.append("example");
myStr.addLaw('e');
myStr.autoForm(); //see autoForm() in Format Familly
cout << myStr;
return 0;
}rmvLaw() removes the specified character to illegalChars.
The syntax is:
nstringObj.rmvLaw(char legal);| VarName | Use |
|---|---|
| legal | character to be removed to illegalChars |
#include "nstring.h"
#include <iostream>
using namesapce std;
/* output:
* @example
*/
int main()
{
nstring myStr
myStr.append("@example!");
myStr.baseLaw();
myStr.rmvLaw('@');
myStr.autoForm(); //see autoForm() in Format Familly
cout << myStr;
return 0;
}getLaws() prints all the current illegal characters of a nstring object to the console. It exists to be a form of sanity check to see what is marked as illegal.
The syntax is:
nstringObj.getLaws();getLaws() takes no parameters
#include "nstring.h"
#include <iostream>
using namesapce std;
/* output:
* Laws: e
*/
int main()
{
nstring myStr
myStr.append("example");
myStr.addLaw('e');
myStr.getLaws();
return 0;
}has() returns a bool that is true or false depending on if the calling object has the target character.
The syntax is:
nstringObj.has(char target);| VarName | Use |
|---|---|
| target | character that each character in the calling object will be compared to |
#include "nstring.h"
#include <iostream>
using namesapce std;
/* output:
* True
*/
int main()
{
nstring myStr
myStr.append("example");
cout << myStr.has('e');
return 0;
}howMany() returns an int that is depending on how many of the target character the calling object has.
The syntax is:
nstringObj.howMany(char target);| VarName | Use |
|---|---|
| target | character that each character in the calling object will be compared to |
#include "nstring.h"
#include <iostream>
using namesapce std;
/* output:
* 2
*/
int main()
{
nstring myStr
myStr.append("example");
cout << myStr.howMany('e');
return 0;
}Revisions underway
This project is still in very early stages. Documentation will be updated with code to the best of my ability.