LayoutFarm.TextBreak.WordVisitor.LoadText C# (CSharp) Method

LoadText() public method

public LoadText ( char buffer, int index ) : void
buffer char
index int
return void
        public void LoadText(char[] buffer, int index)
        {
            this.buffer = buffer;
            this.bufferLen = buffer.Length;
            this.startIndex = currentIndex = index;
            this.currentChar = buffer[currentIndex];
            breakAtList.Clear();
            latestBreakAt = 0;
        }
        public VisitorState State

Usage Example

コード例 #1
0
        public void BreakWords(char[] charBuff, int startAt)
        {
            //conver to char buffer
            int j = charBuff.Length;

            textLength = j;
            visitor.LoadText(charBuff, 0);
            //----------------------------------------
            BreakingEngine currentEngine = breakingEngine = SelectEngine(charBuff[startAt]);

            //----------------------------------------
            //select breaking engine
            for (; ;)
            {
                //----------------------------------------
                currentEngine.BreakWord(visitor, charBuff, startAt, charBuff.Length - startAt);
                switch (visitor.State)
                {
                default: throw new NotSupportedException();

                case VisitorState.End:
                    //ok
                    return;

                case VisitorState.OutOfRangeChar:
                {
                    //find proper breaking engine for current char

                    BreakingEngine anotherEngine = SelectEngine(visitor.Char);
                    if (anotherEngine == currentEngine)
                    {
                        throw new NotSupportedException();
                    }
                    else
                    {
                        currentEngine = anotherEngine;
                        startAt       = visitor.CurrentIndex;
                    }
                }
                break;
                }
            }
        }