• R/O
  • SSH
  • HTTPS

eirsamples: Commit


Commit MetaInfo

Revision35 (tree)
Time2020-10-16 00:16:56
Authorquiret

Log Message

- added support for writing signed integers
- added more helpful text

Change Summary

Incremental Difference

--- rwchunk-writer/src/main.cpp (revision 34)
+++ rwchunk-writer/src/main.cpp (revision 35)
@@ -276,7 +276,7 @@
276276 }
277277 else
278278 {
279- std::cout << "not enough params" << std::endl;
279+ std::cout << "not enough params (lmaj, lmin, rmaj, rmin)" << std::endl;
280280 }
281281 }
282282 else if ( current_block.inContext() && current_block.getBlockID() == CHUNK_STRUCT )
@@ -310,7 +310,7 @@
310310 }
311311 else
312312 {
313- std::cout << "invalid param count" << std::endl;
313+ std::cout << "invalid param count (bitcnt, value)" << std::endl;
314314 }
315315 }
316316 else if ( BoundedStringEqual( maincmd.GetConstString(), maincmd.GetLength(), "uint8", false ) )
@@ -330,6 +330,23 @@
330330 std::cout << "invalid param count" << std::endl;
331331 }
332332 }
333+ else if ( BoundedStringEqual( maincmd.GetConstString(), maincmd.GetLength(), "int8", false ) )
334+ {
335+ recognized_cmd = true;
336+
337+ if ( tokens.GetCount() >= 2 )
338+ {
339+ int8_t value = eir::to_number_len <int8_t> ( tokens[1].GetConstString(), tokens[1].GetLength() );
340+
341+ flush_bits();
342+
343+ current_block.writeInt8( value );
344+ }
345+ else
346+ {
347+ std::cout << "invalid param count" << std::endl;
348+ }
349+ }
333350 else if ( BoundedStringEqual( maincmd.GetConstString(), maincmd.GetLength(), "uint16", false ) )
334351 {
335352 recognized_cmd = true;
@@ -352,6 +369,28 @@
352369 std::cout << "invalid param count" << std::endl;
353370 }
354371 }
372+ else if ( BoundedStringEqual( maincmd.GetConstString(), maincmd.GetLength(), "int16", false ) )
373+ {
374+ recognized_cmd = true;
375+
376+ if ( tokens.GetCount() >= 2 )
377+ {
378+ int16_t value = eir::to_number_len <int16_t> ( tokens[1].GetConstString(), tokens[1].GetLength() );
379+
380+ flush_bits();
381+
382+ if ( enable_alignments )
383+ {
384+ byteAlignBlockProvider <2> ( &current_block );
385+ }
386+
387+ current_block.writeInt16( value );
388+ }
389+ else
390+ {
391+ std::cout << "invalid param count" << std::endl;
392+ }
393+ }
355394 else if ( BoundedStringEqual( maincmd.GetConstString(), maincmd.GetLength(), "uint32", false ) )
356395 {
357396 recognized_cmd = true;
@@ -374,6 +413,28 @@
374413 std::cout << "invalid param count" << std::endl;
375414 }
376415 }
416+ else if ( BoundedStringEqual( maincmd.GetConstString(), maincmd.GetLength(), "int32", false ) )
417+ {
418+ recognized_cmd = true;
419+
420+ if ( tokens.GetCount() >= 2 )
421+ {
422+ int32_t value = eir::to_number_len <int32_t> ( tokens[1].GetConstString(), tokens[1].GetLength() );
423+
424+ flush_bits();
425+
426+ if ( enable_alignments )
427+ {
428+ byteAlignBlockProvider <4> ( &current_block );
429+ }
430+
431+ current_block.writeInt32( value );
432+ }
433+ else
434+ {
435+ std::cout << "invalid param count" << std::endl;
436+ }
437+ }
377438 else if ( BoundedStringEqual( maincmd.GetConstString(), maincmd.GetLength(), "uint64", false ) )
378439 {
379440 recognized_cmd = true;
@@ -396,6 +457,28 @@
396457 std::cout << "invalid param count" << std::endl;
397458 }
398459 }
460+ else if ( BoundedStringEqual( maincmd.GetConstString(), maincmd.GetLength(), "int64", false ) )
461+ {
462+ recognized_cmd = true;
463+
464+ if ( tokens.GetCount() >= 2 )
465+ {
466+ int64_t value = eir::to_number_len <int64_t> ( tokens[1].GetConstString(), tokens[1].GetLength() );
467+
468+ flush_bits();
469+
470+ if ( enable_alignments )
471+ {
472+ byteAlignBlockProvider <8> ( &current_block );
473+ }
474+
475+ current_block.writeInt64( value );
476+ }
477+ else
478+ {
479+ std::cout << "invalid param count" << std::endl;
480+ }
481+ }
399482 else if ( BoundedStringEqual( maincmd.GetConstString(), maincmd.GetLength(), "fixchar", false ) )
400483 {
401484 recognized_cmd = true;
@@ -421,7 +504,7 @@
421504 }
422505 else
423506 {
424- std::cout << "invalid param count" << std::endl;
507+ std::cout << "invalid param count (num, str)" << std::endl;
425508 }
426509 }
427510 else if ( BoundedStringEqual( maincmd.GetConstString(), maincmd.GetLength(), "byterep", false ) )
@@ -442,7 +525,7 @@
442525 }
443526 else
444527 {
445- std::cout << "invalid param count" << std::endl;
528+ std::cout << "invalid param count (byteval, repcnt)" << std::endl;
446529 }
447530 }
448531 else if ( BoundedStringEqual( maincmd.GetConstString(), maincmd.GetLength(), "bitrep", false ) )
@@ -477,7 +560,7 @@
477560 }
478561 else
479562 {
480- std::cout << "invalid param count" << std::endl;
563+ std::cout << "invalid param count (bitcnt, value, repcnt)" << std::endl;
481564 }
482565 }
483566 }
Show on old repository browser