-
Notifications
You must be signed in to change notification settings - Fork 3
Expand file tree
/
Copy pathinvoiceutil.cpp
More file actions
49 lines (41 loc) · 1.08 KB
/
invoiceutil.cpp
File metadata and controls
49 lines (41 loc) · 1.08 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
#include "util.h"
#include "invoiceutil.h"
namespace InvoiceUtil {
bool validateInvoiceNumber(std::string input)
{
int size = input.size();
if(size > 32) {
return false;
}
for(int idx=0; idx < size; ++idx)
{
int ch = input.at(idx);
if(((ch >= '0' && ch<='9') ||
(ch >= 'a' && ch<='z') ||
(ch >= 'A' && ch<='Z') ||
(ch == '-')))
{
// Alphanumeric or -
}
else
{
return false;
}
}
return true;
}
void parseInvoiceNumberAndAddress(std::string input, std::string& outAddress, std::string& outInvoiceNumber)
{
size_t plusIndex = input.find('+');
if(plusIndex == string::npos)
{ //no +
outAddress = input;
outInvoiceNumber = "";
}
else
{ //+
outAddress = input.substr(0, plusIndex);
outInvoiceNumber = input.substr(plusIndex + 1, input.size());
}
}
}