Things that can be efficienlty written to a Writer

The point of this interface is to allow the instance to be efficiently written into a Writer.

Ready-to-save documents usually provide this interface.

Introduced properties

abstract fun write_to(stream: Writer)

core :: Writable :: write_to

Write itself to a stream
fun write_to_bytes: Bytes

core :: Writable :: write_to_bytes

Like write_to but return a new Bytes (may be quite large)
fun write_to_file(filepath: String)

core :: Writable :: write_to_file

Like write_to but take care of creating the file
fun write_to_string: String

core :: Writable :: write_to_string

Like write_to but return a new String (may be quite large).

Redefined properties

redef type SELF: Writable

core $ Writable :: SELF

Type of this instance, automatically specialized in every class

All properties

fun !=(other: nullable Object): Bool

core :: Object :: !=

Have self and other different values?
fun ==(other: nullable Object): Bool

core :: Object :: ==

Have self and other the same value?
type CLASS: Class[SELF]

core :: Object :: CLASS

The type of the class of self.
type SELF: Object

core :: Object :: SELF

Type of this instance, automatically specialized in every class
protected fun class_factory(name: String): CLASS

core :: Object :: class_factory

Implementation used by get_class to create the specific class.
fun class_name: String

core :: Object :: class_name

The class name of the object.
fun get_class: CLASS

core :: Object :: get_class

The meta-object representing the dynamic type of self.
fun hash: Int

core :: Object :: hash

The hash code of the object.
init init

core :: Object :: init

fun inspect: String

core :: Object :: inspect

Developer readable representation of self.
protected fun inspect_head: String

core :: Object :: inspect_head

Return "CLASSNAME:#OBJECTID".
intern fun is_same_instance(other: nullable Object): Bool

core :: Object :: is_same_instance

Return true if self and other are the same instance (i.e. same identity).
fun is_same_serialized(other: nullable Object): Bool

core :: Object :: is_same_serialized

Is self the same as other in a serialization context?
intern fun is_same_type(other: Object): Bool

core :: Object :: is_same_type

Return true if self and other have the same dynamic type.
intern fun object_id: Int

core :: Object :: object_id

An internal hash code for the object based on its identity.
fun output

core :: Object :: output

Display self on stdout (debug only).
intern fun output_class_name

core :: Object :: output_class_name

Display class name on stdout (debug only).
fun serialization_hash: Int

core :: Object :: serialization_hash

Hash value use for serialization
intern fun sys: Sys

core :: Object :: sys

Return the global sys object, the only instance of the Sys class.
abstract fun to_jvalue(env: JniEnv): JValue

core :: Object :: to_jvalue

fun to_s: String

core :: Object :: to_s

User readable representation of self.
abstract fun write_to(stream: Writer)

core :: Writable :: write_to

Write itself to a stream
fun write_to_bytes: Bytes

core :: Writable :: write_to_bytes

Like write_to but return a new Bytes (may be quite large)
fun write_to_file(filepath: String)

core :: Writable :: write_to_file

Like write_to but take care of creating the file
fun write_to_string: String

core :: Writable :: write_to_string

Like write_to but return a new String (may be quite large).
package_diagram core::Writable Writable core::Object Object core::Writable->core::Object core::Bytes Bytes core::Bytes->core::Writable core::Text Text core::Text->core::Writable ini::IniFile IniFile ini::IniFile->core::Writable csv::CsvDocument CsvDocument csv::CsvDocument->core::Writable template::Template Template template::Template->core::Writable html::HTMLPage HTMLPage html::HTMLPage->core::Writable html::HTMLTag HTMLTag html::HTMLTag->core::Writable ordered_tree::OrderedTree OrderedTree ordered_tree::OrderedTree->core::Writable core::FlatText FlatText core::FlatText->core::Text core::String String core::String->core::Text core::Buffer Buffer core::Buffer->core::Text core::U16String U16String core::U16String->core::Text core::FlatText... ... core::FlatText...->core::FlatText core::String... ... core::String...->core::String core::Buffer... ... core::Buffer...->core::Buffer core::U16String... ... core::U16String...->core::U16String gen_nit::NitModule NitModule gen_nit::NitModule->template::Template nitcorn::ErrorTemplate ErrorTemplate nitcorn::ErrorTemplate->template::Template html::BSComponent BSComponent html::BSComponent->template::Template template::TemplateString TemplateString template::TemplateString->template::Template popcorn::ErrorTpl ErrorTpl popcorn::ErrorTpl->template::Template popcorn::HtmlErrorTemplate HtmlErrorTemplate popcorn::HtmlErrorTemplate->template::Template template::TmplComposers TmplComposers template::TmplComposers->template::Template template::TmplComposer TmplComposer template::TmplComposer->template::Template template::TmplComposerDetail TmplComposerDetail template::TmplComposerDetail->template::Template gen_nit::NitModule... ... gen_nit::NitModule...->gen_nit::NitModule nitcorn::ErrorTemplate... ... nitcorn::ErrorTemplate...->nitcorn::ErrorTemplate html::BSComponent... ... html::BSComponent...->html::BSComponent template::TemplateString... ... template::TemplateString...->template::TemplateString popcorn::ErrorTpl... ... popcorn::ErrorTpl...->popcorn::ErrorTpl popcorn::HtmlErrorTemplate... ... popcorn::HtmlErrorTemplate...->popcorn::HtmlErrorTemplate template::TmplComposers... ... template::TmplComposers...->template::TmplComposers template::TmplComposer... ... template::TmplComposer...->template::TmplComposer template::TmplComposerDetail... ... template::TmplComposerDetail...->template::TmplComposerDetail html::NitHomepage NitHomepage html::NitHomepage->html::HTMLPage html::NitHomepage... ... html::NitHomepage...->html::NitHomepage

