wc3lib  0.1.0
Namespaces | Classes | Typedefs | Functions | Variables
wc3lib Namespace Reference

Core More...

Namespaces

 blp
 BLP module
 
 editor
 Editor module
 
 jass
 JASS module
 
 map
 Map module
 
 mdlx
 MDLX module
 
 mpq
 MPQ module
 
 resources
 
 test
 
 w3g
 

Classes

class  BasicVertex
 Basic type for N-dimensional vertex which can be serialized and deserialized. More...
 
class  Bgr
 
class  Bgra
 
class  Exception
 Default exception class base which is used for all exception classes in wc3lib. More...
 
class  Format
 Abstract class for serializable file formats which supports basic I/O operations "read" and "write". More...
 
class  Quaternion
 Provides serialization for a quaternion. More...
 
class  Rgb
 Basic RGB color with storage and serialization support of three color channels. More...
 
class  Rgba
 
class  Vertex2d
 Provides serialization for a two dimensional vertex. More...
 
class  Vertex3d
 Provides serialization for a three dimensional vertex. More...
 

Typedefs

typedef char byte
 
typedef unsigned char ubyte
 
typedef int8_t int8
 
typedef uint8_t uint8
 
typedef int16_t int16
 
typedef uint16_t uint16
 
typedef int32_t int32
 
typedef uint32_t uint32
 
typedef int64_t int64
 
typedef uint64_t uint64
 
typedef float float32
 
typedef std::basic_istream< byteistream
 
typedef std::basic_ostream< byteostream
 
typedef std::basic_string< bytestring
 
typedef std::basic_stringstream< bytestringstream
 
typedef std::basic_istringstream< byteistringstream
 
typedef std::basic_ostringstream< byteostringstream
 
typedef boost::filesystem::basic_fstream< bytefstream
 
typedef boost::filesystem::basic_ifstream< byteifstream
 
typedef boost::filesystem::basic_ofstream< byteofstream
 
typedef boost::iostreams::stream< boost::iostreams::basic_array< byte > > arraystream
 
typedef boost::iostreams::stream< boost::iostreams::basic_array_source< byte > > iarraystream
 
typedef boost::iostreams::stream< boost::iostreams::basic_array_sink< byte > > oarraystream
 
typedef uint32_t flag
 
typedef boost::array< byte, 4 > charArray
 

Functions

std::string iostateMessage (const std::ios_base::iostate &state)
 
template<typename T >
std::string hexValue (T value)
 
template<typename _CharT >
void checkStream (std::basic_ios< _CharT > &stream)
 
template<typename T , typename _CharT >
std::basic_istream< _CharT > & read (std::basic_istream< _CharT > &istream, T &value, std::streamsize &sizeCounter, std::streamsize size=sizeof(T)*sizeof(_CharT))
 
template<typename _CharT >
std::basic_istream< _CharT > & readString (std::basic_istream< _CharT > &istream, std::basic_string< _CharT > &value, std::streamsize &sizeCounter, _CharT terminatingChar= '\0', const std::size_t maxLength=1024)
 Reads a C-like string which is terminated by the character terminatingChar from input stream istream into value. More...
 
template<typename T , typename _ByteT >
std::basic_istream< _ByteT > & parse (std::basic_istream< _ByteT > &istream, T &value, std::streamsize &sizeCounter, const std::basic_string< char > &delimiters=" \t\n\r")
 
template<typename _CharT >
std::streampos endPosition (std::basic_istream< _CharT > &istream)
 Gets the last position of an input stream. More...
 
template<typename _CharT >
bool eof (std::basic_istream< _CharT > &istream)
 Checks if the an input stream has reached its end. More...
 
template<typename _CharT >
std::basic_istream< _CharT > & readLine (std::basic_istream< _CharT > &istream, std::string &value, std::streamsize &sizeCounter)
 Reads a '
' terminated string from an input stream. More...
 
template<typename T , typename _CharT >
std::basic_ostream< _CharT > & write (std::basic_ostream< _CharT > &ostream, const T &value, std::streamsize &sizeCounter, std::streamsize size=sizeof(T)*sizeof(_CharT))
 
template<typename T , typename _CharT >
std::basic_ostream< _CharT > & write (std::basic_ostream< _CharT > &ostream, const T *value, std::streamsize &sizeCounter, std::streamsize size)
 
template<typename T , typename _CharT >
std::basic_ostream< _CharT > & write (std::basic_ostream< _CharT > &ostream, T *value, std::streamsize &sizeCounter, std::streamsize size)
 
template<typename _CharT >
std::basic_ostream< _CharT > & writeCString (std::basic_ostream< _CharT > &ostream, const _CharT *value, std::streamsize &sizeCounter, std::streamsize size=0)
 Writes C string of value "value" into output (with 0 terminating char if size is 0). More...
 
template<typename _CharT >
std::basic_ostream< _CharT > & writeString (std::basic_ostream< _CharT > &ostream, const std::basic_string< _CharT > &value, std::streamsize &sizeCounter, std::streamsize size=0)
 
template<typename _CharT >
std::basic_ostream< _CharT > & writeLine (std::basic_ostream< _CharT > &ostream, const _CharT *value, std::streamsize &sizeCounter, std::streamsize size=0)
 
template<typename _CharT >
std::basic_ostream< _CharT > & writeLine (std::basic_ostream< _CharT > &ostream, const std::basic_string< _CharT > &value, std::streamsize &sizeCounter, std::streamsize size=0)
 
template<typename T , typename _CharT >
std::basic_ostream< _CharT > & writeByteCount (std::basic_ostream< _CharT > &ostream, const T &byteCount, std::streampos position, std::streamsize &sizeCounter, bool inclusive=false)
 
template<typename T , typename _CharT >
std::basic_ostream< _CharT > & skipByteCount (std::basic_ostream< _CharT > &ostream, std::streampos &position)
 
template<typename T >
std::string sizeStringBinary (T size)
 
template<typename T >
std::string sizeStringDecimal (T size)
 
std::string boolString (bool value)
 
bool expectInput ()
 Waits for the user input in terminal to confirm or reject something. More...
 

Variables

std::ofstream spiritTraceLog
 

Detailed Description

Core

The LLVM binding uses the visitor pattern to be separated from the jass module. It creates Value objects for all AST nodes to generate LLVM's IR (http://llvm.org/docs/LangRef.html). LLVM should be able to create real assembler code for all of it target architectures then. This builds an abstract compiler implementation.

http://llvm.org/docs/tutorial/LangImpl3.html is used as reference example.

Typedef Documentation

typedef boost::iostreams::stream<boost::iostreams::basic_array<byte> > wc3lib::arraystream
typedef char wc3lib::byte
typedef boost::array<byte, 4> wc3lib::charArray

Chars and Array of Chars They are just stored like standard chars (1 char = 1 byte) and array of chars (no null terminating char needed). Size (chars): 1 byte Size (array of chars): usually 4 bytes

typedef uint32_t wc3lib::flag

Flags

Flags are boolean values (true or false, 1 or 0). They can be stored using 4 bytes. Each bit is a flag (4 bytes = 32 bit = 32 flags). Blizzard uses integers to store its flags. Size: usually 4 bytes

typedef float wc3lib::float32

Floats Floats are using the standard IEEE 32bit float format. They are stored using 4 bytes and the "Little Endian" order. They are just like the C++ "float" type. Size: 4 bytes Example: 7654.32 decimal, this number can't be stored using this format so the system will take the closest value that can be represented using binary digits. The closest one is: 7654.319824 decimal = [45 EF 32 8F]h and will be stored as [8F 32 EF 45]h

MDL notes: Floating point numbers are in IEEE scientific notation format with 6 significant figures. Exponent is not shown for exponents of ±4. If the number is an integral float, decimal point is not shown.

typedef boost::filesystem::basic_fstream<byte> wc3lib::fstream
typedef boost::iostreams::stream<boost::iostreams::basic_array_source<byte> > wc3lib::iarraystream
typedef boost::filesystem::basic_ifstream<byte> wc3lib::ifstream
typedef int16_t wc3lib::int16

Short Integers Short Integers are stored using 2 bytes in "Little Endian" order. They are close to the C++ signed short but their range is from -16384 to 16383. It means the 2 highest bit are free of use for a flag for example. Size: 2 bytes

typedef int32_t wc3lib::int32

Integers Intergers are stored using 4 bytes in "Little Endian" order. It means that the first byte read is the lowest byte. They are just like the C++ "int" (signed) type. In some other documentation of this kind you may see them named "long". Size: 4 bytes Example: 1234 decimal = [00 00 04 D2]h will be stored in this order: [D2 04 00 00]h

typedef int64_t wc3lib::int64
typedef int8_t wc3lib::int8
typedef std::basic_istream<byte> wc3lib::istream
typedef std::basic_istringstream<byte> wc3lib::istringstream
typedef boost::iostreams::stream<boost::iostreams::basic_array_sink<byte> > wc3lib::oarraystream
typedef boost::filesystem::basic_ofstream<byte> wc3lib::ofstream
typedef std::basic_ostream<byte> wc3lib::ostream
typedef std::basic_ostringstream<byte> wc3lib::ostringstream
typedef std::basic_string<byte> wc3lib::string

Trigger Strings and Strings

