NDEVR
API Documentation
StringValidator.h
1/*--------------------------------------------------------------------------------------------
2Copyright (c) 2019, NDEVR LLC
3tyler.parke@ndevr.org
4 __ __ ____ _____ __ __ _______
5 | \ | | | __ \ | ___|\ \ / / | __ \
6 | \ | | | | \ \ | |___ \ \ / / | |__) |
7 | . \| | | |__/ / | |___ \ V / | _ /
8 | |\ |_|_____/__|_____|___\_/____| | \ \
9 |__| \__________________________________| \__\
10
11Subject to the terms of the Enterprise+ Agreement, NDEVR hereby grants
12Licensee a limited, non-exclusive, non-transferable, royalty-free license
13(without the right to sublicense) to use the API solely for the purpose of
14Licensee's internal development efforts to develop applications for which
15the API was provided.
16
17The above copyright notice and this permission notice shall be included in all
18copies or substantial portions of the Software.
19
20THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED,
21INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR
22PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE
23FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
24OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
25DEALINGS IN THE SOFTWARE.
26
27Library: Base
28File: StringValidator
29Included in API: True
30Author(s): Tyler Parke
31 *-----------------------------------------------------------------------------------------**/
32#pragma once
33#include "DLLInfo.h"
34#include <NDEVR/String.h>
35#include <regex>
36namespace NDEVR
37{
38 class TypeInfo;
46 class NDEVR_BASE_API StringValidator
47 {
48 public:
58 static bool checkRegex(const StringView& string, const StringView& regex, uint04 start_index = 0, uint04 end_index = Constant<uint04>::Invalid, uint04 max_size = 256);
59
65 template <class t_type>
66 static bool isValid(const StringView& string)
67 {
68 std::basic_regex<char> basic_regex(regex<t_type>());
69 return std::regex_match(string.begin(), string.end(), basic_regex);
70 }
71
77 static bool isValid(const StringView& string, const TypeInfo& type)
78 {
79 std::basic_regex<char> basic_regex(regex(type));
80 return std::regex_match(string.begin(), string.end(), basic_regex);
81 }
82
86 template <class t_type>
87 static const char* regex()
88 {
90 }
91
97 static const char* regex(const TypeInfo& type);
98
99
100 };
101}
static const char * getValidRegex()
Optionally specified to allow the software to do a check on user or file input to ensure that fromStr...
Logic for validating a string given a specific regex pattern.
static bool checkRegex(const StringView &string, const StringView &regex, uint04 start_index=0, uint04 end_index=Constant< uint04 >::Invalid, uint04 max_size=256)
Checks whether a substring of the given string matches the specified regex pattern.
static const char * regex(const TypeInfo &type)
Retrieves the validation regex pattern string for the specified TypeInfo.
static bool isValid(const StringView &string)
Checks whether the given string is valid for the specified type using its associated regex.
static bool isValid(const StringView &string, const TypeInfo &type)
Checks whether the given string is valid for the specified TypeInfo using its associated regex.
static const char * regex()
Retrieves the validation regex pattern string for the specified type.
The core String View class for the NDEVR API.
Definition StringView.h:58
Stores information about a type, relevant for certain templated functions.
Definition TypeInfo.h:43
The primary namespace for the NDEVR SDK.
@ type
The type identifier string for this model node.
Definition Model.h:58
uint32_t uint04
-Defines an alias representing a 4 byte, unsigned integer -Can represent exact integer values 0 throu...