functionloadClassContentString

Loads class elements from a string and inserts them into the given loaded class.

Information

Loads class content from a string and inserts it into the given loaded class with an optional position offset for graphical annotations. The existing class must be a long class definition, either normal or class extends. The content is merged according to the following rules:

  • public/protected sections: Merged with the last public/protected section if the protection is the same.
  • equation sections: Merged with the last equation section if it's the same type of equation section (normal/initial).
  • external declaration: The new declaration overwrites the old.
  • annotations: The new annotation is merged with the old.

Any section not merged is added after the last section of the same type, or where they would normally be placed if no such section exists (i.e. public/protected first, then equations, etc).

Example:

loadClassContentString("
    Real y;
  algorithm
    y = x;
", P.M);

If an offset is given it will be applied to the graphical annotations on the loaded content before it's merged into the class, for example Placement annotations on components.

Inputs

TypeNameDefaultDescription
Stringdata
TypeNameclassName
IntegeroffsetX0
IntegeroffsetY0

Outputs

TypeNameDefaultDescription
Booleansuccess