Strings are just arrays of chars terminated with a null char (C++ '\0'). However Blizzard sometimes use special control codes to change the displayed color for the string. These codes are like "|cAABBGGRR" where "AA", "RR", "GG" and "BB" are hexadecimal values (using 2 digits each) for the alpha, red, the green and the blue values. If a string starts with "TRIGSTR_" (case sensitive), it's considered as a trigger string. A trigger string is kept in memory as is ("TRIGSTR_***") and is only changed when Warcraft 3 needs to display it. Instead of just writing "TRIGSTR_000" on the user screen, War3 will look in its trigger string table created when the map was loaded and display the corresponding trigger string instead. Trigger strings only work for files inside a w3m (Jass, w3i, ...) except for the WTS which is used to define the trigger string table itself. If the number following "TRIGSTR_" is negative the trigger string will refer to a null (empty) string, if "TRIGSTR_" is followed by text, it'll be considered as trigger string #0 ( = "TRIGSTR_000"). "TRIGSTR_7", "TRIGSTR_07", "TRIGSTR_007" and "TRIGSTR_7abc" are all representing trigger string #7. "TRIGSTR_ab7", "TRIGSTR_abc" and "TRIGSTR_" refer to trigger string #0. "TRIGSTR_-7" is negative and will not refer to a trigger string; it'll be displayed as "". By convention, "TRIGSTR_" is followed by 3 digits and the null char that ends the string. Example 1: your got the string "blah |c00FF8000blah", War3 will display "blah blah" but the second "bla h" will be orange (red=FF + green=80 + blue=00 ==> orange) The alpha value doesn't really work btw. Example 2: you got "TRIGSTR_025" and trigger string 25 is defined (in the .wts file) as "blah|c00FF8000blah", it'll display the same result as the previous example. Size (string): vary. String length + 1 (null terminating char) Size (trigger string): 12 bytes

For its strings Warcraft uses a unicode format called UTF-8. They do this because the files need to be localized into many different languages. This format uses one byte for the most common characters which is equal to the character's ASCII value. For example A = 65 or 0x41. For the more unusual characters it can take from 2 to 6 bytes per character. For example the German letter Ä would be represented by 195 and 164 or 0xC3A4. The higher the first byte is, the more bytes are required to represent the character. Simple modulo calculations are enough to convert UTF to common unicode (UCS) and back. To convert UTF to UCS use this pattern:

If FirstByte <= 191 return FirstByte If 192 <= FirstByte <= 223 return (FirstByte - 192) * 64 + (SecondByte - 128) If 224 <= FirstByte <= 239 return (FirstByte - 224) * 4096 + (SecondByte - 128) * 64 + (ThirdByte - 128) If 240 <= FirstByte <= 247 return (FirstByte - 240) * 262144 + (SecondByte - 128) * 4096 + (ThirdByte - 128) * 64 + (FourthByte - 128) If 248 <= FirstByte <= 251 return (FirstByte - 248) * 16777216 + (SecondByte - 128) * 262144 + (ThridByte - 128) * 4096 + (FourthByte - 128) * 64 + (FifthByte - 128) If 252 <= FirstByte return (FirstByte - 252) * 1073741824 + (SecondByte - 128) * 16777216 + (ThirdByte - 128) * 262144 + (FourthByte - 128) * 4096 + (FifthByte - 128) * 64 + (SixthByte - 128) To convert UCS back to UTF use this: If ASCII <= 127 FirstByte = ASCII If 128 <= ASCII <= 2047 FirstByte = 192 + (ASCII \ 64) SecondByte = 128 + (ASCII Mod 64) If 2048 <= ASCII <= 65535 FirstByte = 224 + (ASCII \ 4096) SecondByte = 128 + ((ASCII \ 64) Mod 64) ThirdByte = 128 + (ASCII Mod 64) If 65536 <= ASCII <= 2097151 FirstByte = 240 + (ASCII \ 262144) SecondByte = 128 + ((ASCII \ 4096) Mod 64) ThirdByte = 128 + ((ASCII \ 64) Mod 64) FourthByte = 128 + (ASCII Mod 64) If 2097152 <= ASCII <= 67108863 FirstByte = 248 + (ASCII \ 16777216) SecondByte = 128 + ((ASCII \ 262144) Mod 64) ThirdByte = 128 + ((ASCII \ 4096) Mod 64) FourthByte = 128 + ((ASCII \ 64) Mod 64) FifthByte = 128 + (ASCII Mod 64) If 67108864 <= ASCII <= 2147483647 FirstByte = 252 + (ASCII \ 1073741824) SecondByte = 128 + ((ASCII \ 16777216) Mod 64) ThirdByte = 128 + ((ASCII \ 262144) Mod 64) FourthByte = 128 + ((ASCII \ 4096) Mod 64) FifthByte = 128 + ((ASCII \ 64) Mod 64) SixthByte = 128 + (ASCII Mod 64)) The conversion will only be needed if you want to display text in your application or write user input to files. For all other purposes you can internally treat the UTF-Strings just like ordinary strings.

typedef std::basic_stringstream<byte> wc3lib::stringstream
typedef unsigned char wc3lib::ubyte
typedef uint16_t wc3lib::uint16
typedef uint32_t wc3lib::uint32
typedef uint64_t wc3lib::uint64
typedef uint8_t wc3lib::uint8

Function Documentation

template<typename T >
std::string wc3lib::hexValue ( value)
inline