Remove a bunch of debugging printfs and add verbosity levels
This commit is contained in:
parent
17df0d4adf
commit
41327c92fd
5 changed files with 46 additions and 44 deletions
|
@ -18,6 +18,9 @@
|
|||
#include "writer_png.h"
|
||||
|
||||
|
||||
int verbosity = 0;
|
||||
|
||||
|
||||
static void
|
||||
usage(const char *progname)
|
||||
{
|
||||
|
@ -75,7 +78,7 @@ main(int argc,
|
|||
outfile = optarg;
|
||||
break;
|
||||
case 'v':
|
||||
/* TODO: Verbosity levels. */
|
||||
++verbosity;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
@ -88,6 +91,10 @@ main(int argc,
|
|||
|
||||
infile = argv[optind];
|
||||
|
||||
if (outfile.empty()) {
|
||||
outfile = "charles_out.png";
|
||||
}
|
||||
|
||||
/* Parse YAML files. */
|
||||
YAMLReader reader(scene);
|
||||
for (int i = optind; i < argc; i++) {
|
||||
|
|
|
@ -13,6 +13,7 @@
|
|||
|
||||
#include "yaml.h"
|
||||
|
||||
#include "charles.hh"
|
||||
#include "reader_yaml.hh"
|
||||
|
||||
#include "yaml/parsers.hh"
|
||||
|
@ -71,7 +72,7 @@ YAMLReader::read_file(const std::string& filename)
|
|||
yaml_parser_t parser;
|
||||
yaml_parser_initialize(&parser);
|
||||
|
||||
printf("Reading file: %s\n", filename.c_str());
|
||||
printf("Reading %s\n", filename.c_str());
|
||||
yaml_parser_set_input_file(&parser, yaml_infile);
|
||||
|
||||
yaml::ParserStack parsers;
|
||||
|
@ -85,45 +86,47 @@ YAMLReader::read_file(const std::string& filename)
|
|||
goto error;
|
||||
}
|
||||
|
||||
switch (event.type) {
|
||||
case YAML_NO_EVENT:
|
||||
printf("YAML_NO_EVENT\n");
|
||||
break;
|
||||
if (verbosity >= 4) {
|
||||
switch (event.type) {
|
||||
case YAML_NO_EVENT:
|
||||
printf("YAML_NO_EVENT\n");
|
||||
break;
|
||||
|
||||
case YAML_STREAM_START_EVENT:
|
||||
printf("YAML_STREAM_START_EVENT\n");
|
||||
break;
|
||||
case YAML_STREAM_END_EVENT:
|
||||
printf("YAML_STREAM_END_EVENT\n");
|
||||
break;
|
||||
case YAML_STREAM_START_EVENT:
|
||||
printf("YAML_STREAM_START_EVENT\n");
|
||||
break;
|
||||
case YAML_STREAM_END_EVENT:
|
||||
printf("YAML_STREAM_END_EVENT\n");
|
||||
break;
|
||||
|
||||
case YAML_DOCUMENT_START_EVENT:
|
||||
printf("YAML_DOCUMENT_START_EVENT\n");
|
||||
break;
|
||||
case YAML_DOCUMENT_END_EVENT:
|
||||
printf("YAML_DOCUMENT_END_EVENT\n");
|
||||
break;
|
||||
case YAML_DOCUMENT_START_EVENT:
|
||||
printf("YAML_DOCUMENT_START_EVENT\n");
|
||||
break;
|
||||
case YAML_DOCUMENT_END_EVENT:
|
||||
printf("YAML_DOCUMENT_END_EVENT\n");
|
||||
break;
|
||||
|
||||
case YAML_ALIAS_EVENT:
|
||||
printf("YAML_ALIAS_EVENT\n");
|
||||
break;
|
||||
case YAML_SCALAR_EVENT:
|
||||
printf("YAML_SCALAR_EVENT\n");
|
||||
break;
|
||||
case YAML_ALIAS_EVENT:
|
||||
printf("YAML_ALIAS_EVENT\n");
|
||||
break;
|
||||
case YAML_SCALAR_EVENT:
|
||||
printf("YAML_SCALAR_EVENT\n");
|
||||
break;
|
||||
|
||||
case YAML_SEQUENCE_START_EVENT:
|
||||
printf("YAML_SEQUENCE_START_EVENT\n");
|
||||
break;
|
||||
case YAML_SEQUENCE_END_EVENT:
|
||||
printf("YAML_SEQUENCE_END_EVENT\n");
|
||||
break;
|
||||
case YAML_SEQUENCE_START_EVENT:
|
||||
printf("YAML_SEQUENCE_START_EVENT\n");
|
||||
break;
|
||||
case YAML_SEQUENCE_END_EVENT:
|
||||
printf("YAML_SEQUENCE_END_EVENT\n");
|
||||
break;
|
||||
|
||||
case YAML_MAPPING_START_EVENT:
|
||||
printf("YAML_MAPPING_START_EVENT\n");
|
||||
break;
|
||||
case YAML_MAPPING_END_EVENT:
|
||||
printf("YAML_MAPPING_END_EVENT\n");
|
||||
break;
|
||||
case YAML_MAPPING_START_EVENT:
|
||||
printf("YAML_MAPPING_START_EVENT\n");
|
||||
break;
|
||||
case YAML_MAPPING_END_EVENT:
|
||||
printf("YAML_MAPPING_END_EVENT\n");
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if (event.type == YAML_DOCUMENT_START_EVENT) {
|
||||
|
@ -135,7 +138,6 @@ YAMLReader::read_file(const std::string& filename)
|
|||
if (!parsers.empty()) {
|
||||
parsers.top()->HandleEvent(event);
|
||||
if (parsers.top()->GetDone()) {
|
||||
printf("parser done\n");
|
||||
delete parsers.top();
|
||||
parsers.pop();
|
||||
}
|
||||
|
|
|
@ -41,8 +41,6 @@ ObjectParser::HandleKeyEvent(const std::string& key)
|
|||
{"radius", RadiusSection}
|
||||
};
|
||||
|
||||
printf("%s: got key = %s", __PRETTY_FUNCTION__, key.c_str());
|
||||
|
||||
if (sSections.count(key) > 0) {
|
||||
mSection = sSections.at(key);
|
||||
}
|
||||
|
|
|
@ -29,8 +29,6 @@ void
|
|||
ScalarMappingParser::HandleEvent(yaml_event_t& event)
|
||||
{
|
||||
if (mShouldExpectKey && event.type == YAML_MAPPING_START_EVENT) {
|
||||
printf("%s: start scalar mapping: tag = %s\n", __PRETTY_FUNCTION__,
|
||||
event.data.mapping_start.tag);
|
||||
return;
|
||||
}
|
||||
else if (mShouldExpectKey && event.type == YAML_MAPPING_END_EVENT) {
|
||||
|
|
|
@ -96,11 +96,9 @@ SceneParser::HandleObjectsEvent(yaml_event_t& event)
|
|||
{
|
||||
if (event.type == YAML_SEQUENCE_START_EVENT) {
|
||||
/* Ignore sequence-start for now. */
|
||||
printf("start objects\n");
|
||||
return;
|
||||
}
|
||||
else if (event.type == YAML_SEQUENCE_END_EVENT) {
|
||||
printf("end objects\n");
|
||||
mSection = NoSection;
|
||||
SetShouldExpectKey(true);
|
||||
return;
|
||||
|
@ -111,7 +109,6 @@ SceneParser::HandleObjectsEvent(yaml_event_t& event)
|
|||
return;
|
||||
}
|
||||
|
||||
printf("start object\n");
|
||||
GetParsers().push(new ObjectParser(GetScene(), GetParsers()));
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue