view mde/file/mergetag/internal.d @ 179:1f9d00f392bd default tip

Fixed a bug where (non-resizible) widgets wouldn't get shrunk when minimal size decreases, meaning optional context menus are hiden properly now. Optimised when ServiceContentList.opCall is called, I think without breaking anything.
author Diggory Hardy <diggory.hardy@gmail.com>
date Tue, 15 Sep 2009 20:09:59 +0200
parents 4084f07f2c7a
children
line wrap: on
line source

/* LICENSE BLOCK
Part of mde: a Modular D game-oriented Engine
Copyright © 2007-2008 Diggory Hardy

This program is free software: you can redistribute it and/or modify it under the terms
of the GNU General Public License as published by the Free Software Foundation, either
version 2 of the License, or (at your option) any later version.

This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY;
without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
See the GNU General Public License for more details.

You should have received a copy of the GNU General Public License
along with this program.  If not, see <http://www.gnu.org/licenses/>. */

/// Contains functions/data structures used internally by mergetag.
module mde.file.mergetag.internal;

    enum MTFormat : ubyte {	// known formats
        INVALID	= 0x00,
        MT01	= 0x01,		// not yet final
    }
    /// The current MergeTag version
    static const MTFormat CurrentVersion = MTFormat.MT01;
    static const char[] CurrentVersionString = "MT01";
    
    static MTFormat checkVersion (char[] str)
    in {
            assert (str.length == 2);
    } body {
        if (str[0] == '0' && str[1] == '1') return MTFormat.MT01;
        else return MTFormat.INVALID;
    }
    
    /// Check the header (first 6 bytes) and return version
    static MTFormat checkHeader (char[] fbuf) {
        if (fbuf.length < 6 || fbuf[0] != '{' || fbuf[1] != 'M' || fbuf[2] != 'T' || fbuf[5] != '}')
            return MTFormat.INVALID;
        else
            return checkVersion (fbuf[3..5]);
    }
    
    // taken from tango.io.Console, mostly to make sure notepad can read our files:
    version (Win32)
            const char[] Eol = "\r\n";
    else
        const char[] Eol = "\n";