Haxe 标准库简介

参考:https://haxe.org/documentation/introduction/stdlib-introduction.html

Haxe 标准库提供了通用的工具,而不是试图成为数据结构和算法的详尽集合。Haxe 发行版附带一个包含 Haxe 标准库的 std 目录。它的内容可以这样分类:

  • 一般用途std 目录本身包含一些顶级类,如 ArrayMapString,它们可以用于所有目标。haxe 子目录提供额外的数据结构、输入/输出 api 和更多工具。

  • 系统:子目录 sys 包含与文件系统和数据库相关的 api。此外,Sys 顶级类允许与操作系统进行各种交互。它们只能在编译到 sys 类的目标(C++, C#, Java, Neko, PHP)时被访问。

  • 特定于目标:每个 Haxe 目标有一个不同的子目录,其中包含特定于目标的 api。只有在编译到给定目标时才能访问它们。

一般用途

对所有目标可用。

最高阶层的:

  • Array:类型化集合,它定义了几个符合 ECMA 的操作

  • Date, DateTools:与日期和时间戳相关的操作

  • EReg:正则表达式

  • Lambda: Operations over iterables

  • Map: Key-to-value mapping data structure

  • Math: ECMA-compliant mathematical functions

  • Reflect: Field-related reflection

  • Std: Runtime type-checking; numerical parsing; conversion to Int and String

  • String: Basic operations on String

  • StringBuf: Optimized for building Strings

  • StringTools: Various extensions to String

  • Type: Type-related reflection

  • Xml: Cross-platform XML

haxe 包:

haxe.ds 包:

haxe.io 包:

系统 API

可在 C++,C#, Java, Neko 和 PHP。

  • Sys: Execute native commands; interact with stdin, stdout and stderr; various other native operations

  • sys.FileSystem: Read and modify directories; obtain information on files and directories

  • sys.db: APIs for working with MySQL and SQLite databases

  • sys.io.File: Read and write file content; copy files

  • sys.io.Process: Use native processes

  • sys.thread: API for multi-threaded applications.

目标特定 API

  • cpp:

    • cpp.Lib: Provides platform-specific functions for the C++ target.

    • cpp.vm: Thread API, debugger, profiler etc.

  • js:

    • js.Lib: Provides some platform-specific functions for the JavaScript target.

    • js.Browser: Shortcuts for common browser functions.

    • js.html: Externs for interacting with the native JavaScript API’s / DOM.

    • js.html: Helper for low-level JavaScript specific code generation.

  • php:

    • php.Lib: Provides platform-specific functions for the PHP target.

    • php.Syntax: Helper for low-level PHP specific code generation.

    • php.Session: Work with native PHP sessions

    • php.Web: Work with HTTP requests and responses

    • php.db.PDO: Additional PDO driver for database interactions

  • cs: API for C# target

    • cs.Lib: Provides platform-specific functions for the C# target.

    • cs.system: Externs for interacting with native C# classes.

  • java: API for Java target

    • java.Lib Provides platform-specific functions for the Java target.

    • java.* Externs for interacting with native Java classes.

  • python:

    • python.Lib: Provides platform-specific functions for the Python target.

    • python.Syntax: Helper for low-level Python specific code generation.

    • python.Syntax: Externs for interacting with native Python classes.

  • flash:

  • neko:

    • neko.Lib: Low level interactions with the Neko VM target.

    • neko.Web: Work with HTTP requests and responses.

    • neko.net: Tools for interacting with networks and running servers.

    • neko.vm: API for multi-threaded applications.

  • hl: Low level interactions with the HashLink target

  • lua: Low level interactions with the lua target