Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- //Errors:
- 1>------ Build started: Project: ByteBuffer, Configuration: Release Win32 ------
- 1> ByteBuffer.cpp
- 1>c:\users\fatalsleep\documents\visual studio 2013\projects\bytebuffer\bytebuffer\UbyteStructure.h(21): error C2535: 'double UbyteBuffer::BufferCreate(uint64,uint64,uint64)' : member function already defined or declared
- 1> c:\users\fatalsleep\documents\visual studio 2013\projects\bytebuffer\bytebuffer\UbyteStructure.h(18) : see declaration of 'UbyteBuffer::BufferCreate'
- 1>c:\users\fatalsleep\documents\visual studio 2013\projects\bytebuffer\bytebuffer\UbyteStructure.h(30): error C2535: 'double UbyteBuffer::BufferDelete(uint64)' : member function already defined or declared
- 1> c:\users\fatalsleep\documents\visual studio 2013\projects\bytebuffer\bytebuffer\UbyteStructure.h(19) : see declaration of 'UbyteBuffer::BufferDelete'
- ========== Build: 0 succeeded, 1 failed, 0 up-to-date, 0 skipped ==========
- //Main CPP:
- #include <iostream>
- #include "UbyteStructure.h"
- //#define External extern "C++" _declspec( dllexport )
- int main( void ) {
- uint64 Addr = ( uint64 ) UbyteBuffer::BufferCreate( 3 , 3 , 3 );
- UbyteBuffer::BufferDelete( Addr );
- int xx = 0;
- std::cin >> xx;
- };
- // Header:
- #pragma once
- #include "ByteTypes.h"
- #include <vector>
- class UbyteBuffer {
- public:
- static ubyte* ByteBuffer;
- static uint64 ByteAddress;
- static uint64 ByteBuffWidth;
- static uint64 ByteBuffHeight;
- static uint64 ByteBuffDepth;
- static std::vector<uint64> ByteMemory;
- static std::vector<uint64> ByteWidth;
- static std::vector<uint64> ByteHeight;
- static std::vector<uint64> ByteDepth;
- static double UbyteBuffer :: BufferCreate( uint64 Width , uint64 Height , uint64 Depth );
- static double UbyteBuffer :: BufferDelete( uint64 Address );
- static double BufferCreate( uint64 Width , uint64 Height , uint64 Depth ) {
- ubyte* Buffer = new ubyte[ Width , Height , Depth ];
- ByteMemory.push_back( ( uint64 ) Buffer );
- ByteWidth.push_back( Width );
- ByteHeight.push_back( Height );
- ByteDepth.push_back( Depth );
- return ( uint64 ) Buffer;
- };
- static double BufferDelete( uint64 Address ) {
- for( uint32 b = 0; b < ByteMemory.size(); b ++ ) {
- if ( ByteMemory.at( b ) == Address ) {
- ByteMemory.erase( ByteMemory.begin() + b );
- ByteWidth.erase( ByteWidth.begin() + b );
- ByteHeight.erase( ByteHeight.begin() + b );
- ByteDepth.erase( ByteDepth.begin() + b );
- delete[] ( ( ubyte* ) Address );
- if ( Address == ( uint64 ) ByteBuffer ) {
- ByteBuffer = nullptr;
- ByteAddress = 0;
- ByteBuffWidth = 0;
- ByteBuffHeight = 0;
- ByteBuffDepth = 0;
- return 2.0;
- };
- return 1.0;
- };
- };
- return 0.0;
- };
- static double BufferExists( uint64 Address ) {
- for( uint32 b = 0; b < ByteMemory.size(); b ++ ) {
- if ( ByteMemory.at( b ) == Address ) {
- ByteMemory.erase( ByteMemory.begin() + b );
- return 1.0;
- };
- };
- return 0.0;
- };
- static double BufferTarget( uint64 Address ) {
- for( uint64 b = 0; b < ByteMemory.size(); b ++ ) {
- if ( ByteMemory.at( b ) == ByteAddress ) {
- ByteBuffWidth = ByteWidth.at( b );
- ByteBuffHeight = ByteHeight.at( b );
- ByteBuffDepth = ByteDepth.at( b );
- };
- };
- ByteBuffer = ( ubyte* ) Address;
- ByteAddress = Address;
- return 0.0;
- };
- static double BufferReset( void ) {
- ByteBuffer = nullptr;
- ByteAddress = 0;
- return 0.0;
- };
- static double BufferAddress( void ) {
- return ByteAddress;
- };
- static double BufferDeallocate( void ) {
- ByteBuffer = nullptr;
- ByteAddress = 0;
- ByteBuffWidth = 0;
- ByteBuffHeight = 0;
- ByteBuffDepth = 0;
- uint64 Address = 0;
- if ( ByteMemory.empty() == false ) {
- for( uint32 b = 0; b < ByteMemory.size(); b ++ ) {
- Address = ByteMemory.at( b );
- delete[] ( ( ubyte* ) Address );
- };
- };
- ByteMemory.erase( ByteMemory.begin() , ByteMemory.end() );
- ByteWidth.erase( ByteWidth.begin() , ByteWidth.end() );
- ByteHeight.erase( ByteHeight.begin() , ByteHeight.end() );
- ByteDepth.erase( ByteDepth.begin() , ByteDepth.end() );
- return 0.0;
- };
- static double BufferCells( void ) {
- return ByteBuffWidth * ByteBuffHeight * ByteBuffDepth;
- };
- static double BufferDimension( uint64 Dimension ) {
- switch( Dimension ) {
- case 1:
- return ByteBuffWidth;
- break;
- case 2:
- return ByteBuffHeight;
- break;
- case 3:
- return ByteBuffDepth;
- break;
- default:
- return -1;
- break;
- };
- };
- static double BufferGet( uint64 Xpos , uint64 Ypos , uint64 Zpos ) {
- if ( Xpos < ByteBuffWidth && Ypos < ByteBuffHeight && Zpos < ByteBuffDepth ) {
- return ByteBuffer[ Xpos , Ypos , Zpos ];
- };
- return -1.0;
- };
- static double BufferSet( uint64 Xpos , uint64 Ypos , uint64 Zpos , ubyte Byte ) {
- if ( Xpos < ByteBuffWidth && Ypos < ByteBuffHeight && Zpos < ByteBuffDepth ) {
- ByteBuffer[ Xpos , Ypos , Zpos ] = Byte;
- return 0.0;
- };
- return -1.0;
- };
- static double BufferAdd( uint64 Xpos , uint64 Ypos , uint64 Zpos , ubyte Byte ) {
- if ( Xpos < ByteBuffWidth && Ypos < ByteBuffHeight && Zpos < ByteBuffDepth ) {
- ByteBuffer[ Xpos , Ypos , Zpos ] += Byte;
- return 0.0;
- };
- return -1.0;
- };
- static double BufferSubtract( uint64 Xpos , uint64 Ypos , uint64 Zpos , ubyte Byte ) {
- if ( Xpos < ByteBuffWidth && Ypos < ByteBuffHeight && Zpos < ByteBuffDepth ) {
- ByteBuffer[ Xpos , Ypos , Zpos ] -= Byte;
- return 0.0;
- };
- return -1.0;
- };
- static double BufferMultiply( uint64 Xpos , uint64 Ypos , uint64 Zpos , ubyte Byte ) {
- if ( Xpos < ByteBuffWidth && Ypos < ByteBuffHeight && Zpos < ByteBuffDepth ) {
- ByteBuffer[ Xpos , Ypos , Zpos ] *= Byte;
- return 0.0;
- };
- return -1.0;
- };
- static double BufferDivide( uint64 Xpos , uint64 Ypos , uint64 Zpos , ubyte Byte ) {
- if ( Xpos < ByteBuffWidth && Ypos < ByteBuffHeight && Zpos < ByteBuffDepth ) {
- ByteBuffer[ Xpos , Ypos , Zpos ] /= Byte;
- return 0.0;
- };
- return -1.0;
- };
- static double BufferModulo( uint64 Xpos , uint64 Ypos , uint64 Zpos , ubyte Byte ) {
- if ( Xpos < ByteBuffWidth && Ypos < ByteBuffHeight && Zpos < ByteBuffDepth ) {
- ByteBuffer[ Xpos , Ypos , Zpos ] %= Byte;
- return 0.0;
- };
- return -1.0;
- };
- static double BufferBitShift( uint64 Xpos , uint64 Ypos , uint64 Zpos , ubyte Byte , boolflag Shift ) {
- ubyte Value = ByteBuffer[ Xpos , Ypos , Zpos ];
- if ( Shift == false ) {
- ByteBuffer[ Xpos , Ypos , Zpos ] = Value >> Byte;
- return 0.0;
- } else {
- ByteBuffer[ Xpos , Ypos , Zpos ] = Value << Byte;
- return 0.0;
- };
- return -1.0;
- };
- static double BufferBitAnd( uint64 Xpos , uint64 Ypos , uint64 Zpos , ubyte Byte ) {
- if ( Xpos < ByteBuffWidth && Ypos < ByteBuffHeight && Zpos < ByteBuffDepth ) {
- ByteBuffer[ Xpos , Ypos , Zpos ] &= Byte;
- return 0.0;
- };
- return -1.0;
- };
- static double BufferBitOr( uint64 Xpos , uint64 Ypos , uint64 Zpos , ubyte Byte ) {
- if ( Xpos < ByteBuffWidth && Ypos < ByteBuffHeight && Zpos < ByteBuffDepth ) {
- ByteBuffer[ Xpos , Ypos , Zpos ] |= Byte;
- return 0.0;
- };
- return -1.0;
- };
- static double BufferBitXor( uint64 Xpos , uint64 Ypos , uint64 Zpos , ubyte Byte ) {
- if ( Xpos < ByteBuffWidth && Ypos < ByteBuffHeight && Zpos < ByteBuffDepth ) {
- ByteBuffer[ Xpos , Ypos , Zpos ] ^= Byte;
- return 0.0;
- };
- return -1.0;
- };
- static double BufferAreaSet( uint64 Xpos , uint64 Ypos , uint64 Zpos , uint64 Width , uint64 Height , uint64 Depth , ubyte Byte ) {
- for( uint64 w = Xpos; w < Xpos + Width; w ++ ) {
- for( uint64 h = Ypos; w < Ypos + Height; h ++ ) {
- for( uint64 d = Zpos; w < Zpos + Depth; d ++ ) {
- if ( w < ByteBuffWidth && h < ByteBuffHeight && d < ByteBuffDepth ) {
- ByteBuffer[ w , h , d ] = Byte;
- };
- };
- };
- };
- return 0.0;
- };
- static double BufferAreaAdd( uint64 Xpos , uint64 Ypos , uint64 Zpos , uint64 Width , uint64 Height , uint64 Depth , ubyte Byte ) {
- for( uint64 w = Xpos; w < Xpos + Width; w ++ ) {
- for( uint64 h = Ypos; w < Ypos + Height; h ++ ) {
- for( uint64 d = Zpos; w < Zpos + Depth; d ++ ) {
- if ( w < ByteBuffWidth && h < ByteBuffHeight && d < ByteBuffDepth ) {
- ByteBuffer[ w , h , d ] += Byte;
- };
- };
- };
- };
- return 0.0;
- };
- static double BufferAreaSubtract( uint64 Xpos , uint64 Ypos , uint64 Zpos , uint64 Width , uint64 Height , uint64 Depth , ubyte Byte ) {
- for( uint64 w = Xpos; w < Xpos + Width; w ++ ) {
- for( uint64 h = Ypos; w < Ypos + Height; h ++ ) {
- for( uint64 d = Zpos; w < Zpos + Depth; d ++ ) {
- if ( w < ByteBuffWidth && h < ByteBuffHeight && d < ByteBuffDepth ) {
- ByteBuffer[ w , h , d ] -= Byte;
- };
- };
- };
- };
- return 0.0;
- };
- static double BufferAreaMultiply( uint64 Xpos , uint64 Ypos , uint64 Zpos , uint64 Width , uint64 Height , uint64 Depth , ubyte Byte ) {
- for( uint64 w = Xpos; w < Xpos + Width; w ++ ) {
- for( uint64 h = Ypos; w < Ypos + Height; h ++ ) {
- for( uint64 d = Zpos; w < Zpos + Depth; d ++ ) {
- if ( w < ByteBuffWidth && h < ByteBuffHeight && d < ByteBuffDepth ) {
- ByteBuffer[ w , h , d ] *= Byte;
- };
- };
- };
- };
- return 0.0;
- };
- static double BufferAreaDivide( uint64 Xpos , uint64 Ypos , uint64 Zpos , uint64 Width , uint64 Height , uint64 Depth , ubyte Byte ) {
- for( uint64 w = Xpos; w < Xpos + Width; w ++ ) {
- for( uint64 h = Ypos; w < Ypos + Height; h ++ ) {
- for( uint64 d = Zpos; w < Zpos + Depth; d ++ ) {
- if ( w < ByteBuffWidth && h < ByteBuffHeight && d < ByteBuffDepth ) {
- ByteBuffer[ w , h , d ] /= Byte;
- };
- };
- };
- };
- return 0.0;
- };
- static double BufferAreaModulo( uint64 Xpos , uint64 Ypos , uint64 Zpos , uint64 Width , uint64 Height , uint64 Depth , ubyte Byte ) {
- for( uint64 w = Xpos; w < Xpos + Width; w ++ ) {
- for( uint64 h = Ypos; w < Ypos + Height; h ++ ) {
- for( uint64 d = Zpos; w < Zpos + Depth; d ++ ) {
- if ( w < ByteBuffWidth && h < ByteBuffHeight && d < ByteBuffDepth ) {
- ByteBuffer[ w , h , d ] %= Byte;
- };
- };
- };
- };
- return 0.0;
- };
- static double BufferAreaBitshift( uint64 Xpos , uint64 Ypos , uint64 Zpos , uint64 Width , uint64 Height , uint64 Depth , ubyte Byte , boolflag Shift ) {
- ubyte Value = 0;
- if ( Shift == false ) {
- for( uint64 w = Xpos; w < Xpos + Width; w ++ ) {
- for( uint64 h = Ypos; w < Ypos + Height; h ++ ) {
- for( uint64 d = Zpos; w < Zpos + Depth; d ++ ) {
- if ( w < ByteBuffWidth && h < ByteBuffHeight && d < ByteBuffDepth ) {
- Value = ByteBuffer[ w , h , d ];
- ByteBuffer[ w , h , d ] = Value >> Byte;
- };
- };
- };
- };
- } else {
- for( uint64 w = Xpos; w < Xpos + Width; w ++ ) {
- for( uint64 h = Ypos; w < Ypos + Height; h ++ ) {
- for( uint64 d = Zpos; w < Zpos + Depth; d ++ ) {
- if ( w < ByteBuffWidth && h < ByteBuffHeight && d < ByteBuffDepth ) {
- Value = ByteBuffer[ w , h , d ];
- ByteBuffer[ w , h , d ] = Value << Byte;
- };
- };
- };
- };
- };
- return 0.0;
- };
- static double BufferAreaBitAnd( uint64 Xpos , uint64 Ypos , uint64 Zpos , uint64 Width , uint64 Height , uint64 Depth , ubyte Byte ) {
- for( uint64 w = Xpos; w < Xpos + Width; w ++ ) {
- for( uint64 h = Ypos; w < Ypos + Height; h ++ ) {
- for( uint64 d = Zpos; w < Zpos + Depth; d ++ ) {
- if ( w < ByteBuffWidth && h < ByteBuffHeight && d < ByteBuffDepth ) {
- ByteBuffer[ w , h , d ] &= Byte;
- };
- };
- };
- };
- return 0.0;
- };
- static double BufferAreaBitOr( uint64 Xpos , uint64 Ypos , uint64 Zpos , uint64 Width , uint64 Height , uint64 Depth , ubyte Byte ) {
- for( uint64 w = Xpos; w < Xpos + Width; w ++ ) {
- for( uint64 h = Ypos; w < Ypos + Height; h ++ ) {
- for( uint64 d = Zpos; w < Zpos + Depth; d ++ ) {
- if ( w < ByteBuffWidth && h < ByteBuffHeight && d < ByteBuffDepth ) {
- ByteBuffer[ w , h , d ] |= Byte;
- };
- };
- };
- };
- return 0.0;
- };
- static double BufferAreaBitXor( uint64 Xpos , uint64 Ypos , uint64 Zpos , uint64 Width , uint64 Height , uint64 Depth , ubyte Byte ) {
- for( uint64 w = Xpos; w < Xpos + Width; w ++ ) {
- for( uint64 h = Ypos; w < Ypos + Height; h ++ ) {
- for( uint64 d = Zpos; w < Zpos + Depth; d ++ ) {
- if ( w < ByteBuffWidth && h < ByteBuffHeight && d < ByteBuffDepth ) {
- ByteBuffer[ w , h , d ] ^= Byte;
- };
- };
- };
- };
- return 0.0;
- };
- static double BufferAreaSum( uint64 Xpos , uint64 Ypos , uint64 Zpos , uint64 Width , uint64 Height , uint64 Depth , ubyte Byte ) {
- uint64 Sum = 0;
- for( uint64 w = Xpos; w < Xpos + Width; w ++ ) {
- for( uint64 h = Ypos; w < Ypos + Height; h ++ ) {
- for( uint64 d = Zpos; w < Zpos + Depth; d ++ ) {
- if ( w < ByteBuffWidth && h < ByteBuffHeight && d < ByteBuffDepth ) {
- Sum += ByteBuffer[ w , h , d ];
- };
- };
- };
- };
- return Sum;
- };
- static double BufferAreaMin( uint64 Xpos , uint64 Ypos , uint64 Zpos , uint64 Width , uint64 Height , uint64 Depth , ubyte Byte ) {
- uint64 Min = 255;
- for( uint64 w = Xpos; w < Xpos + Width; w ++ ) {
- for( uint64 h = Ypos; w < Ypos + Height; h ++ ) {
- for( uint64 d = Zpos; w < Zpos + Depth; d ++ ) {
- if ( ByteBuffer[ w , h , d ] < Min ) {
- if ( w < ByteBuffWidth && h < ByteBuffHeight && d < ByteBuffDepth ) {
- Min = ByteBuffer[ w , h , d ];
- };
- };
- };
- };
- };
- return Min;
- };
- static double BufferAreaMax( uint64 Xpos , uint64 Ypos , uint64 Zpos , uint64 Width , uint64 Height , uint64 Depth , ubyte Byte ) {
- uint64 Max = 0;
- for( uint64 w = Xpos; w < Xpos + Width; w ++ ) {
- for( uint64 h = Ypos; w < Ypos + Height; h ++ ) {
- for( uint64 d = Zpos; w < Zpos + Depth; d ++ ) {
- if ( ByteBuffer[ w , h , d ] > Max ) {
- if ( w < ByteBuffWidth && h < ByteBuffHeight && d < ByteBuffDepth ) {
- Max = ByteBuffer[ w , h , d ];
- };
- };
- };
- };
- };
- return Max;
- };
- static double BufferAreaMean( uint64 Xpos , uint64 Ypos , uint64 Zpos , uint64 Width , uint64 Height , uint64 Depth , ubyte Byte ) {
- uint64 Mean = 0;
- for( uint64 w = Xpos; w < Width; w ++ ) {
- for( uint64 h = Ypos; w < Height; h ++ ) {
- for( uint64 d = Zpos; w < Depth; d ++ ) {
- if ( ByteBuffer[ w , h , d ] < Mean ) {
- if ( w < ByteBuffWidth && h < ByteBuffHeight && d < ByteBuffDepth ) {
- Mean += ByteBuffer[ w , h , d ];
- };
- };
- };
- };
- };
- return Mean / ( Width * Height * Depth );
- };
- };
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement