project_files/frontlib/model/schemelist.h
author Wuzzy <Wuzzy2@mail.ru>
Sun, 19 May 2019 11:05:57 +0200
changeset 15008 fdf646e3e083
parent 10017 de822cd3df3a
permissions -rw-r--r--
Update locale files
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
10017
de822cd3df3a fixwhitespace and dos2unix
koda
parents: 7497
diff changeset
     1
/*
de822cd3df3a fixwhitespace and dos2unix
koda
parents: 7497
diff changeset
     2
 * Hedgewars, a free turn based strategy game
de822cd3df3a fixwhitespace and dos2unix
koda
parents: 7497
diff changeset
     3
 * Copyright (C) 2012 Simeon Maxein <smaxein@googlemail.com>
de822cd3df3a fixwhitespace and dos2unix
koda
parents: 7497
diff changeset
     4
 *
de822cd3df3a fixwhitespace and dos2unix
koda
parents: 7497
diff changeset
     5
 * This program is free software; you can redistribute it and/or
de822cd3df3a fixwhitespace and dos2unix
koda
parents: 7497
diff changeset
     6
 * modify it under the terms of the GNU General Public License
de822cd3df3a fixwhitespace and dos2unix
koda
parents: 7497
diff changeset
     7
 * as published by the Free Software Foundation; either version 2
de822cd3df3a fixwhitespace and dos2unix
koda
parents: 7497
diff changeset
     8
 * of the License, or (at your option) any later version.
de822cd3df3a fixwhitespace and dos2unix
koda
parents: 7497
diff changeset
     9
 *
de822cd3df3a fixwhitespace and dos2unix
koda
parents: 7497
diff changeset
    10
 * This program is distributed in the hope that it will be useful,
de822cd3df3a fixwhitespace and dos2unix
koda
parents: 7497
diff changeset
    11
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
de822cd3df3a fixwhitespace and dos2unix
koda
parents: 7497
diff changeset
    12
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
de822cd3df3a fixwhitespace and dos2unix
koda
parents: 7497
diff changeset
    13
 * GNU General Public License for more details.
de822cd3df3a fixwhitespace and dos2unix
koda
parents: 7497
diff changeset
    14
 *
de822cd3df3a fixwhitespace and dos2unix
koda
parents: 7497
diff changeset
    15
 * You should have received a copy of the GNU General Public License
de822cd3df3a fixwhitespace and dos2unix
koda
parents: 7497
diff changeset
    16
 * along with this program; if not, write to the Free Software
de822cd3df3a fixwhitespace and dos2unix
koda
parents: 7497
diff changeset
    17
 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
de822cd3df3a fixwhitespace and dos2unix
koda
parents: 7497
diff changeset
    18
 */
de822cd3df3a fixwhitespace and dos2unix
koda
parents: 7497
diff changeset
    19
de822cd3df3a fixwhitespace and dos2unix
koda
parents: 7497
diff changeset
    20
/**
de822cd3df3a fixwhitespace and dos2unix
koda
parents: 7497
diff changeset
    21
 * Functions for managing a list of schemes.
de822cd3df3a fixwhitespace and dos2unix
koda
parents: 7497
diff changeset
    22
 * This is in here because the scheme config file of the QtFrontend (which we are staying compatible with) contains
de822cd3df3a fixwhitespace and dos2unix
koda
parents: 7497
diff changeset
    23
 * all the schemes at once, so we need functions to work with a list like that.
de822cd3df3a fixwhitespace and dos2unix
koda
parents: 7497
diff changeset
    24
 */
de822cd3df3a fixwhitespace and dos2unix
koda
parents: 7497
diff changeset
    25
de822cd3df3a fixwhitespace and dos2unix
koda
parents: 7497
diff changeset
    26
#ifndef SCHEMELIST_H_
de822cd3df3a fixwhitespace and dos2unix
koda
parents: 7497
diff changeset
    27
#define SCHEMELIST_H_
de822cd3df3a fixwhitespace and dos2unix
koda
parents: 7497
diff changeset
    28
de822cd3df3a fixwhitespace and dos2unix
koda
parents: 7497
diff changeset
    29
#include "scheme.h"
de822cd3df3a fixwhitespace and dos2unix
koda
parents: 7497
diff changeset
    30
de822cd3df3a fixwhitespace and dos2unix
koda
parents: 7497
diff changeset
    31
typedef struct {
de822cd3df3a fixwhitespace and dos2unix
koda
parents: 7497
diff changeset
    32
    int schemeCount;
de822cd3df3a fixwhitespace and dos2unix
koda
parents: 7497
diff changeset
    33
    flib_scheme **schemes;
de822cd3df3a fixwhitespace and dos2unix
koda
parents: 7497
diff changeset
    34
} flib_schemelist;
de822cd3df3a fixwhitespace and dos2unix
koda
parents: 7497
diff changeset
    35
de822cd3df3a fixwhitespace and dos2unix
koda
parents: 7497
diff changeset
    36
/**
de822cd3df3a fixwhitespace and dos2unix
koda
parents: 7497
diff changeset
    37
 * Load a list of configurations from the ini file.
de822cd3df3a fixwhitespace and dos2unix
koda
parents: 7497
diff changeset
    38
 * Returns NULL on error.
de822cd3df3a fixwhitespace and dos2unix
koda
parents: 7497
diff changeset
    39
 */
