HDK
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
HUSD_CvexCode.h
Go to the documentation of this file.
1 /*
2  * Copyright 2019 Side Effects Software Inc.
3  *
4  * Licensed under the Apache License, Version 2.0 (the "License");
5  * you may not use this file except in compliance with the License.
6  * You may obtain a copy of the License at
7  *
8  * http://www.apache.org/licenses/LICENSE-2.0
9  *
10  * Unless required by applicable law or agreed to in writing, software
11  * distributed under the License is distributed on an "AS IS" BASIS,
12  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13  * See the License for the specific language governing permissions and
14  * limitations under the License.
15  *
16  */
17 
18 #ifndef __HUSD_CvexCode__
19 #define __HUSD_CvexCode__
20 
21 #include "HUSD_API.h"
22 #include <UT/UT_StringHolder.h>
23 
24 /// Abstracts the CVEX source code (either command or vexpression), along
25 /// with some aspects of it, such as return type and export parameter mask
26 /// for expressions.
28 {
29 public:
30  /// Creates the cvex code object given the string and its meaning.
31  HUSD_CvexCode( const UT_StringRef &cmd_or_vexpr, bool is_cmd = true );
32 
33  /// Returns the source string (either a command or vexpression).
34  const UT_StringHolder & getSource() const
35  { return mySource; }
36 
37  /// Returns true if the source is a command, or false if it's a vexpression.
38  bool isCommand() const
39  { return myIsCommand; }
40 
41  // Lists return types.
42  enum class ReturnType
43  {
44  NONE, // void type (usually all output parameters are used)
45  BOOLEAN, // true/false for selection of entities
46  STRING, // for keyword value
47  };
48 
49  /// @{ Sets the return type for the code.
50  /// Cvex scripts that select (match) primitives or faces return a boolean.
51  /// Cvex scripts that partition with keyword, usually return a string.
52  /// Cvex scripts that partition with all outupt values, or run on all
53  /// attributes (ie, are not used for selection or partitionin),
54  /// usually return void (which is a default value).
56  { myReturnType = type; }
58  { return myReturnType; }
59  /// @}
60 
61 private:
62  UT_StringHolder mySource; // command or expression source code
63  bool myIsCommand; // true if source is a command line
64  ReturnType myReturnType; // return type of the vexpression
65 };
66 
67 #endif
68 
ReturnType getReturnType() const
Definition: HUSD_CvexCode.h:57
#define HUSD_API
Definition: HUSD_API.h:32
void setReturnType(ReturnType type)
Definition: HUSD_CvexCode.h:55
GLuint GLuint GLsizei GLenum type
Definition: glew.h:1253
bool isCommand() const
Returns true if the source is a command, or false if it's a vexpression.
Definition: HUSD_CvexCode.h:38
const UT_StringHolder & getSource() const
Returns the source string (either a command or vexpression).
Definition: HUSD_CvexCode.h:34
type
Definition: core.h:528