advgetopt 2.0.47
Parse complex command line arguments and configuration files in C++.
validator.h
Go to the documentation of this file.
1// Copyright (c) 2006-2024 Made to Order Software Corp. All Rights Reserved
2//
3// https://snapwebsites.org/project/advgetopt
4// contact@m2osw.com
5//
6// This program is free software; you can redistribute it and/or modify
7// it under the terms of the GNU General Public License as published by
8// the Free Software Foundation; either version 2 of the License, or
9// (at your option) any later version.
10//
11// This program is distributed in the hope that it will be useful,
12// but WITHOUT ANY WARRANTY; without even the implied warranty of
13// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14// GNU General Public License for more details.
15//
16// You should have received a copy of the GNU General Public License along
17// with this program; if not, write to the Free Software Foundation, Inc.,
18// 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
19#pragma once
20
32// self
33//
34#include <advgetopt/utils.h>
35
36
37// C++
38//
39#include <memory>
40
41
42
43namespace advgetopt
44{
45
46
47
48class validator;
49
51{
52public:
53 virtual ~validator_factory();
54
55 virtual std::string get_name() const = 0;
56 virtual std::shared_ptr<validator>
57 create(string_list_t const & data) const = 0;
58};
59
60
62{
63public:
64 typedef std::shared_ptr<validator> pointer_t;
65 typedef std::vector<pointer_t> vector_t;
66
67 virtual ~validator();
68
69 // virtuals
70 //
71 virtual std::string name() const = 0;
72 virtual bool validate(std::string const & value) const = 0;
73
74 static void register_validator(validator_factory const & factory);
75 static pointer_t create(std::string const & name, string_list_t const & data);
76 static pointer_t create(std::string const & name_and_params);
77};
78
79
80
81} // namespace advgetopt
82// vim: ts=4 sw=4 et
virtual std::string get_name() const =0
virtual std::shared_ptr< validator > create(string_list_t const &data) const =0
virtual ~validator_factory()
The destructor to ease derived classes.
static pointer_t create(std::string const &name, string_list_t const &data)
static void register_validator(validator_factory const &factory)
std::vector< pointer_t > vector_t
Definition validator.h:65
virtual ~validator()
The validator destructor to support virtuals.
std::shared_ptr< validator > pointer_t
Definition validator.h:64
virtual std::string name() const =0
Return the name of the validator.
virtual bool validate(std::string const &value) const =0
Return true if value validates agains this validator.
The advgetopt environment to parse command line options.
constexpr flag_t option_flags_merge()
Definition flags.h:87
std::vector< std::string > string_list_t
Definition utils.h:41
A few utility functions that are not specific to an object.

This document is part of the Snap! Websites Project.

Copyright by Made to Order Software Corp.