vformat.c: fixed incomplete base64_init()
[barry.git] / tools / util.cc
blobe4ad197e73de031b3aeb3ecc9fe0e314841dad30
1 ///
2 /// \file util.cc
3 /// Misc. utility functions for command line tools.
4 ///
6 /*
7 Copyright (C) 2012-2013, Net Direct Inc. (http://www.netdirect.ca/)
9 This program is free software; you can redistribute it and/or modify
10 it under the terms of the GNU General Public License as published by
11 the Free Software Foundation; either version 2 of the License, or
12 (at your option) any later version.
14 This program is distributed in the hope that it will be useful,
15 but WITHOUT ANY WARRANTY; without even the implied warranty of
16 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
18 See the GNU General Public License in the COPYING file at the
19 root directory of this project for more details.
22 #include "util.h"
23 #include "i18n.h"
25 #include <barry/barry.h>
26 #ifdef __BARRY_SYNC_MODE__
27 #include <barry/barrysync.h>
28 #endif
30 #include <iostream>
32 using namespace std;
33 using namespace Barry;
35 void ShowParsers(bool show_fields, bool show_mime_support)
37 cout << _("Supported Database parsers:\n");
39 #ifdef __BARRY_SYNC_MODE__
40 if( show_mime_support )
41 cout << _(" (* = can display in vformat MIME mode)\n");
43 #define MIME_DOT(tname) (MimeDump<tname>::Supported() && show_mime_support ? " *" : "")
45 #else
46 #define MIME_DOT(tname) ""
47 #endif
49 #undef HANDLE_PARSER
50 #define HANDLE_PARSER(tname) \
51 { \
52 cout << " " << tname::GetDBName() << MIME_DOT(tname) << "\n"; \
53 if( show_fields ) { \
54 cout << " "; \
55 FieldHandle<tname>::ListT::const_iterator \
56 fhi = tname::GetFieldHandles().begin(), \
57 fhe = tname::GetFieldHandles().end(); \
58 for( int count = 0, len = 6; fhi != fhe; ++fhi, ++count ) { \
59 if( count ) { \
60 cout << ", "; \
61 len += 2; \
62 } \
63 std::string name = fhi->GetIdentity().Name; \
64 if( len + name.size() >= 75 ) { \
65 cout << "\n "; \
66 len = 6; \
67 } \
68 cout << name; \
69 len += name.size(); \
70 } \
71 cout << "\n"; \
72 } \
75 ALL_KNOWN_PARSER_TYPES
77 cout << endl;
80 void ShowBuilders()
82 cout << _("Supported Database builders:\n");
84 #undef HANDLE_BUILDER
85 #define HANDLE_BUILDER(tname) cout << " " << tname::GetDBName() << "\n";
86 ALL_KNOWN_BUILDER_TYPES
88 cout << endl;