Implement generic Bitmap. Rework Bitmap128 to use Bitmap. Add Bitmap4096.

This commit is contained in:
Alfredo Cardigliano 2025-10-09 11:25:31 +02:00
parent 3c2b6a16f7
commit 44f34e7485
6 changed files with 216 additions and 173 deletions

42
src/Bitmap.cpp Normal file
View file

@ -0,0 +1,42 @@
/*
*
* (C) 2013-25 - ntop.org
*
*
* 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 3 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, write to the Free Software Foundation,
* Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
*
*/
#include "ntop_includes.h"
template <size_t N> void Bitmap<N>::lua(lua_State *vm, const char *label) const {
lua_newtable(vm);
for (u_int i = 0; i < numBits(); i++) {
if (isSetBit(i)) {
lua_pushboolean(vm, true); /* The boolean indicating this bit is set */
lua_pushinteger(vm, i); /* The integer bit id, used as key of this lua table */
lua_insert(vm, -2);
lua_settable(vm, -3);
}
}
lua_pushstring(vm, label);
lua_insert(vm, -2);
lua_settable(vm, -3);
}
template class Bitmap<2>; // Bitmap128
template class Bitmap<64>; // Bitmap4096