DIRECTORY Basics USING [Comparison]; NSString: CEDAR DEFINITIONS = BEGIN Character: TYPE = MACHINE DEPENDENT RECORD [chset, code: BYTE]; Characters: TYPE = REF CharactersRep; CharactersRep: TYPE = RECORD [data: SEQUENCE length: CARDINAL OF Character]; String: TYPE = REF TEXT; StringRep: TYPE ~ TEXT; SubString: TYPE = REF SubStringDescriptor; SubStringDescriptor: TYPE = RECORD [base: String, offset, length: CARDINAL]; Relation: TYPE = Basics.Comparison; MesaString: TYPE = REF TEXT; nullString: String = NIL; LogicalLength: PROC [s: String] RETURNS [CARDINAL]; WordsForString: PROC [bytes: CARDINAL] RETURNS [CARDINAL]; AppendCharacter: PROC [to: String, from: Character] RETURNS [String]; AppendString: PROC [to: String, from: String] RETURNS [String]; AppendSubString: PROC [to: String, from: SubString] RETURNS [String]; CompareStrings: PROC [s1, s2: String, ignoreCase: BOOLEAN _ TRUE] RETURNS [Relation]; CompareSubStrings: PROC [s1, s2: SubString, ignoreCase: BOOLEAN _ TRUE] RETURNS [Relation]; DeleteSubString: PROC [s: SubString] RETURNS [String]; EqualCharacter: PROC [c: Character, s: String, index: CARDINAL] RETURNS [BOOLEAN]; EqualString, EqualStrings: PROC [s1, s2: String] RETURNS [BOOLEAN] = INLINE { RETURN[CompareStrings[s1, s2, FALSE] = equal]}; EqualSubString, EqualSubStrings: PROC [s1, s2: SubString] RETURNS [BOOLEAN] = INLINE {RETURN[CompareSubStrings[s1, s2, FALSE] = equal]}; EquivalentString, EquivalentStrings: PROC [s1, s2: String] RETURNS [BOOLEAN] = INLINE {RETURN[CompareStrings[s1, s2] = equal]}; EquivalentSubString, EquivalentSubStrings: PROC [s1, s2: SubString] RETURNS [BOOLEAN] = INLINE {RETURN[CompareSubStrings[s1, s2] = equal]}; ScanForCharacter: PROC [c: Character, s: String, start: CARDINAL _ 0] RETURNS [CARDINAL]; UpperCase, LowerCase: PROC [c: Character] RETURNS [Character]; WellFormed: PROC [s: String] RETURNS [BOOLEAN]; MakeString: PROC [bytes: CARDINAL] RETURNS [String]; FreeString: PROC [s: String]; CopyString: PROC [s: String] RETURNS [String]; ExpandString: PROCEDURE [s: String] RETURNS [Characters]; FreeCharacters: PROCEDURE [c: Characters]; TruncateString: PROC [s: String, bytes: CARDINAL] RETURNS [String]; CompareStringsAndStems: PROC [s1, s2: String, ignoreCase: BOOLEAN _ TRUE] RETURNS [relation: Relation, equalStems: BOOLEAN]; CompareStringsTruncated: PROC [s1, s2: String, trunc1, trunc2: BOOLEAN _ FALSE, ignoreCase: BOOLEAN _ TRUE] RETURNS [Relation]; AppendDecimal: PROC [s: String, n: INTEGER] RETURNS [String]; AppendOctal: PROC [s: String, n: UNSPECIFIED] RETURNS [String]; AppendLongNumber: PROC [s: String, n: LONG UNSPECIFIED, radix: CARDINAL _ 10] RETURNS [String]; AppendLongDecimal: PROC [s: String, n: LONG INTEGER] RETURNS [String]; AppendNumber: PROC [s: String, n: UNSPECIFIED, radix: CARDINAL _ 10] RETURNS [String]; StringToDecimal: PROC [s: String] RETURNS [INTEGER] = INLINE { RETURN[StringToNumber[s, 10]]}; StringToOctal: PROC [s: String] RETURNS [WORD] = INLINE {RETURN[StringToNumber[s, 8]]}; StringToLongNumber: PROC [s: String, radix: CARDINAL _ 10] RETURNS [LONG UNSPECIFIED]; StringToNumber: PROC [s: String, radix: CARDINAL _ 10] RETURNS [UNSPECIFIED]; StringFromMesaString: PROC [s: MesaString] RETURNS [String]; AppendToMesaString: PROC [to: MesaString, from: String]; ValidAsMesaString: PROC [s: String] RETURNS [BOOLEAN]; InvalidNumber: ERROR; -- raised by StringToDecimal if the characters do not represent a decimal number. This is a SIGNAL is String.mesa InvalidString: ERROR; StringBoundsFault: SIGNAL [old: String, increaseBy: CARDINAL] RETURNS [new: String]; END. -- of NSString LOG ( date - person - action ) February 26, 1981 - Kabcenell - Creation. - - - - FILING 5.0 - - - - 1-Mar-82 14:07:59 - Hamilton - Add SubString and StringToDecimal stuff. 19-Apr-82 15:59:12 - Hamilton - Add remaining ops that String.mesa has and NSString.mesa doesn't. August 2, 1982 - Hanzel - Define Characters, ExpandString, and Freecharacters in support of character-level access. August 5, 1982 - Kiser - Added increaseBy to StringBoundsFault. 5-Aug-82 19:18:52 - Kabcenell - Changed order of arguments in ExpandString and FreeCharacters; made Characters a LONG DESCRIPTOR. 2-Sep-82 15:50:35 - Kiser - Made internal structure of Character visible; added DescribeString. 22-Sep-82 21:00:195 - Kiser - Changed NOTE comment: StringBoundsFault always leaves a well-formed string. ²NSString.mesa Copyright Σ 1986, 1987 by Xerox Corporation. All rights reserved. Revised by Kiser: 22-Sep-82 21:00:23 Overview: Definitions for the international network string format. Tim Diebert: January 6, 1987 5:02:56 pm PST Ruseli Binsol: November 18, 1986 4:27:01 pm PST Courier USING [Description], -- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- TYPES : -- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- Handle to network string. offset and length are in logical characters, not bytes. -- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- CONSTANTS : -- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- Null value of String. -- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- OPERATIONS : -- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- BASIC STRING OPERATIONS: Returns the number of NS characters in the string (not the same as the number of bytes). Return the number of words needed for a string whose maxlength is equal to the specified number of bytes. NOTE: all three append operations may raise StringBoundsFault. If the client wishes the operation to continue in such a case, it is his obligation to supply a new, larger string, whose contents are identical to what was in the old string just BEFORE the call which raised StringBoundsFault. i.e. the client should fill the new string based on the "to" argument String, and NOT from the "old" String passed back by StringBoundsFault (unless, of course, the client is satisfied with a partial copy). Append the specified character or string to the end of the specified string. The returned String replaces the "to" String, which should no longer be used. Appends the substring to the end of the specified string. Compare the strings, ignoring the case if specified. Compare the substrings, ignoring the case if specified. Delete the specified SubString from its parent string TRUE if the character indicated by the string index is equal to the given character. index is a logical character index, not a byte index. TRUE if the two strings are character-by-character equal. TRUE if the two substrings are character-by-character equal. TRUE if the two strings are equal, disregarding case. TRUE if the two substrings are equal, disregarding case. Scans the string for the specified character from the given starting point. start and return value are logical character indices, not byte indices. Failure is indicated by returning LAST [CARDINAL]. TRUE if the string contains a valid sequence of bytes. STRING ALLOCATION/DEALLOCATION Allocate a string with a maximum length of bytes and a current length of zero. Deallocate the specified string. Allocate a string which is an exact copy of the specified string (although its maximum length may be less). CHARACTER ACCESS Return the set of logical characters within the specified string. Return storage allocated for logical character access to the specified zone. ROUTINES FOR DEALING WITH TRUNCATED STRINGS Return the longest valid String whose length is less than or equal to MIN [s.length, bytes]. Note that the returned String refers to the same storage as that addressed by the String argument. Compare the strings, ignoring the case if specified. "equalStems" is TRUE if the strings are equal at least up to the end of the shorter one. Compare the strings, ignoring the case if specified. If "truncN" is specified, the corresponding string is considered to be truncated and is treated as *. ROUTINES FOR INTERCONVERTING Strings AND Numbers Converts the value of n to radix 10 text and appends it to s. Supplies a leading minus sign if n is negative. Converts the value of n to radix 8 text and appends it to s. Appends a "B". Analgous to AppendNumber. Analgous to AppendDecimal. Converts the value of n to text using radix and appends it to s. radix sould be in the interval [2..36]. Converts the specified string to a decimal value. Raises InvalidNumber if s does not represent a valid decimal number. Analogous to StringToNumber, except it returns a LONG INTEGER instead of an UNSPECIFIED. See PPM for details. ROUTINES FOR INTERCONVERTING NSStrings AND MesaStrings Return a String which contains the same bytes as are in the Mesa string. Note that the data is not copied; the validity of the String depends on the continued existence of the Mesa string. Append the bytes in the String to the end of the Mesa string. Note that some of these bytes may not actually be Mesa characters; use ValidAsMesaString to make sure, if desired. TRUE if all characters in the string are valid Mesa characters. COURIER DESCRIPTIONS DescribeString: Courier.Description; Caveat: When deserializing a String, the maxlength may not be set to the correct value. It is only guaranteed to have a value >= the length of the string. The maxlength field may, of course, be set by the client after deserialization to match the length field. -- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- SIGNALS AND ERRORS : -- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- The string has an invalid format. Overflow: ERROR; ++ this is defined as a SIGNAL in String.mesa, but isn't raised by anyone. The string is too small by increaseBy bytes; if desired, continue with a new one, after copying into it all old characters which were in the old string BEFORE the start of the operation raising StringBoundsFault. (See note before AppendCharacter.) Κς˜codešœ ™ KšœB™BKšœ%™%KšœC™CK™+K™/—K˜šΟk ˜ Kšœœ™Kšœœ˜—K˜KšΟnœœ œ˜#˜KšœI™IKšœ™KšœI™I—˜Kš œ œœ œœœ˜?—˜Kšœ œœ˜%Kš œœœœ œœ ˜L—˜Kšœœœœ˜šœ œœ˜Kšœ™——˜Kšœ œœ˜*šœœœ œ˜LKšœ7™7——˜Kšœ œ˜#—˜Kšœ œœœ˜—˜KšœI™IKšœ ™ KšœI™I—˜Kšœœ˜Kšœ™—˜KšœI™IKšœ ™ KšœI™I—˜Kšœ™—˜šž œœ œœ˜3KšœX™X——˜š žœœ œœœ˜:Kšœi™i——˜Kšœτ™τ—˜Kšžœœœ ˜E—˜šž œœœ ˜?Kšœ›™›—K˜šžœœœ ˜EKšœ9™9——˜š žœœœœœ ˜UKšœ4™4——˜š žœœ!œœœ ˜[Kšœ7™7——˜šžœœœ ˜6Kšœ5™5——˜š žœœ"œœœ˜RKšœ‹™‹——˜š ž œž œœœœœ˜MKšœœ ˜/Kšœ9™9——˜š žœžœœœœ˜MKšœœœ ˜:Kšœ<™<——˜š žœžœœœœ˜NKšœœ"˜0Kšœ5™5——˜šžœžœœ˜CKšœœœœ%˜GKšœ8™8——˜š žœœ"œœœ˜YKšœΘ™Θ——˜Kšž œž œœœ ˜>K˜šž œœ œœ˜/Kšœ6™6——˜Kšœ™—˜šž œœ œœ ˜4KšœN™N——˜šž œœ ˜Kšœ ™ ——˜šž œœ œ ˜.Kšœk™k——˜Kšœ™—˜šž œ œ œ˜9KšœA™A——˜šžœ œ˜*KšœL™L——˜Kšœ+™+—˜šžœœœœ ˜CKšœΐ™ΐ——˜š žœœœœœ"œ˜|KšœŽ™Ž——˜šžœœ"œœœœœ ˜Kšœ£™£——˜Kšœ0™0—˜šž œœœœ ˜=Kšœn™n——˜šž œœ œœ ˜?KšœL™L——˜š žœœœ œ œœ ˜_Kšœ™——˜š žœœœœœ ˜FKšœ™——˜š ž œœ œ œœ ˜VKšœi™i——˜š žœœ œœ˜