libroot/posix/stdio: Remove unused portions.
[haiku.git] / src / preferences / shortcuts / MetaKeyStateMap.cpp
blobfa23f836ec300b27686773cd81c2e1d2ce3115b6
1 /*
2 * Copyright 1999-2009 Jeremy Friesner
3 * Copyright 2009 Haiku, Inc. All rights reserved.
4 * Distributed under the terms of the MIT License.
6 * Authors:
7 * Jeremy Friesner
8 */
11 #include "MetaKeyStateMap.h"
14 #include <stdio.h>
15 #include <string.h>
18 #include "BitFieldTesters.h"
21 MetaKeyStateMap::MetaKeyStateMap()
23 fKeyName(NULL)
25 // User MUST call SetInfo() before using!
29 MetaKeyStateMap::MetaKeyStateMap(const char* name)
31 SetInfo(name);
35 void
36 MetaKeyStateMap::SetInfo(const char* keyName)
38 fKeyName = new char[strlen(keyName) + 1];
39 strcpy(fKeyName, keyName);
43 MetaKeyStateMap::~MetaKeyStateMap()
45 delete [] fKeyName;
46 int nr = fStateDescs.CountItems();
47 for (int i = 0; i < nr; i++)
48 delete [] ((const char*) fStateDescs.ItemAt(i));
50 nr = fStateTesters.CountItems();
51 for (int j = 0; j < nr; j++)
52 delete ((BitFieldTester*) fStateTesters.ItemAt(j));
53 // _stateBits are stored in-line, no need to delete them
57 void
58 MetaKeyStateMap::AddState(const char* d, const BitFieldTester* t)
60 char* copy = new char[strlen(d) + 1];
61 strcpy(copy, d);
62 fStateDescs.AddItem(copy);
63 fStateTesters.AddItem((void *)t);
67 int
68 MetaKeyStateMap::GetNumStates() const
70 return fStateTesters.CountItems();
74 const BitFieldTester*
75 MetaKeyStateMap::GetNthStateTester(int stateNum) const
77 return ((const BitFieldTester*) fStateTesters.ItemAt(stateNum));
81 const char*
82 MetaKeyStateMap::GetNthStateDesc(int stateNum) const
84 return ((const char*) fStateDescs.ItemAt(stateNum));
88 const char*
89 MetaKeyStateMap::GetName() const
91 return fKeyName;