2323
2424namespace nodepp { namespace encoder { namespace key {
2525
26- string_t generate ( const string_t & alph, int x=32 ){ ulong idx=0 ;
26+ inline string_t generate ( const string_t & alph, int x=32 ){ ulong idx=0 ;
2727 string_t data ( (ulong)x, ' \0 ' ); for ( auto &x: data ){
2828 x = alph[rand ()%(alph.size ())]; ++idx; } return data;
2929 }
3030
31- string_t generate ( int x=32 ) { return generate ( NODEPP_BASE64, x ); }
31+ inline string_t generate ( int x=32 ) { return generate ( NODEPP_BASE64, x ); }
3232
3333}}}
3434
3535/* ────────────────────────────────────────────────────────────────────────────*/
3636
3737namespace nodepp { namespace encoder { namespace hash {
3838
39- ulong get ( const string_t & key, int tableSize ) {
39+ inline ulong get ( const string_t & key, int tableSize ) {
4040 ulong hash = 5381 ; forEach ( x, key ) {
4141 hash = ((hash << 5 ) + hash) + x;
4242 } return hash % tableSize;
4343 }
4444
45- ulong get ( int key, int tableSize ) { return key % tableSize; }
45+ inline ulong get ( int key, int tableSize ) { return key % tableSize; }
4646
47- ulong get ( const string_t & key ) { return get ( key, HASH_TABLE_SIZE ); }
47+ inline ulong get ( const string_t & key ) { return get ( key, HASH_TABLE_SIZE ); }
4848
4949}}}
5050
5151/* ────────────────────────────────────────────────────────────────────────────*/
5252
5353namespace nodepp { namespace encoder { namespace XOR {
5454
55- string_t get ( string_t data, const string_t & key ){
55+ inline string_t get ( string_t data, const string_t & key ){
5656 auto tmp= data.copy ();
5757 ulong pos= 0 ; forEach ( x, tmp ) {
5858 x = x^ key[pos]; ++pos;
5959 pos %= key.size ();
6060 } return tmp;
6161 }
6262
63- string_t set ( string_t data, const string_t & key ){
63+ inline string_t set ( string_t data, const string_t & key ){
6464 auto tmp= data.copy ();
6565 ulong pos= 0 ; forEach ( x, tmp ) {
6666 x = x^ key[pos]; ++pos;
@@ -173,14 +173,14 @@ namespace nodepp { namespace encoder { namespace hex {
173173
174174namespace nodepp { namespace encoder { namespace hex {
175175
176- string_t get ( const ptr_t <uchar>& inp ){
176+ inline string_t get ( const ptr_t <uchar>& inp ){
177177 if ( inp.empty () ){ return nullptr ; }
178178 queue_t <char > out; for ( auto x : inp ){
179179 for ( auto y: get (x) ){ out.push ( y ); }
180180 } out.push (' \0 ' ); return string_t ( out.data () );
181181 }
182182
183- ptr_t <uchar> set ( string_t x ){
183+ inline ptr_t <uchar> set ( string_t x ){
184184 if ( x.empty () ){ return nullptr ; }
185185 ulong size = x.size ()/2 + ( x.size ()%2 != 0 ?1 :0 );
186186 ptr_t <uchar> out (size,' \0 ' ); for ( auto &y : out ){
@@ -190,25 +190,25 @@ namespace nodepp { namespace encoder { namespace hex {
190190
191191 /* ─······································································─*/
192192
193- ptr_t <uchar> btoa ( string_t inp ) { return set ( inp ); }
193+ inline ptr_t <uchar> btoa ( string_t inp ) { return set ( inp ); }
194194
195- string_t atob ( const ptr_t <uchar>& inp ) { return get ( inp ); }
195+ inline string_t atob ( const ptr_t <uchar>& inp ) { return get ( inp ); }
196196
197197}}}
198198
199199/* ────────────────────────────────────────────────────────────────────────────*/
200200
201201namespace nodepp { namespace encoder { namespace buffer {
202202
203- string_t hex2buff ( const string_t & inp ){
203+ inline string_t hex2buff ( const string_t & inp ){
204204 if ( inp.empty () ){ return nullptr ; }
205205 ptr_t <uchar> buff = hex::set (inp);
206206 string_t raw ( buff.size () + 1 );
207207 memcpy ( raw.get (), &buff, buff.size () );
208208 return raw;
209209 }
210210
211- string_t buff2hex ( const string_t & inp ){
211+ inline string_t buff2hex ( const string_t & inp ){
212212 if ( inp.empty () ){ return nullptr ; }
213213 auto raw = ptr_t <uchar>( inp.size () );
214214 memcpy ( &raw, inp.get (), inp.size () );
@@ -217,27 +217,27 @@ namespace nodepp { namespace encoder { namespace buffer {
217217
218218 /* ─······································································─*/
219219
220- string_t atob ( const string_t & inp ) { return buff2hex ( inp ); }
220+ inline string_t atob ( const string_t & inp ) { return buff2hex ( inp ); }
221221
222- string_t btoa ( const string_t & inp ) { return hex2buff ( inp ); }
222+ inline string_t btoa ( const string_t & inp ) { return hex2buff ( inp ); }
223223
224224}}}
225225
226226/* ────────────────────────────────────────────────────────────────────────────*/
227227
228228namespace nodepp { namespace encoder { namespace base16 {
229229
230- string_t atob ( const string_t & inp ) { return buffer::buff2hex ( inp ); }
230+ inline string_t atob ( const string_t & inp ) { return buffer::buff2hex ( inp ); }
231231
232- string_t btoa ( const string_t & inp ) { return buffer::hex2buff ( inp ); }
232+ inline string_t btoa ( const string_t & inp ) { return buffer::hex2buff ( inp ); }
233233
234234}}}
235235
236236/* ────────────────────────────────────────────────────────────────────────────*/
237237
238238namespace nodepp { namespace encoder { namespace base64 {
239239
240- string_t get ( const string_t &in ) {
240+ inline string_t get ( const string_t &in ) {
241241
242242 queue_t <char > out; int pos1 = 0 , pos2 = -6 ;
243243
@@ -255,7 +255,7 @@ namespace nodepp { namespace encoder { namespace base64 {
255255 out.push (' \0 ' ); return string_t ( out.data () );
256256 }
257257
258- string_t set ( const string_t &in ) {
258+ inline string_t set ( const string_t &in ) {
259259
260260 queue_t <char > out; int pos1=0 , pos2=-8 ;
261261 array_t <int > T ( 256 , -1 );
@@ -274,31 +274,31 @@ namespace nodepp { namespace encoder { namespace base64 {
274274
275275 /* ─······································································─*/
276276
277- string_t btoa ( const string_t &in ) { return set ( in ); }
277+ inline string_t btoa ( const string_t &in ) { return set ( in ); }
278278
279- string_t atob ( const string_t &in ) { return get ( in ); }
279+ inline string_t atob ( const string_t &in ) { return get ( in ); }
280280
281281}}}
282282
283283/* ────────────────────────────────────────────────────────────────────────────*/
284284
285285namespace nodepp { namespace encoder { namespace utf8 {
286- ptr_t <uint16> to_utf16 ( ptr_t <uint8> inp ){ return utf::utf8_to_utf16 ( inp ); }
287- ptr_t <uint32> to_utf32 ( ptr_t <uint8> inp ){ return utf::utf8_to_utf32 ( inp ); }
286+ inline ptr_t <uint16> to_utf16 ( ptr_t <uint8> inp ){ return utf::utf8_to_utf16 ( inp ); }
287+ inline ptr_t <uint32> to_utf32 ( ptr_t <uint8> inp ){ return utf::utf8_to_utf32 ( inp ); }
288288}}}
289289
290290/* ────────────────────────────────────────────────────────────────────────────*/
291291
292292namespace nodepp { namespace encoder { namespace utf16 {
293- ptr_t <uint8> to_utf8 ( ptr_t <uint16> inp ){ return utf::utf16_to_utf8 ( inp ); }
294- ptr_t <uint32> to_utf32 ( ptr_t <uint16> inp ){ return utf::utf16_to_utf32 ( inp ); }
293+ inline ptr_t <uint8> to_utf8 ( ptr_t <uint16> inp ){ return utf::utf16_to_utf8 ( inp ); }
294+ inline ptr_t <uint32> to_utf32 ( ptr_t <uint16> inp ){ return utf::utf16_to_utf32 ( inp ); }
295295}}}
296296
297297/* ────────────────────────────────────────────────────────────────────────────*/
298298
299299namespace nodepp { namespace encoder { namespace utf32 {
300- ptr_t <uint8> to_utf8 ( ptr_t <uint32> inp ){ return utf::utf32_to_utf8 ( inp ); }
301- ptr_t <uint16> to_utf16 ( ptr_t <uint32> inp ){ return utf::utf32_to_utf16 ( inp ); }
300+ inline ptr_t <uint8> to_utf8 ( ptr_t <uint32> inp ){ return utf::utf32_to_utf8 ( inp ); }
301+ inline ptr_t <uint16> to_utf16 ( ptr_t <uint32> inp ){ return utf::utf32_to_utf16 ( inp ); }
302302}}}
303303
304304/* ────────────────────────────────────────────────────────────────────────────*/
0 commit comments