]> git.proxmox.com Git - ceph.git/blob - ceph/src/common/ceph_argparse.h
add subtree-ish sources for 12.0.3
[ceph.git] / ceph / src / common / ceph_argparse.h
1 // -*- mode:C++; tab-width:8; c-basic-offset:2; indent-tabs-mode:t -*-
2 // vim: ts=8 sw=2 smarttab
3 /*
4 * Ceph - scalable distributed file system
5 *
6 * Copyright (C) 2008-2011 New Dream Network
7 *
8 * This is free software; you can redistribute it and/or
9 * modify it under the terms of the GNU Lesser General Public
10 * License version 2.1, as published by the Free Software
11 * Foundation. See file COPYING.
12 *
13 */
14
15 #ifndef CEPH_ARGPARSE_H
16 #define CEPH_ARGPARSE_H
17
18 /*
19 * Ceph argument parsing library
20 *
21 * We probably should eventually replace this with something standard like popt.
22 * Until we do that, though, this file is the place for argv parsing
23 * stuff to live.
24 */
25
26 #include <deque>
27 #include <stdint.h>
28 #include <string>
29 #include <vector>
30
31 #include "common/entity_name.h"
32 #include "msg/msg_types.h"
33
34 /////////////////////// Types ///////////////////////
35 class CephInitParameters
36 {
37 public:
38 explicit CephInitParameters(uint32_t module_type_);
39 std::list<std::string> get_conf_files() const;
40
41 uint32_t module_type;
42 EntityName name;
43 };
44
45 /////////////////////// Functions ///////////////////////
46 extern void string_to_vec(std::vector<std::string>& args, std::string argstr);
47 extern void env_to_vec(std::vector<const char*>& args, const char *name=NULL);
48 extern void argv_to_vec(int argc, const char **argv,
49 std::vector<const char*>& args);
50 extern void vec_to_argv(const char *argv0, std::vector<const char*>& args,
51 int *argc, const char ***argv);
52
53 extern bool parse_ip_port_vec(const char *s, std::vector<entity_addr_t>& vec);
54 bool ceph_argparse_double_dash(std::vector<const char*> &args,
55 std::vector<const char*>::iterator &i);
56 bool ceph_argparse_flag(std::vector<const char*> &args,
57 std::vector<const char*>::iterator &i, ...);
58 bool ceph_argparse_witharg(std::vector<const char*> &args,
59 std::vector<const char*>::iterator &i, std::string *ret,
60 std::ostream &oss, ...);
61 bool ceph_argparse_witharg(std::vector<const char*> &args,
62 std::vector<const char*>::iterator &i, std::string *ret, ...);
63 template<class T>
64 bool ceph_argparse_witharg(std::vector<const char*> &args,
65 std::vector<const char*>::iterator &i, T *ret,
66 std::ostream &oss, ...);
67 bool ceph_argparse_binary_flag(std::vector<const char*> &args,
68 std::vector<const char*>::iterator &i, int *ret,
69 std::ostream *oss, ...);
70 extern CephInitParameters ceph_argparse_early_args
71 (std::vector<const char*>& args, uint32_t module_type,
72 std::string *cluster, std::string *conf_file_list);
73 extern void generic_server_usage();
74 extern void generic_client_usage();
75
76 #endif