de822cd3df3a fixwhitespace and dos2unix
koda
parents: 7497
diff changeset
    40
flib_schemelist *flib_schemelist_from_ini(const char *filename);
de822cd3df3a fixwhitespace and dos2unix
koda
parents: 7497
diff changeset
    41
de822cd3df3a fixwhitespace and dos2unix
koda
parents: 7497
diff changeset
    42
/**
de822cd3df3a fixwhitespace and dos2unix
koda
parents: 7497
diff changeset
    43
 * Store the list of configurations to an ini file.
de822cd3df3a fixwhitespace and dos2unix
koda
parents: 7497
diff changeset
    44
 * Returns NULL on error.
de822cd3df3a fixwhitespace and dos2unix
koda
parents: 7497
diff changeset
    45
 */
de822cd3df3a fixwhitespace and dos2unix
koda
parents: 7497
diff changeset
    46
int flib_schemelist_to_ini(const char *filename, const flib_schemelist *config);
de822cd3df3a fixwhitespace and dos2unix
koda
parents: 7497
diff changeset
    47
de822cd3df3a fixwhitespace and dos2unix
koda
parents: 7497
diff changeset
    48
/**
de822cd3df3a fixwhitespace and dos2unix
koda
parents: 7497
diff changeset
    49
 * Create an empty scheme list. Returns NULL on error.
de822cd3df3a fixwhitespace and dos2unix
koda
parents: 7497
diff changeset
    50
 */
de822cd3df3a fixwhitespace and dos2unix
koda
parents: 7497
diff changeset
    51
flib_schemelist *flib_schemelist_create();
de822cd3df3a fixwhitespace and dos2unix
koda
parents: 7497
diff changeset
    52
de822cd3df3a fixwhitespace and dos2unix
koda
parents: 7497
diff changeset
    53
/**
de822cd3df3a fixwhitespace and dos2unix
koda
parents: 7497
diff changeset
    54
 * Insert a new scheme into the list at position pos, moving all higher schemes to make place.
de822cd3df3a fixwhitespace and dos2unix
koda
parents: 7497
diff changeset
    55
 * pos must be at least 0 (insert at the start) and at most list->schemeCount (insert at the end).
de822cd3df3a fixwhitespace and dos2unix
koda
parents: 7497
diff changeset
    56
 * Ownership of the scheme is transferred to the list.
de822cd3df3a fixwhitespace and dos2unix
koda
parents: 7497
diff changeset
    57
 * Returns 0 on success.
de822cd3df3a fixwhitespace and dos2unix
koda
parents: 7497
diff changeset
    58
 */
de822cd3df3a fixwhitespace and dos2unix
koda
parents: 7497
diff changeset
    59
int flib_schemelist_insert(flib_schemelist *list, flib_scheme *cfg, int pos);
de822cd3df3a fixwhitespace and dos2unix
koda
parents: 7497
diff changeset
    60
de822cd3df3a fixwhitespace and dos2unix
koda
parents: 7497
diff changeset
    61
/**
de822cd3df3a fixwhitespace and dos2unix
koda
parents: 7497
diff changeset
    62
 * Delete a scheme from the list at position pos, moving down all higher schemes.
de822cd3df3a fixwhitespace and dos2unix
koda
parents: 7497
diff changeset
    63
 * The scheme is destroyed.
de822cd3df3a fixwhitespace and dos2unix
koda
parents: 7497
diff changeset
    64
 * Returns 0 on success.
de822cd3df3a fixwhitespace and dos2unix
koda
parents: 7497
diff changeset
    65
 */
de822cd3df3a fixwhitespace and dos2unix
koda
parents: 7497
diff changeset
    66
int flib_schemelist_delete(flib_schemelist *list, int pos);
de822cd3df3a fixwhitespace and dos2unix
koda
parents: 7497
diff changeset
    67
de822cd3df3a fixwhitespace and dos2unix
koda
parents: 7497
diff changeset
    68
/**
de822cd3df3a fixwhitespace and dos2unix
koda
parents: 7497
diff changeset
    69
 * Find the scheme with a specific name
de822cd3df3a fixwhitespace and dos2unix
koda
parents: 7497
diff changeset
    70
 */
de822cd3df3a fixwhitespace and dos2unix
koda
parents: 7497
diff changeset
    71
flib_scheme *flib_schemelist_find(flib_schemelist *list, const char *name);
de822cd3df3a fixwhitespace and dos2unix
koda
parents: 7497
diff changeset
    72
de822cd3df3a fixwhitespace and dos2unix
koda
parents: 7497
diff changeset
    73
/**
de822cd3df3a fixwhitespace and dos2unix
koda
parents: 7497
diff changeset
    74
 * Free this schemelist and all contained schemes
de822cd3df3a fixwhitespace and dos2unix
koda
parents: 7497
diff changeset
    75
 */
de822cd3df3a fixwhitespace and dos2unix
koda
parents: 7497
diff changeset
    76
void flib_schemelist_destroy(flib_schemelist *list);
de822cd3df3a fixwhitespace and dos2unix
koda
parents: 7497
diff changeset
    77
de822cd3df3a fixwhitespace and dos2unix
koda
parents: 7497
diff changeset
    78
de822cd3df3a fixwhitespace and dos2unix
koda
parents: 7497
diff changeset
    79
#endif /* SCHEMELIST_H_ */