-- String.Mesa  Last edited by Sandman on June 30, 1980  11:02 AM
-- Copyright  Xerox Corporation 1979, 1980

DIRECTORY
  AltoDefs USING [charlength, CharsPerPage, CharsPerWord, LogCharsPerPage],
  StringDefs USING [SubString, SubStringDescriptor];

String: DEFINITIONS =
  BEGIN

  StringHeaderSize: CARDINAL = 2;

  CharsPerWord: CARDINAL = AltoDefs.CharsPerWord;
  charlength: CARDINAL = AltoDefs.charlength;
  CharsPerPage: CARDINAL = AltoDefs.CharsPerPage;
  LogCharsPerPage: CARDINAL = AltoDefs.LogCharsPerPage;

  SubStringDescriptor: TYPE = StringDefs.SubStringDescriptor;

  SubString: TYPE = StringDefs.SubString;

  Overflow: SIGNAL;
  InvalidNumber: SIGNAL;
  StringBoundsFault: SIGNAL [s: STRING] RETURNS [ns: STRING];

  WordsForString: PROCEDURE [nchars: CARDINAL] RETURNS [CARDINAL];

  AppendChar: PROCEDURE [s: STRING, c: CHARACTER];
  AppendString: PROCEDURE [to: STRING, from: STRING];
  EqualString, EquivalentString: PROCEDURE [s1, s2: STRING] RETURNS [BOOLEAN];
  EqualStrings, EquivalentStrings: PROCEDURE [s1, s2: STRING] RETURNS [BOOLEAN];
  CompareStrings: PROCEDURE [s1, s2: STRING, ignoreCase: BOOLEAN ← TRUE]
    RETURNS [INTEGER]; --  -1 => less, 0 => equal, 1 => greater


  AppendSubString: PROCEDURE [to: STRING, from: SubString];
  EqualSubStrings, EquivalentSubStrings: PROCEDURE [s1, s2: SubString]
    RETURNS [BOOLEAN];
  EqualSubString, EquivalentSubString: PROCEDURE [s1, s2: SubString]
    RETURNS [BOOLEAN];
  DeleteSubString: PROCEDURE [s: SubString];

  UpperCase, LowerCase: PROCEDURE [c: CHARACTER] RETURNS [CHARACTER];

  -- routines for converting between strings and numbers


  StringToNumber: PROCEDURE [s: STRING, radix: CARDINAL] RETURNS [UNSPECIFIED];
  StringToDecimal: PROCEDURE [s: STRING] RETURNS [INTEGER] = INLINE
    BEGIN RETURN[StringToNumber[s, 10]] END;

  StringToOctal: PROCEDURE [s: STRING] RETURNS [UNSPECIFIED] = INLINE
    BEGIN RETURN[StringToNumber[s, 8]]; END;

  StringToLongNumber: PROCEDURE [s: STRING, radix: CARDINAL]
    RETURNS [LONG UNSPECIFIED];
  AppendNumber: PROCEDURE [s: STRING, n: CARDINAL, radix: CARDINAL];
  AppendDecimal: PROCEDURE [s: STRING, n: INTEGER];
  AppendOctal: PROCEDURE [s: STRING, n: UNSPECIFIED];
  AppendLongNumber: PROCEDURE [s: STRING, n: LONG UNSPECIFIED, radix: CARDINAL];
  AppendLongDecimal: PROCEDURE [s: STRING, n: LONG INTEGER];
  END.