#include "pdf_reader.h"
+#include <common/log.h>
+
#include <boost/spirit/home/qi.hpp>
+#include <boost/lexical_cast.hpp>
namespace qi = boost::spirit::qi;
stack.pop_back();
}
+ std::string get_indent() const
+ {
+ return std::string(stack.size() * 4, ' ');
+ }
+
void set_name(const std::string& str)
{
name.assign(str.begin(), str.end());
+ CASPAR_LOG(trace) << get_indent() << name;
}
- void add_char(unsigned char c)
+ void add_char(std::uint8_t c)
{
char_flag = !char_flag;
}
void set_value(double val)
{
- value = std::to_wstring((long double)val);
+ value = boost::lexical_cast<std::wstring>(val);
set_value();
}
void set_value()
{
+ CASPAR_LOG(trace) << get_indent() << value;
+
stack.back()->push_back(std::make_pair(name, Ptree(value)));
clear_state();
}
pdf_context &c;
explicit a_char(pdf_context& c) : c(c) {}
- void operator()(unsigned char n, qi::unused_type, qi::unused_type) const
+ void operator()(std::uint8_t n, qi::unused_type, qi::unused_type) const
{
c.add_char(n);
}
};
};
-bool read_pdf(boost::property_tree::wptree& tree, const std::vector<char>& v)
+bool read_pdf(boost::property_tree::wptree& tree, const std::wstring& s)
{
- typedef std::vector<char>::const_iterator iterator_type;
+ typedef std::wstring::const_iterator iterator_type;
pdf_grammar<iterator_type> g;
bool result = false;
try
{
- auto it = v.begin();
- result = qi::phrase_parse(it, v.end(), g, qi::space);
+ auto it = s.begin();
+ result = qi::phrase_parse(it, s.end(), g, qi::space);
if(result)
tree.swap(g.context.root);
}
- catch(std::exception& ex)
- {}
+ catch(std::exception&)
+ {
+ CASPAR_LOG_CURRENT_EXCEPTION();
+ }
return result;
}
} //namespace psd
-} //namespace caspar
\ No newline at end of file
+} //namespace caspar