Go to the documentation of this file.
4 #ifndef tools_sg_style_parser
5 #define tools_sg_style_parser
12 #include "../lina/vec3f"
15 #include "../get_lines"
76 mem::increment(s_class().c_str());
82 mem::decrement(s_class().c_str());
137 mem::increment(s_class().c_str());
315 highlight_color %g %g %g\n\
316 back_color %g %g %g\n\
324 multi_node_limit %d\n\
335 translation %g %g %g"
359 std::string lf(
"\n");
391 s +=
"marker_style ";
415 s +=
"tick_modeling ";
444 s +=
"font_modeling ";
448 s +=
"font_modeling ";
452 s +=
"font_modeling ";
461 s +=
"color_mapping ";
624 bool parse(std::ostream& a_out,
const cmaps_t& a_cmaps,
const std::string& a_s){
627 std::vector<std::string>
lines;
631 const std::string&
line = *it;
632 if(
line.empty())
continue;
637 std::vector<std::string> ws;
639 size_t wordn = ws.size();
641 a_out <<
"style_parser::parse :"
642 <<
" in " <<
sout(a_s)
644 <<
" has a bad word count (at least two expected)."
648 const std::string& word0 = ws[0];
651 const std::string& word1 = ws[1];
653 a_out <<
"style_parser::parse :"
654 <<
" in " <<
sout(a_s)
655 <<
" : " <<
sout(word1)
660 }
else if (wordn==4) {
661 const std::string& rs = ws[1];
663 if(!to<float>(rs,r)) {
664 a_out <<
"style_parser::parse :"
665 <<
" in " <<
sout(a_s)
671 const std::string& gs = ws[2];
673 if(!to<float>(gs,g)) {
674 a_out <<
"style_parser::parse :"
675 <<
" in " <<
sout(a_s)
681 const std::string& bs = ws[3];
683 if(!to<float>(bs,b)) {
684 a_out <<
"style_parser::parse :"
685 <<
" in " <<
sout(a_s)
693 }
else if (wordn==5) {
694 const std::string& rs = ws[1];
696 if(!to<float>(rs,r)) {
697 a_out <<
"style_parser::parse :"
698 <<
" in " <<
sout(a_s)
704 const std::string& gs = ws[2];
706 if(!to<float>(gs,g)) {
707 a_out <<
"style_parser::parse :"
708 <<
" in " <<
sout(a_s)
714 const std::string& bs = ws[3];
716 if(!to<float>(bs,b)) {
717 a_out <<
"style_parser::parse :"
718 <<
" in " <<
sout(a_s)
724 const std::string& as = ws[4];
726 if(!to<float>(as,a)) {
727 a_out <<
"style_parser::parse :"
728 <<
" in " <<
sout(a_s)
737 a_out <<
"style_parser::parse :"
738 <<
" in " <<
sout(a_s)
740 <<
" has a bad word count (two or four expected)."
745 }
else if(word0==
"highlight_color") {
747 const std::string& word1 = ws[1];
749 a_out <<
"style_parser::parse :"
750 <<
" in " <<
sout(a_s)
751 <<
" : " <<
sout(word1)
756 }
else if (wordn==4) {
757 const std::string& rs = ws[1];
759 if(!to<float>(rs,r)) {
760 a_out <<
"style_parser::parse :"
761 <<
" in " <<
sout(a_s)
767 const std::string& gs = ws[2];
769 if(!to<float>(gs,g)) {
770 a_out <<
"style_parser::parse :"
771 <<
" in " <<
sout(a_s)
777 const std::string& bs = ws[3];
779 if(!to<float>(bs,b)) {
780 a_out <<
"style_parser::parse :"
781 <<
" in " <<
sout(a_s)
789 }
else if (wordn==5) {
790 const std::string& rs = ws[1];
792 if(!to<float>(rs,r)) {
793 a_out <<
"style_parser::parse :"
794 <<
" in " <<
sout(a_s)
800 const std::string& gs = ws[2];
802 if(!to<float>(gs,g)) {
803 a_out <<
"style_parser::parse :"
804 <<
" in " <<
sout(a_s)
810 const std::string& bs = ws[3];
812 if(!to<float>(bs,b)) {
813 a_out <<
"style_parser::parse :"
814 <<
" in " <<
sout(a_s)
820 const std::string& as = ws[4];
822 if(!to<float>(as,a)) {
823 a_out <<
"style_parser::parse :"
824 <<
" in " <<
sout(a_s)
833 a_out <<
"style_parser::parse :"
834 <<
" in " <<
sout(a_s)
836 <<
" has a bad word count (two or four expected)."
841 }
else if(word0==
"back_color") {
843 const std::string& word1 = ws[1];
845 a_out <<
"style_parser::parse :"
846 <<
" in " <<
sout(a_s)
847 <<
" : " <<
sout(word1)
852 }
else if (wordn==4) {
853 const std::string& rs = ws[1];
855 if(!to<float>(rs,r)) {
856 a_out <<
"style_parser::parse :"
857 <<
" in " <<
sout(a_s)
863 const std::string& gs = ws[2];
865 if(!to<float>(gs,g)) {
866 a_out <<
"style_parser::parse :"
867 <<
" in " <<
sout(a_s)
873 const std::string& bs = ws[3];
875 if(!to<float>(bs,b)) {
876 a_out <<
"style_parser::parse :"
877 <<
" in " <<
sout(a_s)
885 }
else if (wordn==5) {
886 const std::string& rs = ws[1];
888 if(!to<float>(rs,r)) {
889 a_out <<
"style_parser::parse :"
890 <<
" in " <<
sout(a_s)
896 const std::string& gs = ws[2];
898 if(!to<float>(gs,g)) {
899 a_out <<
"style_parser::parse :"
900 <<
" in " <<
sout(a_s)
906 const std::string& bs = ws[3];
908 if(!to<float>(bs,b)) {
909 a_out <<
"style_parser::parse :"
910 <<
" in " <<
sout(a_s)
916 const std::string& as = ws[4];
918 if(!to<float>(as,a)) {
919 a_out <<
"style_parser::parse :"
920 <<
" in " <<
sout(a_s)
929 a_out <<
"style_parser::parse :"
930 <<
" in " <<
sout(a_s)
932 <<
" has a bad word count (two or four expected)."
937 }
else if(word0==
"pattern") {
939 const std::string& word1 = ws[1];
943 a_out <<
"style_parser::parse :"
944 <<
" in " <<
sout(a_s)
945 <<
" : " <<
sout(word1)
946 <<
" not a line pattern."
953 }
else if(word0==
"line_pattern") {
955 const std::string& word1 = ws[1];
959 a_out <<
"style_parser::parse :"
960 <<
" in " <<
sout(a_s)
961 <<
" : " <<
sout(word1)
962 <<
" not a line pattern."
968 }
else if(word0==
"marker_style") {
970 const std::string& word1 = ws[1];
972 a_out <<
"style_parser::parse :"
973 <<
" in " <<
sout(a_s)
974 <<
" : " <<
sout(word1)
975 <<
" not a marker_style."
979 }
else if(word0==
"area_style") {
981 const std::string& word1 = ws[1];
983 a_out <<
"style_parser::parse :"
984 <<
" in " <<
sout(a_s)
985 <<
" : " <<
sout(word1)
986 <<
" not a area_style."
990 }
else if(word0==
"modeling") {
993 }
else if(word0==
"light_model") {
996 }
else if(word0==
"tick_modeling") {
999 }
else if(word0==
"encoding") {
1002 }
else if(word0==
"smoothing") {
1007 }
else if(word0==
"hinting") {
1012 }
else if(word0==
"enforced") {
1017 }
else if(word0==
"cut") {
1019 for(
unsigned int wordi=1;wordi<wordn;wordi++) {
1020 if(wordi!=1)
m_cut +=
" ";
1023 }
else if(word0==
"options") {
1025 for(
unsigned int wordi=1;wordi<wordn;wordi++) {
1029 }
else if(word0==
"color_mapping") {
1031 for(
unsigned int wordi=1;wordi<wordn;wordi++) {
1035 }
else if(word0==
"painting") {
1038 a_out <<
"style_parser::parse :"
1039 <<
" in " <<
sout(a_s)
1040 <<
" : " <<
sout(ws[1])
1041 <<
" not a painting_policy."
1045 }
else if(word0==
"hatching") {
1048 a_out <<
"style_parser::parse :"
1049 <<
" in " <<
sout(a_s)
1050 <<
" : " <<
sout(ws[1])
1051 <<
" not a hatching_policy."
1055 }
else if(word0==
"projection") {
1058 a_out <<
"style_parser::parse :"
1059 <<
" in " <<
sout(a_s)
1060 <<
" : " <<
sout(ws[1])
1061 <<
" not a projection_type."
1065 }
else if(word0==
"font") {
1068 }
else if(word0==
"width") {
1073 }
else if(word0==
"line_width") {
1078 }
else if(word0==
"marker_size") {
1083 }
else if(word0==
"point_size") {
1088 }
else if(word0==
"font_size") {
1093 }
else if(word0==
"font_modeling") {
1099 a_out <<
"style_parser::parse :"
1100 <<
" in " <<
sout(a_s)
1101 <<
" : " <<
sout(ws[1])
1102 <<
" not a font_modeling."
1106 }
else if(word0==
"back_shadow") {
1112 }
else if(word0==
"multi_node_limit") {
1117 }
else if(word0==
"divisions") {
1122 }
else if(word0==
"rotation_steps") {
1127 }
else if(word0==
"angle") {
1132 }
else if(word0==
"scale") {
1137 }
else if(word0==
"offset") {
1142 }
else if(word0==
"strip_width") {
1147 }
else if(word0==
"spacing") {
1152 }
else if(word0==
"visible") {
1157 }
else if(word0==
"editable") {
1162 }
else if(word0==
"pickable") {
1167 }
else if(word0==
"automated") {
1172 }
else if(word0==
"bar_offset") {
1177 }
else if(word0==
"bar_width") {
1183 }
else if(word0==
"translation") {
1185 const std::string& sx = ws[1];
1187 if(!to<float>(sx,x)) {
1188 a_out <<
"style_parser::parse :"
1189 <<
" in " <<
sout(a_s)
1190 <<
" : " <<
sout(sx)
1195 const std::string& sy = ws[2];
1197 if(!to<float>(sy,y)) {
1198 a_out <<
"style_parser::parse :"
1199 <<
" in " <<
sout(a_s)
1200 <<
" : " <<
sout(sy)
1205 const std::string& sz = ws[3];
1207 if(!to<float>(sz,z)) {
1208 a_out <<
"style_parser::parse :"
1209 <<
" in " <<
sout(a_s)
1210 <<
" : " <<
sout(sz)
1217 a_out <<
"style_parser::parse :"
1218 <<
" in " <<
sout(a_s)
1219 <<
" has a bad word count (four expected)."
1224 }
else if(word0==
"front_face") {
1226 const std::string& word1 = ws[1];
1229 }
else if(word1==
"cw") {
1232 a_out <<
"style_parser::parse :"
1233 <<
" in " <<
sout(a_s)
1234 <<
" : " <<
sout(word1)
1235 <<
" not a winding type."
1240 }
else if(word0==
"hjust") {
1242 const std::string& word1 = ws[1];
1244 a_out <<
"style_parser::parse :"
1245 <<
" in " <<
sout(a_s)
1246 <<
" : " <<
sout(word1)
1252 }
else if(word0==
"vjust") {
1254 const std::string& word1 = ws[1];
1256 a_out <<
"style_parser::parse :"
1257 <<
" in " <<
sout(a_s)
1258 <<
" : " <<
sout(word1)
1264 }
else if(word0==
"coloring") {
1268 }
else if(word0==
"title") {
1273 a_out <<
"style_parser::parse :"
1274 <<
" in " <<
sout(a_s)
1275 <<
" : " <<
sout(word0)
1286 const std::string& a_s,
1287 const std::string& a_line,std::ostream& a_out) {
1289 a_out <<
"style_parser::parse :"
1290 <<
" in " <<
sout(a_s)
1291 <<
" : " <<
sout(a_line)
1292 <<
" has a bad word count (two expected)."
1300 const std::string& a_s,std::ostream& a_out,
bool& a_v){
1302 a_out <<
"style_parser::parse :"
1303 <<
" in " <<
sout(a_s)
1304 <<
" : " <<
sout(a_w)
1305 <<
" not a boolean."
1313 const std::string& a_s,std::ostream& a_out,
int& a_v) {
1314 if(!to<int>(a_w,a_v)){
1315 a_out <<
"style_parser::parse :"
1316 <<
" in " <<
sout(a_s)
1317 <<
" : " <<
sout(a_w)
1326 const std::string& a_s,std::ostream& a_out,
unsigned int& a_v) {
1327 if(!to<unsigned int>(a_w,a_v)){
1328 a_out <<
"style_parser::parse :"
1329 <<
" in " <<
sout(a_s)
1330 <<
" : " <<
sout(a_w)
1331 <<
" not an unsigned int."
1339 const std::string& a_s,std::ostream& a_out,
float& a_v) {
1340 if(!to<float>(a_w,a_v)){
1341 a_out <<
"style_parser::parse :"
1342 <<
" in " <<
sout(a_s)
1343 <<
" : " <<
sout(a_w)
#define TOOLS_SCLASS(a_name)
#define tools_vforcit(a__T, a__v, a__it)