KSeExpr  4.0.4.0
EditableExpression.h
Go to the documentation of this file.
1 // SPDX-FileCopyrightText: 2011-2019 Disney Enterprises, Inc.
2 // SPDX-License-Identifier: LicenseRef-Apache-2.0
3 // SPDX-FileCopyrightText: 2020 L. E. Segovia <amy@amyspark.me>
4 // SPDX-License-Identifier: GPL-3.0-or-later
5 
6 /*
7  * @file EditableExpression.h
8  * @author Andrew Selle
9  */
10 #pragma once
11 
12 #include <memory>
13 #include <string>
14 #include <vector>
15 
16 class Editable;
17 
20 {
21  std::string _expr; // original full expression
22  using Editables = std::vector<Editable *>; // TODO: use shared_ptr -amyspark
23  Editables _editables; // control that can edit the expression
24  std::vector<std::string> _variables;
25 
26 public:
27  EditableExpression() = default;
28  virtual ~EditableExpression();
29 
34 
36  void setExpr(const std::string &expr);
37 
39  std::string getEditedExpr() const;
40 
42  bool controlsMatch(const EditableExpression &other) const;
43 
45  void updateString(const EditableExpression &other);
46 
48  Editable *operator[](const int i)
49  {
50  return _editables[i];
51  }
52 
54  size_t size() const
55  {
56  return _editables.size();
57  }
58 
60  const std::vector<std::string> &getVariables() const
61  {
62  return _variables;
63  }
64 
65 private:
67  void cleanup();
68 };
Factors a SeExpr into an editable expression with controls (i.e. value boxes, curve boxes)
size_t size() const
Return the count of editable parameters.
EditableExpression(const EditableExpression &)=default
EditableExpression()=default
std::vector< std::string > _variables
void setExpr(const std::string &expr)
Set's expressions and parses it into "control editable form".
std::string getEditedExpr() const
Return a reconstructed expression using all the editable's current values.
Editable * operator[](const int i)
Access an editable parameter.
std::vector< Editable * > Editables
EditableExpression & operator=(const EditableExpression &)=default
EditableExpression & operator=(EditableExpression &&)=default
bool controlsMatch(const EditableExpression &other) const
Check if the other editable expression has editables that all match i.e. the controls are same.
void cleanup()
clean memeory
void updateString(const EditableExpression &other)
Update the string refered to into the controls (this is only valid if controlsmatch)
EditableExpression(EditableExpression &&)=default
const std::vector< std::string > & getVariables() const
Get list of commentsø