Shaka Packager SDK
packager
app
validate_flag.h
1
// Copyright 2014 Google Inc. All rights reserved.
2
//
3
// Use of this source code is governed by a BSD-style
4
// license that can be found in the LICENSE file or at
5
// https://developers.google.com/open-source/licenses/bsd
6
//
7
// Flag validation help functions.
8
9
#ifndef APP_VALIDATE_FLAG_H_
10
#define APP_VALIDATE_FLAG_H_
11
12
#include <string>
13
14
#include "packager/base/strings/stringprintf.h"
15
16
namespace
shaka
{
17
20
void
PrintError
(
const
std::string& error_message);
21
24
void
PrintWarning
(
const
std::string& warning_message);
25
31
// and cannot be empty; If condition is false, then this flag should
32
// not be set.
36
template
<
class
FlagType>
37
bool
ValidateFlag
(
const
char
* flag_name,
38
const
FlagType& flag_value,
39
bool
condition,
40
bool
optional,
41
const
char
* label) {
42
if
(flag_value.empty()) {
43
if
(!optional && condition) {
44
PrintError
(
45
base::StringPrintf(
"--%s is required if %s."
, flag_name, label));
46
return
false
;
47
}
48
}
else
if
(!condition) {
49
PrintError
(base::StringPrintf(
50
"--%s should be specified only if %s."
, flag_name, label));
51
return
false
;
52
}
53
return
true
;
54
}
55
56
}
// namespace shaka
57
58
#endif // APP_VALIDATE_FLAG_H_
shaka::PrintError
void PrintError(const std::string &error_message)
Definition:
validate_flag.cc:15
shaka
All the methods that are virtual are virtual for mocking.
Definition:
gflags_hex_bytes.cc:11
shaka::ValidateFlag
bool ValidateFlag(const char *flag_name, const FlagType &flag_value, bool condition, bool optional, const char *label)
Definition:
validate_flag.h:37
shaka::PrintWarning
void PrintWarning(const std::string &warning_message)
Definition:
validate_flag.cc:19
Generated on Tue Jun 22 2021 00:16:03 for Shaka Packager SDK by
1.8.17