Flutter Engine
The Flutter Engine
Public Member Functions | List of all members
dart::EnumListParameter Class Reference
Inheritance diagram for dart::EnumListParameter:
dart::MethodParameter

Public Member Functions

 EnumListParameter (const char *name, bool required, const char *const *enums)
 
virtual bool Validate (const char *value) const
 
const char ** Parse (char *value) const
 
- Public Member Functions inherited from dart::MethodParameter
 MethodParameter (const char *name, bool required)
 
virtual ~MethodParameter ()
 
virtual bool Validate (const char *value) const
 
virtual bool ValidateObject (const Object &value) const
 
const char * name () const
 
bool required () const
 
virtual void PrintError (const char *name, const char *value, JSONStream *js) const
 
virtual void PrintErrorObject (const char *name, const Object &value, JSONStream *js) const
 

Detailed Description

Definition at line 185 of file service.cc.

Constructor & Destructor Documentation

◆ EnumListParameter()

dart::EnumListParameter::EnumListParameter ( const char *  name,
bool  required,
const char *const *  enums 
)
inline

Definition at line 187 of file service.cc.

188 : MethodParameter(name, required), enums_(enums) {}
const char * name() const
Definition: service.cc:147
MethodParameter(const char *name, bool required)
Definition: service.cc:138
bool required() const
Definition: service.cc:149

Member Function Documentation

◆ Parse()

const char ** dart::EnumListParameter::Parse ( char *  value) const
inline

Definition at line 194 of file service.cc.

194 {
195 const char* kJsonChars = " \t\r\n[,]";
196
197 // Make a writeable copy of the value.
198 intptr_t element_count = ElementCount(value);
199 if (element_count < 0) {
200 return nullptr;
201 }
202 intptr_t element_pos = 0;
203
204 // Allocate our element array. +1 for nullptr terminator.
205 // The caller is responsible for deleting this memory.
206 char** elements = new char*[element_count + 1];
207 elements[element_count] = nullptr;
208
209 // Parse the string destructively. Build the list of elements.
210 while (element_pos < element_count) {
211 // Skip to the next element.
212 value += strspn(value, kJsonChars);
213
214 intptr_t len = strcspn(value, kJsonChars);
215 ASSERT(len > 0); // We rely on the parameter being validated already.
216 value[len] = '\0';
217 elements[element_pos++] = value;
218
219 // Advance. +1 for null terminator.
220 value += (len + 1);
221 }
222 return const_cast<const char**>(elements);
223 }
#define ASSERT(E)
uint8_t value

◆ Validate()

virtual bool dart::EnumListParameter::Validate ( const char *  value) const
inlinevirtual

Reimplemented from dart::MethodParameter.

Definition at line 190 of file service.cc.

190 {
191 return ElementCount(value) >= 0;
192 }

The documentation for this class was generated from the following file: