Commit Graph

17767 Commits

Author SHA1 Message Date
Geert Janssens
ab6dc0f590 Add property structs for transaction vs split properties 2017-02-20 17:52:17 +01:00
Geert Janssens
91df5edaa5 Refactor pair into a tuple in preparation of extending it 2017-02-20 17:51:51 +01:00
Geert Janssens
ffa68c6b84 Factor out balance calculating function 2017-02-20 17:51:46 +01:00
Geert Janssens
0d4d92fbb4 Drop unused parameter 2017-02-20 17:51:43 +01:00
Geert Janssens
f64d217ed3 Drop remaining GError boilerplate from the c++ importer 2017-02-20 17:51:40 +01:00
Geert Janssens
430875772b Replace GError usage in parse function with proper try catch blocks
In addition fix a crash while loading importer settings that would reduce
the number of columns found in the import file.
2017-02-20 17:51:38 +01:00
Geert Janssens
d64c66e68d Replace GError usage in file_format and load_file with proper try catch blocks 2017-02-20 17:51:35 +01:00
Geert Janssens
b9e73d923e Throw in case date can't be parsed instead of returning -1 as date 2017-02-20 17:51:33 +01:00
Geert Janssens
bbac6aa1c5 Various small C++ and other cleanups
- Use CamelCase for type definitions and _ for function names
- m_ for member variables
- avoid typedef (not needed for structs, replace by using for aliases)
- use std::string for composing strings
- fix condition part in for loop (can't use , need &&)
- markup comment for doxygen inclusion
2017-02-20 17:51:31 +01:00
Geert Janssens
2638056203 Use gnc-date functions while parsing date strings for consistent timezone handling 2017-02-20 17:51:28 +01:00
Geert Janssens
c0d518e870 Migrate the glib based test case for GncTxImport to google-test 2017-02-20 17:51:25 +01:00
Geert Janssens
9525d9b84b Use consistent name for importer class and its filename
The class was still called after the original struct in c and the file
had an almost ok name from when I started the conversion.
Add some usage information to the class as well.
2017-02-20 17:51:22 +01:00
Geert Janssens
a6aa76fc76 Fix column sizing for fixed width data
It was written to work with absolute column positions (from stf)
but boost::tokenizer uses column widths instead.
2017-02-20 17:51:19 +01:00
Geert Janssens
bce5eaaa1d Prevent crash when switching to fixed with in assistant
The problem was initially the user doesn't have any column offsets
defined which the tokenize function wasn't handling properly
2017-02-20 17:42:49 +01:00
Geert Janssens
da0120d533 Readd a column for the error messages when reviewing parse errors 2017-02-20 17:42:46 +01:00
Geert Janssens
c1d798d0b0 Return nullptr in case of invalid numeric field to allow proper error handling 2017-02-20 17:42:45 +01:00
Geert Janssens
e0caec0e22 Rearrange statements in gnc_csv_preview_update_assist
- Use a more logical grouping for setting up liststores and columns
- Use one common store for all the header line's combo box entries
- Store column number in each combo box entry for later retrieval
2017-02-20 17:42:44 +01:00
Geert Janssens
6adbab1d38 Use one common liststore for all the combocells in the preview header treeview
They all show the same list anyway and this simplifies the code
2017-02-20 17:42:42 +01:00
Geert Janssens
bbeb351aa8 Some changes to adhere better to the gnucash coding guidelines
- use m_ prefix on member variables
- prefer passing by reference over copying
2017-02-20 17:42:41 +01:00
Geert Janssens
737cbfb35b Drop fake test in fw tokenizer 2017-02-20 17:42:39 +01:00
Geert Janssens
f47d12c373 Add test cases for tokenizer classes 2017-02-20 17:42:38 +01:00
Geert Janssens
b425a5e7dd Trim whitespace in case of fixed width input 2017-02-20 17:42:37 +01:00
Geert Janssens
1b44310b04 Replace transactions GList with a std::multimap 2017-02-20 17:42:32 +01:00
Geert Janssens
d557c01c88 Another round of small c to c++(11) conversions
- prefer c++ data types (auto, bool, int, std::string)
- iterate over vectors instead of accessing via the [] operator
- use boost::{u32}regex instead of directly manipulating a c-string
2017-02-20 17:42:30 +01:00
Geert Janssens
05c187960a Delay the test for a default account until it's needed 2017-02-20 17:42:29 +01:00
Geert Janssens
11ff8273e5 Fix memory management for the temporary trans properties
This is done by wrapping each property in a minimal template class hierarchy
and keep track of each using a std::shared_pointer
2017-02-20 17:42:28 +01:00
Geert Janssens
bebc871fe8 Reduce code duplication by reusing trans_add_split 2017-02-20 17:42:24 +01:00
Geert Janssens
42c2f94b38 Fix memory corruption bug 2017-02-20 17:42:23 +01:00
Geert Janssens
2d42bf5920 Refactor TransProperty stuff to a simple void*
Needs more attention for memory management though.
2017-02-20 17:42:22 +01:00
Geert Janssens
f26d3cea7d Replace private data structure TransPropertyList with a std::map
This required moving around a few other parameters
- currency_format and date_format will now be passed directly to the function that needs it
- Account is converted into a trans_prop just like all the other columns the user had selected
2017-02-20 17:42:20 +01:00
Geert Janssens
38b0b356e4 Remove fake csv parsing test 2017-02-20 17:42:19 +01:00
Geert Janssens
e6d9a614ad Add some polish to csv_import_trans_file_chooser_confirm_cb
- avoid superfluous string copying
- flatten the nested if structures
- set a default file format before attempting to parse
2017-02-20 17:42:18 +01:00
Geert Janssens
8f9b3d322a Prevent c++ name mangling on functions used as callbacks by gtk 2017-02-20 17:42:17 +01:00
Geert Janssens
5c9f9059a1 csv-imp - use enum instead of strings to track user selected column types 2017-02-20 17:42:16 +01:00
Geert Janssens
0b73a56c29 Convert column type to name mapping into a std::map 2017-02-20 17:42:14 +01:00
Geert Janssens
6f15805c0b Adapt assistant for c++ guid changes 2017-02-20 17:42:12 +01:00
Geert Janssens
c21cf18847 Refactor csv assistant code to use GncCsvParseData class instead of gnc-csv-model code 2017-02-20 17:42:11 +01:00
Geert Janssens
b9646e9b9a Build assistant-csv-trans-import.c(pp) as c++ 2017-02-20 17:42:10 +01:00
Geert Janssens
142fb61724 Introduce parse error state 2017-02-20 17:42:08 +01:00
Geert Janssens
0f6dc53cd1 Small local variable cleanups 2017-02-20 17:42:07 +01:00
Geert Janssens
d85de0124c C++ - use std::pair to store tokenized line together with its error message
Also drop a few variables that carry superfluous data and add more c++11 semantics
2017-02-20 17:42:06 +01:00
Geert Janssens
17b2b4668e C++11 Convert unscoped enum into scoped one
As per recommendation 10 in Meyer's Effective Modern C++

This also means the string array with column type names
can no longer be shared between c and c++ code, so
set up a separate one in c++
2017-02-20 17:42:05 +01:00
Geert Janssens
8f9d2ee826 Use more C++11 features
- use iterators to loop and std::find
  This allows us to use 'continue' on the loop in case
  of errors instead of using an ever more indenting if/else
- Use auto where possible
- Use constant iterators where possible
2017-02-20 17:42:03 +01:00
Geert Janssens
bcae6628d6 Revert to boost.regex without ICU support
For some reason named capture groups trigger an uninitialized shared_ptr assert
2017-02-20 17:42:02 +01:00
Geert Janssens
e95b1e2c16 Redo parse_date function using boost regular expressions 2017-02-20 17:41:58 +01:00
Geert Janssens
533b5eb7be Convert error_lines GList in a vector of strings
Also keep the errors separate from the original data.
Use for loop instead of while.
2017-02-20 17:41:53 +01:00
Geert Janssens
cecfe9ecb8 Replace stf based file parser with gnc-tokenizer based one 2017-02-20 17:41:52 +01:00
Geert Janssens
ce63d8aab0 Use vector instead of GArray for column_types class member 2017-02-20 17:41:49 +01:00
Geert Janssens
1507ec0c30 Convert GncCsvParseData into a class
This is just an initial conversion. Lots of
work is still needed to get to proper data encapsulation
and using modern c++ semantics
2017-02-20 17:41:48 +01:00
Geert Janssens
3a0f0dff8e csv-imp - copy gnc-csv-model and make it build as c++
This will be the start of a GncCsvImpTrans class that will
manage transaction imports from csv files
2017-02-20 17:41:47 +01:00