From 41d8341547178384b9c109907a38efb0edccc525 Mon Sep 17 00:00:00 2001 From: Artem Pavlenko Date: Wed, 15 Jun 2005 22:17:12 +0000 Subject: [PATCH] some useful macros --- include/global.hpp | 57 ++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 57 insertions(+) create mode 100644 include/global.hpp diff --git a/include/global.hpp b/include/global.hpp new file mode 100644 index 000000000..b2b479c14 --- /dev/null +++ b/include/global.hpp @@ -0,0 +1,57 @@ +/* This file is part of Mapnik (c++ mapping toolkit) + * Copyright (C) 2005 Artem Pavlenko + * + * Mapnik 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 2 + * of the License, or 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. + */ + +//$Id$ + +#ifndef GLOBAL_HPP +#define GLOBAL_HPP + +#include + +namespace mapnik +{ + using namespace boost; +#define int2net(A) (int32_t) (((uint32_t) ((uint8_t) (A)[1])) |\ + (((uint32_t) ((uint8_t) (A)[0])) << 8)) + +#define int4net(A) (int32_t) (((uint32_t) ((uint8_t) (A)[3])) |\ + (((uint32_t) ((uint8_t) (A)[2])) << 8) |\ + (((uint32_t) ((uint8_t) (A)[1])) << 16) |\ + (((uint32_t) ((uint8_t) (A)[0])) << 24)) + + + typedef char byte; +#define float8net(V,M) do { double def_temp;\ + ((byte*) &def_temp)[0]=(M)[7];\ + ((byte*) &def_temp)[1]=(M)[6];\ + ((byte*) &def_temp)[2]=(M)[5];\ + ((byte*) &def_temp)[3]=(M)[4];\ + ((byte*) &def_temp)[4]=(M)[3];\ + ((byte*) &def_temp)[5]=(M)[2];\ + ((byte*) &def_temp)[6]=(M)[1];\ + ((byte*) &def_temp)[7]=(M)[0];\ + (V) = def_temp; } while(0) +#define float4net(V,M) do { float def_temp;\ + ((byte*) &def_temp)[0]=(M)[3];\ + ((byte*) &def_temp)[1]=(M)[2];\ + ((byte*) &def_temp)[2]=(M)[1];\ + ((byte*) &def_temp)[3]=(M)[0];\ + (V)=def_temp; } while(0) +} + +#endif //GLOBAL_HPP