Text

Motivation | Related Components | Abstract Components | Concrete Components | Component Coupling Diagram

Text is a built-in type in RESOLVE/C++, which is included when you bring "RESOLVE_Foundation.h" into the global context. The name Text is, therefore, unusual: It is the name of a concrete instance even though it does not end in "_2" or "_1a" or the like.


1. Motivation, Applicability, and Indications for Use


RESOLVE/C++ (through the RESOLVE Foundation) includes Boolean , Character, Integer, and Real as built-in scalar types. An object of any of these types has a very simple mathematical model: a simple mathematical type — boolean, character, integer, and real, respectively. While Boolean, Integer , and Real objects clearly are useful in a variety of situations, Character objects usually seem less valuable. The reason is that normally you want to combine individual Character objects into strings (sequences). If you need to deal with a sequence of characters as a unit, then you should use a Text object, whose mathematical model is a string of characters.

RESOLVE/C++ has literals (constants) of the built-in types Boolean , Character, Integer, and Real  — e.g., true, 'a', 13, and 3.14159, respectively. There also are literals of type Text, e.g., "hello there ". A Text literal comprises zero or more Character literals enclosed in double-quotes, without single-quotes around the individual Character literals that make it up. You may use a Text literal any place a Text object is required as an argument to an operation if the associated formal parameter has preserves mode. This makes Text a very useful type when you need to prompt a user for input, label an output, construct a menu of choices, etc. Such prompts and labels may be Text literals in your source code.1


2. Related Components


  • Character — the type of each of the individual items in a Text object
  • Sequence — a generalization of Text in which the individual items may be of any type

  • 3. Component Family Members


    Abstract Components

  • Text_Type — the programming type of interest
  • Text_Add
  • Text_Remove
  • Text_Accessor
  • Text_Length
  • Text_Clear
  • Text_Kernel — a bundle combining the components above
  • Text_Compare
  • Text_Copy_To
  • Text_Get_From
  • Text_Put_To
  • Text_Concatenate
  • Text_Split
  • Text_Is_Equal_To
  • Text_Enhanced — a bundle combining Text_Kernel and the abstract components that come after it in the list of family members
  • Concrete Components

  • Text — This is the standard implementation of the abstract instance Text_Enhanced which comes built-in to RESOLVE/C++. All objects of this type have the interface of Text_Enhanced, with the concrete instance name Text substituted for the abstract instance name Text_Enhanced. Text is a checking component, which means that it checks the preconditions of its operations, so if you call any of the Text operations with a violated precondition then your program will immediately stop and report the violation.
  • To bring this component into the context you write:

      #include "RESOLVE_Foundation.h"


    4. Component Coupling Diagram



    1.   For flexibility, you might store such Text literals in “resource files”. This allows a knowledgeable user to customize certain aspects of an application program (e.g., to adapt it to a foreign language) without having access to the source code. Resource files are not further discussed here, but they are conventional features of programs written for many systems, e.g., Macintosh or MS Windows.