1111#include < sourcepp/String.h>
1212
1313using namespace sourcepp ;
14+ using namespace std ::string_view_literals;
1415using namespace toolpp ;
1516
1617namespace {
@@ -467,11 +468,11 @@ void writeOptionalKeyValueStrings(BufferStream& writer, std::initializer_list<st
467468 static constexpr auto writeOptionalString = [](BufferStream& stream, const std::string& str) {
468469 if (!str.empty ()) {
469470 stream
470- .write (" : \" " , 4 )
471+ .write (" : \" " sv, false )
471472 .write (str, false )
472473 .write (' \" ' );
473474 } else {
474- stream.write (" :" , 2 );
475+ stream.write (" :" sv, false );
475476 }
476477 };
477478 for (auto revString = std::rbegin (strings); revString != std::rend (strings); ++revString) {
@@ -605,66 +606,66 @@ FGDWriter FGDWriter::begin() {
605606
606607FGDWriter& FGDWriter::include (const std::string& fgdPath) {
607608 this ->writer
608- .write (" @include \" " , 10 )
609+ .write (" @include \" " sv, false )
609610 .write (fgdPath, false )
610- .write (" \"\n\n " , 3 );
611+ .write (" \"\n\n " sv, false );
611612 return *this ;
612613}
613614
614615FGDWriter& FGDWriter::version (int version) {
615616 this ->writer
616- .write (" @version(" , 9 )
617+ .write (" @version(" sv, false )
617618 .write (std::to_string (version), false )
618- .write (" )\n\n " , 3 );
619+ .write (" )\n\n " sv, false );
619620 return *this ;
620621}
621622
622623FGDWriter& FGDWriter::mapSize (math::Vec2i mapSize) {
623624 this ->writer
624- .write (" @mapsize(" , 9 )
625+ .write (" @mapsize(" sv, false )
625626 .write (std::to_string (mapSize[0 ]), false )
626- .write (" , " , 2 )
627+ .write (" , " sv, false )
627628 .write (std::to_string (mapSize[1 ]), false )
628- .write (" )\n\n " , 3 );
629+ .write (" )\n\n " sv, false );
629630 return *this ;
630631}
631632
632633FGDWriter& FGDWriter::materialExclusionDirs (const std::vector<std::string>& dirs) {
633- this ->writer .write (" @MaterialExclusion\n [\n " , 21 );
634+ this ->writer .write (" @MaterialExclusion\n [\n " sv, false );
634635 for (const auto & dir : dirs) {
635636 this ->writer << ' \t ' << ' \" ' ;
636637 this ->writer .write (dir, false );
637638 this ->writer << ' \" ' << ' \n ' ;
638639 }
639- this ->writer .write (" ]\n\n " , 3 );
640+ this ->writer .write (" ]\n\n " sv, false );
640641 return *this ;
641642}
642643
643644FGDWriter::AutoVisGroupWriter FGDWriter::beginAutoVisGroup (const std::string& parentName) {
644645 this ->writer
645- .write (" @AutoVisGroup = \" " , 17 )
646+ .write (" @AutoVisGroup = \" " sv, false )
646647 .write (parentName, false )
647- .write (" \"\n [\n " , 4 );
648+ .write (" \"\n [\n " sv, false );
648649 return AutoVisGroupWriter{*this };
649650}
650651
651652FGDWriter::AutoVisGroupWriter& FGDWriter::AutoVisGroupWriter::visGroup (const std::string& name, const std::vector<std::string>& entities) {
652653 this ->parent .writer
653- .write (" \t\" " , 2 )
654+ .write (" \t\" " sv, false )
654655 .write (name, false )
655- .write (" \"\n\t [\n " , 5 );
656+ .write (" \"\n\t [\n " sv, false );
656657 for (const auto & entity : entities) {
657658 this ->parent .writer
658- .write (" \t\t\" " , 3 )
659+ .write (" \t\t\" " sv, false )
659660 .write (entity, false )
660- .write (" \"\n " , 2 );
661+ .write (" \"\n " sv, false );
661662 }
662- this ->parent .writer .write (" \t ]\n " , 3 );
663+ this ->parent .writer .write (" \t ]\n " sv, false );
663664 return *this ;
664665}
665666
666667FGDWriter& FGDWriter::AutoVisGroupWriter::endAutoVisGroup () const {
667- this ->parent .writer .write (" ]\n\n " , 3 );
668+ this ->parent .writer .write (" ]\n\n " sv, false );
668669 return this ->parent ;
669670}
670671
@@ -684,20 +685,20 @@ FGDWriter::EntityWriter FGDWriter::beginEntity(const std::string& classType, con
684685 }
685686 }
686687 this ->writer
687- .write (" = " , 2 )
688+ .write (" = " sv, false )
688689 .write (name, false )
689- .write (" :" , 2 );
690+ .write (" :" sv, false );
690691 // Put the description on the same line if it's short
691692 if (description.size () < 32 ) {
692693 this ->writer
693- .write (" \" " , 2 )
694+ .write (" \" " sv, false )
694695 .write (description, false );
695696 } else {
696697 this ->writer
697- .write (" \n\t\" " , 3 )
698+ .write (" \n\t\" " sv, false )
698699 .write (description, false );
699700 }
700- this ->writer .write (" \"\n [\n " , 4 );
701+ this ->writer .write (" \"\n [\n " sv, false );
701702 return EntityWriter{*this };
702703}
703704
@@ -709,10 +710,10 @@ FGDWriter::EntityWriter& FGDWriter::EntityWriter::keyValue(const std::string& na
709710 .write (valueType, false )
710711 .write (' )' );
711712 if (readOnly) {
712- this ->parent .writer .write (" readonly" , 9 );
713+ this ->parent .writer .write (" readonly" sv, false );
713714 }
714715 if (report) {
715- this ->parent .writer .write (" report" , 7 );
716+ this ->parent .writer .write (" report" sv, false );
716717 }
717718 ::writeOptionalKeyValueStrings (this ->parent.writer, {displayName, valueDefault, description});
718719 this ->parent .writer << ' \n ' ;
@@ -723,60 +724,60 @@ FGDWriter::EntityWriter::KeyValueChoicesWriter FGDWriter::EntityWriter::beginKey
723724 this ->parent .writer
724725 .write (' \t ' )
725726 .write (name, false )
726- .write (" (choices)" , 9 );
727+ .write (" (choices)" sv, false );
727728 if (readOnly) {
728- this ->parent .writer .write (" readonly" , 9 );
729+ this ->parent .writer .write (" readonly" sv, false );
729730 }
730731 if (report) {
731- this ->parent .writer .write (" report" , 7 );
732+ this ->parent .writer .write (" report" sv, false );
732733 }
733734 ::writeOptionalKeyValueStrings (this ->parent.writer, {displayName, valueDefault, description});
734- this ->parent .writer .write (" =\n\t [\n " , 6 );
735+ this ->parent .writer .write (" =\n\t [\n " sv, false );
735736 return KeyValueChoicesWriter{*this };
736737}
737738
738739FGDWriter::EntityWriter::KeyValueChoicesWriter& FGDWriter::EntityWriter::KeyValueChoicesWriter::choice (const std::string& value, const std::string& displayName) {
739740 this ->parent .parent .writer
740- .write (" \t\t\" " , 3 )
741+ .write (" \t\t\" " sv, false )
741742 .write (value, false )
742- .write (" \" : \" " , 5 )
743+ .write (" \" : \" " sv, false )
743744 .write (displayName, false )
744- .write (" \"\n " , 2 );
745+ .write (" \"\n " sv, false );
745746 return *this ;
746747}
747748
748749FGDWriter::EntityWriter& FGDWriter::EntityWriter::KeyValueChoicesWriter::endKeyValueChoices () const {
749- this ->parent .parent .writer .write (" \t ]\n " , 3 );
750+ this ->parent .parent .writer .write (" \t ]\n " sv, false );
750751 return this ->parent ;
751752}
752753
753754FGDWriter::EntityWriter::KeyValueFlagsWriter FGDWriter::EntityWriter::beginKeyValueFlags (const std::string& name, const std::string& displayName, const std::string& description, bool readOnly, bool report) {
754755 this ->parent .writer
755756 .write (' \t ' )
756757 .write (name, false )
757- .write (" (flags)" , 7 );
758+ .write (" (flags)" sv, false );
758759 if (readOnly) {
759- this ->parent .writer .write (" readonly" , 9 );
760+ this ->parent .writer .write (" readonly" sv, false );
760761 }
761762 if (report) {
762- this ->parent .writer .write (" report" , 7 );
763+ this ->parent .writer .write (" report" sv, false );
763764 }
764765 ::writeOptionalKeyValueStrings (this ->parent.writer, {displayName, description});
765- this ->parent .writer .write (" =\n\t [\n " , 6 );
766+ this ->parent .writer .write (" =\n\t [\n " sv, false );
766767 return KeyValueFlagsWriter{*this };
767768}
768769
769770FGDWriter::EntityWriter::KeyValueFlagsWriter& FGDWriter::EntityWriter::KeyValueFlagsWriter::flag (uint64_t value, const std::string& displayName, bool enabledByDefault, const std::string& description) {
770771 this ->parent .parent .writer
771- .write (" \t\t " , 2 )
772+ .write (" \t\t " sv, false )
772773 .write (std::to_string (value), false )
773- .write (" : \" " , 4 )
774+ .write (" : \" " sv, false )
774775 .write (displayName, false )
775- .write (" \" : " , 4 )
776+ .write (" \" : " sv, false )
776777 .write (std::to_string (enabledByDefault), false );
777778 if (!description.empty ()) {
778779 this ->parent .parent .writer
779- .write (" : \" " , 4 )
780+ .write (" : \" " sv, false )
780781 .write (description, false )
781782 .write (' \" ' );
782783 }
@@ -785,21 +786,21 @@ FGDWriter::EntityWriter::KeyValueFlagsWriter& FGDWriter::EntityWriter::KeyValueF
785786}
786787
787788FGDWriter::EntityWriter& FGDWriter::EntityWriter::KeyValueFlagsWriter::endKeyValueFlags () const {
788- this ->parent .parent .writer .write (" \t ]\n " , 3 );
789+ this ->parent .parent .writer .write (" \t ]\n " sv, false );
789790 return this ->parent ;
790791}
791792
792793FGDWriter::EntityWriter& FGDWriter::EntityWriter::input (const std::string& name, const std::string& valueType, const std::string& description) {
793794 this ->parent .writer
794795 .write (' \t ' )
795- .write (" input " , 6 )
796+ .write (" input " sv, false )
796797 .write (name, false )
797798 .write (' (' )
798799 .write (valueType, false )
799800 .write (' )' );
800801 if (!description.empty ()) {
801802 this ->parent .writer
802- .write (" : \" " , 4 )
803+ .write (" : \" " sv, false )
803804 .write (description, false )
804805 .write (' \" ' );
805806 }
@@ -810,14 +811,14 @@ FGDWriter::EntityWriter& FGDWriter::EntityWriter::input(const std::string& name,
810811FGDWriter::EntityWriter& FGDWriter::EntityWriter::output (const std::string& name, const std::string& valueType, const std::string& description) {
811812 this ->parent .writer
812813 .write (' \t ' )
813- .write (" output " , 7 )
814+ .write (" output " sv, false )
814815 .write (name, false )
815816 .write (' (' )
816817 .write (valueType, false )
817818 .write (' )' );
818819 if (!description.empty ()) {
819820 this ->parent .writer
820- .write (" : \" " , 4 )
821+ .write (" : \" " sv, false )
821822 .write (description, false )
822823 .write (' \" ' );
823824 }
@@ -826,7 +827,7 @@ FGDWriter::EntityWriter& FGDWriter::EntityWriter::output(const std::string& name
826827}
827828
828829FGDWriter& FGDWriter::EntityWriter::endEntity () const {
829- this ->parent .writer .write (" ]\n\n " , 3 );
830+ this ->parent .writer .write (" ]\n\n " sv, false );
830831 return this ->parent ;
831832}
832833
0 commit comments