lib: moved mimedump.h from tools/ into the library (mimeio.h)
[barry/progweb.git] / tools / util.cc
blobdcba212845a6c7bcfeaff8ad479d6c9c005a2254
1 ///
2 /// \file util.cc
3 /// Misc. utility functions for command line tools.
4 ///
6 /*
7 Copyright (C) 2012, 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"
24 #include <barry/barry.h>
25 #ifdef __BARRY_SYNC_MODE__
26 #include <barry/barrysync.h>
27 #endif
29 #include <iostream>
31 using namespace std;
32 using namespace Barry;
34 void ShowParsers(bool show_fields, bool show_mime_support)
36 cout << "Supported Database parsers:\n";
38 #ifdef __BARRY_SYNC_MODE__
39 if( show_mime_support )
40 cout << " (* = can display in vformat MIME mode)\n";
42 #define MIME_DOT(tname) (MimeDump<tname>::Supported() && show_mime_support ? " *" : "")
44 #else
45 #define MIME_DOT(tname) ""
46 #endif
48 #undef HANDLE_PARSER
49 #define HANDLE_PARSER(tname) \
50 { \
51 cout << " " << tname::GetDBName() << MIME_DOT(tname) << "\n"; \
52 if( show_fields ) { \
53 cout << " "; \
54 FieldHandle<tname>::ListT::const_iterator \
55 fhi = tname::GetFieldHandles().begin(), \
56 fhe = tname::GetFieldHandles().end(); \
57 for( int count = 0, len = 6; fhi != fhe; ++fhi, ++count ) { \
58 if( count ) { \
59 cout << ", "; \
60 len += 2; \
61 } \
62 std::string name = fhi->GetIdentity().Name; \
63 if( len + name.size() >= 75 ) { \
64 cout << "\n "; \
65 len = 6; \
66 } \
67 cout << name; \
68 len += name.size(); \
69 } \
70 cout << "\n"; \
71 } \
74 ALL_KNOWN_PARSER_TYPES
76 cout << endl;
79 void ShowBuilders()
81 cout << "Supported Database builders:\n";
83 #undef HANDLE_BUILDER
84 #define HANDLE_BUILDER(tname) cout << " " << tname::GetDBName() << "\n";
85 ALL_KNOWN_BUILDER_TYPES
87 cout << endl;