package org.unicode.icu4x;
import com.sun.jna.Callback
import com.sun.jna.Library
import com.sun.jna.Native
import com.sun.jna.Pointer
import com.sun.jna.Structure

internal interface LineBreakIteratorLatin1Lib: Library {
    fun icu4x_LineBreakIteratorLatin1_destroy_mv1(handle: Pointer)
    fun icu4x_LineBreakIteratorLatin1_next_mv1(handle: Pointer): Int
}
/** See the [Rust documentation for `LineBreakIterator`](https://docs.rs/icu/2.2.0/icu/segmenter/iterators/struct.LineBreakIterator.html) for more information.
*/
class LineBreakIteratorLatin1 internal constructor (
    internal val handle: Pointer,
    // These ensure that anything that is borrowed is kept alive and not cleaned
    // up by the garbage collector.
    internal val selfEdges: List<Any>,
    internal val aEdges: List<Any?>,
    internal var owned: Boolean,
)  {

    init {
        if (this.owned) {
            this.registerCleaner()
        }
    }

    private class LineBreakIteratorLatin1Cleaner(val handle: Pointer, val lib: LineBreakIteratorLatin1Lib) : Runnable {
        override fun run() {
            lib.icu4x_LineBreakIteratorLatin1_destroy_mv1(handle)
        }
    }
    private fun registerCleaner() {
        CLEANER.register(this, LineBreakIteratorLatin1.LineBreakIteratorLatin1Cleaner(handle, LineBreakIteratorLatin1.lib));
    }

    companion object {
        internal val libClass: Class<LineBreakIteratorLatin1Lib> = LineBreakIteratorLatin1Lib::class.java
        internal val lib: LineBreakIteratorLatin1Lib = Native.load("icu4x", libClass)
    }
    
    /** Finds the next breakpoint. Returns -1 if at the end of the string or if the index is
    *out of range of a 32-bit signed integer.
    *
    *See the [Rust documentation for `next`](https://docs.rs/icu/2.2.0/icu/segmenter/iterators/struct.LineBreakIterator.html#method.next) for more information.
    */
    fun next(): Int {
        
        val returnVal = lib.icu4x_LineBreakIteratorLatin1_next_mv1(handle);
        return (returnVal)
    }

}