updated gnucash support
This commit is contained in:
parent
3934d558e1
commit
19de076b4d
4 changed files with 42 additions and 5 deletions
14
gnucash.cc
14
gnucash.cc
|
|
@ -255,7 +255,19 @@ static void dataHandler(void *userData, const char *s, int len)
|
|||
}
|
||||
}
|
||||
|
||||
int parse_gnucash(std::istream& in, journal_t * journal, account_t * master)
|
||||
bool gnucash_parser_t::test(std::istream& in) const
|
||||
{
|
||||
char buf[23];
|
||||
in.get(buf, 22);
|
||||
in.seekg(0);
|
||||
|
||||
return std::strncmp(buf, "<?xml version=\"1.0\"?>", 21) == 0;
|
||||
}
|
||||
|
||||
unsigned int gnucash_parser_t::parse(std::istream& in,
|
||||
journal_t * journal,
|
||||
account_t * master,
|
||||
const std::string * original_file)
|
||||
{
|
||||
char buf[BUFSIZ];
|
||||
|
||||
|
|
|
|||
21
gnucash.h
Normal file
21
gnucash.h
Normal file
|
|
@ -0,0 +1,21 @@
|
|||
#ifndef _GNUCASH_H
|
||||
#define _GNUCASH_H
|
||||
|
||||
#include "parser.h"
|
||||
|
||||
namespace ledger {
|
||||
|
||||
class gnucash_parser_t : public parser_t
|
||||
{
|
||||
public:
|
||||
virtual bool test(std::istream& in) const;
|
||||
|
||||
virtual unsigned int parse(std::istream& in,
|
||||
journal_t * journal,
|
||||
account_t * master = NULL,
|
||||
const std::string * original_file = NULL);
|
||||
};
|
||||
|
||||
} // namespace ledger
|
||||
|
||||
#endif // _GNUCASH_H
|
||||
6
main.cc
6
main.cc
|
|
@ -3,6 +3,9 @@
|
|||
#include "textual.h"
|
||||
#include "binary.h"
|
||||
#include "qif.h"
|
||||
#ifdef READ_GNUCASH
|
||||
#include "gnucash.h"
|
||||
#endif
|
||||
#include "valexpr.h"
|
||||
#include "format.h"
|
||||
#include "walk.h"
|
||||
|
|
@ -188,6 +191,9 @@ int main(int argc, char * argv[], char * envp[])
|
|||
std::auto_ptr<textual_parser_t> text_parser(new textual_parser_t);
|
||||
|
||||
parser_t::parsers.push_back(bin_parser.get());
|
||||
#ifdef READ_GNUCASH
|
||||
parser_t::parsers.push_back(gnucash_parser.get());
|
||||
#endif
|
||||
parser_t::parsers.push_back(qif_parser.get());
|
||||
parser_t::parsers.push_back(text_parser.get());
|
||||
|
||||
|
|
|
|||
|
|
@ -187,8 +187,8 @@ void value_expr_t::compute(value_t& result, const details_t& details,
|
|||
case INDEX:
|
||||
if (details.xact)
|
||||
result = details.xact->index + 1;
|
||||
else
|
||||
result = 0U;
|
||||
else if (details.account)
|
||||
result = details.account->count;
|
||||
break;
|
||||
|
||||
case DEPTH:
|
||||
|
|
@ -424,8 +424,6 @@ value_expr_t * parse_value_term(std::istream& in)
|
|||
case 'V': node.reset(parse_value_term("P(O,d)")); break;
|
||||
case 'g': node.reset(parse_value_expr("v-c")); break;
|
||||
case 'G': node.reset(parse_value_expr("V-C")); break;
|
||||
case 'o': node.reset(parse_value_expr("d-b")); break;
|
||||
case 'w': node.reset(parse_value_expr("e-d")); break;
|
||||
|
||||
// Functions
|
||||
case '-':
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue