-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathSimpleBaseFactory.cpp
More file actions
132 lines (108 loc) · 3.04 KB
/
Copy pathSimpleBaseFactory.cpp
File metadata and controls
132 lines (108 loc) · 3.04 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
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
// ///////////////////////////////////////////////////////////////// //
// *C++ 11 SimpleBaseLib4CPP Library
// *Copyright(c) 2021 Mbadiwe Nnaemeka Ronald
// *Github Repository <https://github.com/ron4fun>
// *Distributed under the MIT software license, see the accompanying file LICENSE
// *or visit http ://www.opensource.org/licenses/mit-license.php.
// *Acknowledgements:
// ** //
// *Thanks to Ugochukwu Mmaduekwe (https://github.com/Xor-el) for his creative
// *development of this library in Pascal/Delphi
// ////////////////////////////////////////////////////// ///////////////
#include "Base16.h"
#include "Base32.h"
#include "Base32Alphabet.h"
#include "Base58.h"
#include "Base58Alphabet.h"
#include "Base64.h"
#include "Base64Alphabet.h"
#include "SimpleBaseFactory.h"
bool SimpleBaseFactory::isBoot = false;
IBase16 SimpleBaseFactory::CreateBase16()
{
Boot();
return make_shared<Base16>();
}
IBase32 SimpleBaseFactory::CreateBase32(const IBase32Alphabet alphabet)
{
Boot();
return make_shared<Base32>(alphabet);
}
IBase32 SimpleBaseFactory::CreateBase32Crockford()
{
Boot();
return make_shared<Base32>(Base32Alphabet::GetCrockford());
}
IBase32 SimpleBaseFactory::CreateBase32ExtendedHex()
{
Boot();
return make_shared<Base32>(Base32Alphabet::GetExtendedHex());
}
IBase32 SimpleBaseFactory::CreateBase32Rfc4648()
{
Boot();
return make_shared<Base32>(Base32Alphabet::GetRfc4648());
}
IBase58 SimpleBaseFactory::CreateBase58(const IBase58Alphabet alphabet)
{
Boot();
return make_shared<Base58>(alphabet);
}
IBase58 SimpleBaseFactory::CreateBase58BitCoin()
{
Boot();
return make_shared<Base58>(Base58Alphabet::GetBitCoin());
}
IBase58 SimpleBaseFactory::CreateBase58Flickr()
{
Boot();
return make_shared<Base58>(Base58Alphabet::GetFlickr());
}
IBase58 SimpleBaseFactory::CreateBase58Ripple()
{
Boot();
return make_shared<Base58>(Base58Alphabet::GetRipple());
}
IBase64 SimpleBaseFactory::CreateBase64(const IBase64Alphabet alphabet)
{
Boot();
return make_shared<Base64>(alphabet);
}
IBase64 SimpleBaseFactory::CreateBase64Default()
{
Boot();
return make_shared<Base64>(Base64Alphabet::GetDefault());
}
IBase64 SimpleBaseFactory::CreateBase64DefaultNoPadding()
{
Boot();
return make_shared<Base64>(Base64Alphabet::GetDefaultNoPadding());
}
IBase64 SimpleBaseFactory::CreateBase64FileEncoding()
{
Boot();
return make_shared<Base64>(Base64Alphabet::GetFileEncoding());
}
IBase64 SimpleBaseFactory::CreateBase64RegExEncoding()
{
Boot();
return make_shared<Base64>(Base64Alphabet::GetRegExEncoding());
}
IBase64 SimpleBaseFactory::CreateBase64UrlEncoding()
{
Boot();
return make_shared<Base64>(Base64Alphabet::GetUrlEncoding());
}
IBase64 SimpleBaseFactory::CreateBase64XmlEncoding()
{
Boot();
return make_shared<Base64>(Base64Alphabet::GetXmlEncoding());
}
void SimpleBaseFactory::Boot()
{
if (isBoot) return;
Base32Alphabet::Boot();
Base58Alphabet::Boot();
Base64Alphabet::Boot();
isBoot = true;
}