2011-10-16 23:33:45 +02:00
|
|
|
/*
|
|
|
|
* This file is a part of Winix
|
|
|
|
* and is not publicly distributed
|
|
|
|
*
|
2012-01-12 03:24:08 +01:00
|
|
|
* Copyright (c) 2011-2012, Tomasz Sowa
|
2011-10-16 23:33:45 +02:00
|
|
|
* All rights reserved.
|
|
|
|
*
|
|
|
|
*/
|
|
|
|
|
|
|
|
#ifndef headerfile_winix_plugins_groupitem_groups
|
|
|
|
#define headerfile_winix_plugins_groupitem_groups
|
|
|
|
|
|
|
|
#include <map>
|
|
|
|
#include <vector>
|
|
|
|
#include <string>
|
2012-05-01 00:53:54 +02:00
|
|
|
#include "space/spaceparser.h"
|
2011-10-16 23:33:45 +02:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
namespace GroupItem
|
|
|
|
{
|
|
|
|
|
|
|
|
|
|
|
|
class Groups
|
|
|
|
{
|
|
|
|
public:
|
|
|
|
|
|
|
|
/*
|
|
|
|
reading all space
|
|
|
|
(sets and groups)
|
|
|
|
*/
|
2012-01-12 03:24:08 +01:00
|
|
|
PT::Space * GetSpace();
|
2011-10-16 23:33:45 +02:00
|
|
|
|
|
|
|
|
|
|
|
/*
|
|
|
|
building all indexes
|
|
|
|
*/
|
|
|
|
void Reindex();
|
|
|
|
|
|
|
|
|
|
|
|
bool Find(const std::wstring & set, const std::wstring & value, size_t & seti, size_t & groupi);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/*
|
|
|
|
*/
|
|
|
|
size_t Size(size_t seti, size_t groupi);
|
|
|
|
|
|
|
|
const std::wstring & GetOption(size_t seti, size_t groupi, size_t valuei, const wchar_t * option);
|
|
|
|
const std::wstring & GetOption(size_t seti, size_t groupi, size_t valuei, const std::wstring & option);
|
|
|
|
|
|
|
|
|
|
|
|
/*
|
|
|
|
removing all groups
|
|
|
|
*/
|
|
|
|
void Clear();
|
|
|
|
|
|
|
|
|
|
|
|
private:
|
|
|
|
|
|
|
|
/*
|
|
|
|
our space:
|
|
|
|
set1 (
|
|
|
|
|
|
|
|
# group1
|
|
|
|
(
|
|
|
|
( value = "value1"
|
|
|
|
other = "foo" )
|
|
|
|
|
|
|
|
( value = "something"
|
|
|
|
other = "x" )
|
|
|
|
)
|
|
|
|
|
|
|
|
# group2
|
|
|
|
(
|
|
|
|
|
|
|
|
)
|
|
|
|
|
|
|
|
) # end of set1
|
|
|
|
|
|
|
|
# we can have more sets
|
|
|
|
# sets should have a unique name
|
|
|
|
# groups don't have a name
|
|
|
|
*/
|
2012-01-12 03:24:08 +01:00
|
|
|
PT::Space space;
|
2011-10-16 23:33:45 +02:00
|
|
|
|
|
|
|
|
|
|
|
/*
|
|
|
|
indexes to a set of groups
|
|
|
|
*/
|
|
|
|
typedef std::map<std::wstring, size_t> SetIndex;
|
|
|
|
SetIndex set_index;
|
|
|
|
|
|
|
|
/*
|
|
|
|
indexes to a groups in a set
|
|
|
|
mapping: value->group index
|
|
|
|
*/
|
|
|
|
typedef std::map<std::wstring, size_t> GroupIndex;
|
|
|
|
|
|
|
|
/*
|
|
|
|
group indexes in a specified set
|
|
|
|
std::vector<how many sets there are>
|
|
|
|
*/
|
|
|
|
std::vector<GroupIndex> group_index_tab;
|
|
|
|
|
|
|
|
const std::wstring empty_str;
|
|
|
|
|
|
|
|
|
|
|
|
std::wstring sort_by;
|
|
|
|
bool sort_asc;
|
2012-01-12 03:24:08 +01:00
|
|
|
PT::Space::Value sort_value;
|
2011-10-16 23:33:45 +02:00
|
|
|
|
|
|
|
struct SortFunHelper
|
|
|
|
{
|
|
|
|
Groups * groups;
|
|
|
|
SortFunHelper(Groups * pgroups) : groups(pgroups) {};
|
|
|
|
size_t SortValue(const std::wstring & val);
|
2012-01-12 03:24:08 +01:00
|
|
|
bool operator()(PT::Space * sp1, PT::Space * sp2);
|
2011-10-16 23:33:45 +02:00
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
|
2012-01-12 03:24:08 +01:00
|
|
|
void ReindexGroups(GroupIndex & group_index, PT::Space & set);
|
|
|
|
void SortValues(PT::Space & group);
|
2011-10-16 23:33:45 +02:00
|
|
|
};
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
#endif
|
|
|
|
|