Parents

interface Object

core :: Object

The root of the class hierarchy.

Children

class Bytes

core :: Bytes

A buffer containing Byte-manipulation facilities
class CsvDocument

csv :: CsvDocument

A CSV document representation.
class HTMLPage

html :: HTMLPage

A html page
class HTMLTag

html :: HTMLTag

An HTML element.
class IniFile

ini :: IniFile

Read and write INI configuration files
class OrderedTree[E: Object]

ordered_tree :: OrderedTree

Generic structure to manage and display an ordered tree
class Template

template :: Template

Templates are simple hierarchical pieces of text used for efficient stream writing.
abstract class Text

core :: Text

High-level abstraction for all text representations

Descendants

class BSAlert

html :: BSAlert

A Bootstrap alert component.
class BSBadge

html :: BSBadge

A Bootstrap badge component.
class BSBreadCrumbs

html :: BSBreadCrumbs

A Bootstrap breadcrumbs component.
abstract class BSComponent

html :: BSComponent

Bootstrap component abstraction.
class BSIcon

html :: BSIcon

A Boostrap icon.
class BSLabel

html :: BSLabel

A Bootstrap label component.
class BSPageHeader

html :: BSPageHeader

A Bootstrap page header component.
class BSPanel

html :: BSPanel

A Bootstrap panel component.
abstract class Buffer

core :: Buffer

A mutable sequence of characters.
class ErrorTemplate

nitcorn :: ErrorTemplate

A basic error page for the HTTP error code
class FlatBuffer

core :: FlatBuffer

Mutable strings of characters.
abstract class FlatString

core :: FlatString

Immutable strings of characters.
abstract class FlatText

core :: FlatText

All kinds of array-based text representations.
abstract class HTMLList

html :: HTMLList

An abstract HTML list.
class Header

html :: Header

A <h1> to <h6> tag.
class ListItem

html :: ListItem

A <li> tag.
class NitModule

gen_nit :: NitModule

Template of a Nit module to generate Nit code
class OrderedList

html :: OrderedList

A <ol> list tag.
abstract class String

core :: String

Immutable sequence of characters.
class TemplateString

template :: TemplateString

Template with macros replacement.
class TmplComposer

template :: TmplComposer

A composer in the short list of composers
class TmplComposerDetail

template :: TmplComposerDetail

A composer in the detailled list of composers
class TmplComposers

template :: TmplComposers

The root template for composers
class U16String

core :: U16String

UTF-16 encoded string
class UnorderedList

html :: UnorderedList

A <ul> list tag.

Class definitions

core $ Writable
# Things that can be efficienlty written to a `Writer`
#
# The point of this interface is to allow the instance to be efficiently
# written into a `Writer`.
#
# Ready-to-save documents usually provide this interface.
interface Writable
	# Write itself to a `stream`
	# The specific logic it let to the concrete subclasses
	fun write_to(stream: Writer) is abstract

	# Like `write_to` but return a new String (may be quite large).
	#
	# This functionality is anecdotal, since the point
	# of a streamable object is to be efficiently written to a
	# stream without having to allocate and concatenate strings.
	fun write_to_string: String
	do
		var stream = new StringWriter
		write_to(stream)
		return stream.to_s
	end

	# Like `write_to` but return a new Bytes (may be quite large)
	#
	# This functionality is anecdotal, since the point
	# of a streamable object is to be efficiently written to a
	# stream without having to allocate and concatenate buffers.
	#
	# Nevertheless, you might need this method if you want to know
	# the byte size of a writable object.
	fun write_to_bytes: Bytes
	do
		var stream = new BytesWriter
		write_to(stream)
		return stream.bytes
	end
end
lib/core/stream.nit:547,1--584,3

core :: file $ Writable
redef class Writable
	# Like `write_to` but take care of creating the file
	fun write_to_file(filepath: String)
	do
		var stream = new FileWriter.open(filepath)
		write_to(stream)
		stream.close
	end
end
lib/core/file.nit:365,1--373,3