ntopng/src/Bitmap.cpp
2026-03-15 10:50:50 +01:00

44 lines
1.3 KiB
C++

/*
*
* (C) 2013-26 - 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