ST_STRING_ROUTINES

1 message Options
Embed this post
Permalink
Colin Paul Adams

ST_STRING_ROUTINES

Reply Threaded More More options
Print post
Permalink
indexing

        description:

                "Support routines used by ST_STRING and ST_STRING_BUILDER"

        library: "Gobo Eiffel String Library"
        copyright: "Copyright (c) 2008, Colin Adams and others"
        license: "MIT License"
        date: "$Date:  $"
        revision: "$Revision:  $"

class ST_STRING_ROUTINES

inherit
       
        ST_IMPORTED_UNICODE_CHARACTER_CLASS_ROUTINES

feature -- Access

        string_sums (a_strings: ARRAY [READABLE_STRING_GENERAL]): INTEGER is
                        -- Total number of characters in `a_strings'
                require
                        a_strings_not_void: a_strings /= Void
                        all_strings_not_void: not a_strings.has (Void)
                local
                        i, l_count: INTEGER
                do
                        from
                                i := 1
                        until
                                i > a_strings.count
                        loop
                                l_count := l_count + a_strings.item (i).count
                                i := i + 1
                        end
                        Result := l_count
                ensure
                        string_sums_non_negative: Result >= 0
                end
       
feature -- Status report
       
        is_all_whitespace (chars: STRING): BOOLEAN is
                        -- Does `chars' consist only of XML white-space characters?
                local
                        counter: INTEGER
                do
                        from
                                counter := 1
                                Result := True
                        variant
                                chars.count + 1 - counter
                        until
                                Result = False or else counter > chars.count
                        loop
                                if not is_xml_space (chars.item_code (counter)) then
                                        Result := False
                                end
                                counter := counter + 1
                        end
                end

        is_alphanumeric (a_character_code: INTEGER): BOOLEAN is
                        -- Does `a_character_code' represent an alphanumeric character?
                require
                        positive_character_code: a_character_code > 0
                do
                        Result := unicode_character_class.unicode.valid_code (a_character_code)
                                and then (unicode_character_class.is_letter (a_character_code)
                                                         or else unicode_character_class.is_number (a_character_code))
                end

        is_xml_space (a_code: INTEGER): BOOLEAN is
                        -- Does `a_code' represent an XML space?
                do
                        Result := a_code = 32 or a_code = 9 or a_code = 10 or a_code = 13
                end
       
end

--
Colin Adams
Preston Lancashire

-------------------------------------------------------------------------
This SF.Net email is sponsored by the Moblin Your Move Developer's challenge
Build the coolest Linux based applications with Moblin SDK & win great prizes
Grand prize is a trip for two to an Open Source event anywhere in the world
http://moblin-contest.org/redirect.php?banner_id=100&url=/
_______________________________________________
gobo-eiffel-develop mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/gobo-eiffel-develop