Advertisement
FatalSleep

Untitled

Jul 7th, 2014
204
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 14.10 KB | None | 0 0
  1. //Errors:
  2. 1>------ Build started: Project: ByteBuffer, Configuration: Release Win32 ------
  3. 1> ByteBuffer.cpp
  4. 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
  5. 1> c:\users\fatalsleep\documents\visual studio 2013\projects\bytebuffer\bytebuffer\UbyteStructure.h(18) : see declaration of 'UbyteBuffer::BufferCreate'
  6. 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
  7. 1> c:\users\fatalsleep\documents\visual studio 2013\projects\bytebuffer\bytebuffer\UbyteStructure.h(19) : see declaration of 'UbyteBuffer::BufferDelete'
  8. ========== Build: 0 succeeded, 1 failed, 0 up-to-date, 0 skipped ==========
  9.  
  10.  
  11. //Main CPP:
  12. #include <iostream>
  13. #include "UbyteStructure.h"
  14. //#define External extern "C++" _declspec( dllexport )
  15.  
  16. int main( void ) {
  17. uint64 Addr = ( uint64 ) UbyteBuffer::BufferCreate( 3 , 3 , 3 );
  18. UbyteBuffer::BufferDelete( Addr );
  19.  
  20. int xx = 0;
  21. std::cin >> xx;
  22. };
  23.  
  24. // Header:
  25. #pragma once
  26. #include "ByteTypes.h"
  27. #include <vector>
  28.  
  29. class UbyteBuffer {
  30. public:
  31.  
  32. static ubyte* ByteBuffer;
  33. static uint64 ByteAddress;
  34. static uint64 ByteBuffWidth;
  35. static uint64 ByteBuffHeight;
  36. static uint64 ByteBuffDepth;
  37. static std::vector<uint64> ByteMemory;
  38. static std::vector<uint64> ByteWidth;
  39. static std::vector<uint64> ByteHeight;
  40. static std::vector<uint64> ByteDepth;
  41.  
  42. static double UbyteBuffer :: BufferCreate( uint64 Width , uint64 Height , uint64 Depth );
  43. static double UbyteBuffer :: BufferDelete( uint64 Address );
  44.  
  45. static double BufferCreate( uint64 Width , uint64 Height , uint64 Depth ) {
  46. ubyte* Buffer = new ubyte[ Width , Height , Depth ];
  47. ByteMemory.push_back( ( uint64 ) Buffer );
  48. ByteWidth.push_back( Width );
  49. ByteHeight.push_back( Height );
  50. ByteDepth.push_back( Depth );
  51. return ( uint64 ) Buffer;
  52. };
  53.  
  54. static double BufferDelete( uint64 Address ) {
  55. for( uint32 b = 0; b < ByteMemory.size(); b ++ ) {
  56. if ( ByteMemory.at( b ) == Address ) {
  57. ByteMemory.erase( ByteMemory.begin() + b );
  58. ByteWidth.erase( ByteWidth.begin() + b );
  59. ByteHeight.erase( ByteHeight.begin() + b );
  60. ByteDepth.erase( ByteDepth.begin() + b );
  61. delete[] ( ( ubyte* ) Address );
  62.  
  63. if ( Address == ( uint64 ) ByteBuffer ) {
  64. ByteBuffer = nullptr;
  65. ByteAddress = 0;
  66. ByteBuffWidth = 0;
  67. ByteBuffHeight = 0;
  68. ByteBuffDepth = 0;
  69. return 2.0;
  70. };
  71.  
  72. return 1.0;
  73. };
  74. };
  75.  
  76. return 0.0;
  77. };
  78.  
  79. static double BufferExists( uint64 Address ) {
  80. for( uint32 b = 0; b < ByteMemory.size(); b ++ ) {
  81. if ( ByteMemory.at( b ) == Address ) {
  82. ByteMemory.erase( ByteMemory.begin() + b );
  83. return 1.0;
  84. };
  85. };
  86.  
  87. return 0.0;
  88. };
  89.  
  90. static double BufferTarget( uint64 Address ) {
  91. for( uint64 b = 0; b < ByteMemory.size(); b ++ ) {
  92. if ( ByteMemory.at( b ) == ByteAddress ) {
  93. ByteBuffWidth = ByteWidth.at( b );
  94. ByteBuffHeight = ByteHeight.at( b );
  95. ByteBuffDepth = ByteDepth.at( b );
  96. };
  97. };
  98.  
  99. ByteBuffer = ( ubyte* ) Address;
  100. ByteAddress = Address;
  101. return 0.0;
  102. };
  103.  
  104. static double BufferReset( void ) {
  105. ByteBuffer = nullptr;
  106. ByteAddress = 0;
  107. return 0.0;
  108. };
  109.  
  110. static double BufferAddress( void ) {
  111. return ByteAddress;
  112. };
  113.  
  114. static double BufferDeallocate( void ) {
  115. ByteBuffer = nullptr;
  116. ByteAddress = 0;
  117. ByteBuffWidth = 0;
  118. ByteBuffHeight = 0;
  119. ByteBuffDepth = 0;
  120. uint64 Address = 0;
  121.  
  122. if ( ByteMemory.empty() == false ) {
  123. for( uint32 b = 0; b < ByteMemory.size(); b ++ ) {
  124. Address = ByteMemory.at( b );
  125. delete[] ( ( ubyte* ) Address );
  126. };
  127. };
  128.  
  129. ByteMemory.erase( ByteMemory.begin() , ByteMemory.end() );
  130. ByteWidth.erase( ByteWidth.begin() , ByteWidth.end() );
  131. ByteHeight.erase( ByteHeight.begin() , ByteHeight.end() );
  132. ByteDepth.erase( ByteDepth.begin() , ByteDepth.end() );
  133. return 0.0;
  134. };
  135.  
  136. static double BufferCells( void ) {
  137. return ByteBuffWidth * ByteBuffHeight * ByteBuffDepth;
  138. };
  139.  
  140. static double BufferDimension( uint64 Dimension ) {
  141. switch( Dimension ) {
  142. case 1:
  143. return ByteBuffWidth;
  144. break;
  145. case 2:
  146. return ByteBuffHeight;
  147. break;
  148. case 3:
  149. return ByteBuffDepth;
  150. break;
  151. default:
  152. return -1;
  153. break;
  154. };
  155. };
  156.  
  157. static double BufferGet( uint64 Xpos , uint64 Ypos , uint64 Zpos ) {
  158. if ( Xpos < ByteBuffWidth && Ypos < ByteBuffHeight && Zpos < ByteBuffDepth ) {
  159. return ByteBuffer[ Xpos , Ypos , Zpos ];
  160. };
  161.  
  162. return -1.0;
  163. };
  164.  
  165. static double BufferSet( uint64 Xpos , uint64 Ypos , uint64 Zpos , ubyte Byte ) {
  166. if ( Xpos < ByteBuffWidth && Ypos < ByteBuffHeight && Zpos < ByteBuffDepth ) {
  167. ByteBuffer[ Xpos , Ypos , Zpos ] = Byte;
  168. return 0.0;
  169. };
  170.  
  171. return -1.0;
  172. };
  173.  
  174. static double BufferAdd( uint64 Xpos , uint64 Ypos , uint64 Zpos , ubyte Byte ) {
  175. if ( Xpos < ByteBuffWidth && Ypos < ByteBuffHeight && Zpos < ByteBuffDepth ) {
  176. ByteBuffer[ Xpos , Ypos , Zpos ] += Byte;
  177. return 0.0;
  178. };
  179.  
  180. return -1.0;
  181. };
  182.  
  183. static double BufferSubtract( uint64 Xpos , uint64 Ypos , uint64 Zpos , ubyte Byte ) {
  184. if ( Xpos < ByteBuffWidth && Ypos < ByteBuffHeight && Zpos < ByteBuffDepth ) {
  185. ByteBuffer[ Xpos , Ypos , Zpos ] -= Byte;
  186. return 0.0;
  187. };
  188.  
  189. return -1.0;
  190. };
  191.  
  192. static double BufferMultiply( uint64 Xpos , uint64 Ypos , uint64 Zpos , ubyte Byte ) {
  193. if ( Xpos < ByteBuffWidth && Ypos < ByteBuffHeight && Zpos < ByteBuffDepth ) {
  194. ByteBuffer[ Xpos , Ypos , Zpos ] *= Byte;
  195. return 0.0;
  196. };
  197.  
  198. return -1.0;
  199. };
  200.  
  201. static double BufferDivide( uint64 Xpos , uint64 Ypos , uint64 Zpos , ubyte Byte ) {
  202. if ( Xpos < ByteBuffWidth && Ypos < ByteBuffHeight && Zpos < ByteBuffDepth ) {
  203. ByteBuffer[ Xpos , Ypos , Zpos ] /= Byte;
  204. return 0.0;
  205. };
  206.  
  207. return -1.0;
  208. };
  209.  
  210. static double BufferModulo( uint64 Xpos , uint64 Ypos , uint64 Zpos , ubyte Byte ) {
  211. if ( Xpos < ByteBuffWidth && Ypos < ByteBuffHeight && Zpos < ByteBuffDepth ) {
  212. ByteBuffer[ Xpos , Ypos , Zpos ] %= Byte;
  213. return 0.0;
  214. };
  215.  
  216. return -1.0;
  217. };
  218.  
  219. static double BufferBitShift( uint64 Xpos , uint64 Ypos , uint64 Zpos , ubyte Byte , boolflag Shift ) {
  220. ubyte Value = ByteBuffer[ Xpos , Ypos , Zpos ];
  221.  
  222. if ( Shift == false ) {
  223. ByteBuffer[ Xpos , Ypos , Zpos ] = Value >> Byte;
  224. return 0.0;
  225. } else {
  226. ByteBuffer[ Xpos , Ypos , Zpos ] = Value << Byte;
  227. return 0.0;
  228. };
  229.  
  230. return -1.0;
  231. };
  232.  
  233. static double BufferBitAnd( uint64 Xpos , uint64 Ypos , uint64 Zpos , ubyte Byte ) {
  234. if ( Xpos < ByteBuffWidth && Ypos < ByteBuffHeight && Zpos < ByteBuffDepth ) {
  235. ByteBuffer[ Xpos , Ypos , Zpos ] &= Byte;
  236. return 0.0;
  237. };
  238.  
  239. return -1.0;
  240. };
  241.  
  242. static double BufferBitOr( uint64 Xpos , uint64 Ypos , uint64 Zpos , ubyte Byte ) {
  243. if ( Xpos < ByteBuffWidth && Ypos < ByteBuffHeight && Zpos < ByteBuffDepth ) {
  244. ByteBuffer[ Xpos , Ypos , Zpos ] |= Byte;
  245. return 0.0;
  246. };
  247.  
  248. return -1.0;
  249. };
  250.  
  251. static double BufferBitXor( uint64 Xpos , uint64 Ypos , uint64 Zpos , ubyte Byte ) {
  252. if ( Xpos < ByteBuffWidth && Ypos < ByteBuffHeight && Zpos < ByteBuffDepth ) {
  253. ByteBuffer[ Xpos , Ypos , Zpos ] ^= Byte;
  254. return 0.0;
  255. };
  256.  
  257. return -1.0;
  258. };
  259.  
  260. static double BufferAreaSet( uint64 Xpos , uint64 Ypos , uint64 Zpos , uint64 Width , uint64 Height , uint64 Depth , ubyte Byte ) {
  261. for( uint64 w = Xpos; w < Xpos + Width; w ++ ) {
  262. for( uint64 h = Ypos; w < Ypos + Height; h ++ ) {
  263. for( uint64 d = Zpos; w < Zpos + Depth; d ++ ) {
  264. if ( w < ByteBuffWidth && h < ByteBuffHeight && d < ByteBuffDepth ) {
  265. ByteBuffer[ w , h , d ] = Byte;
  266. };
  267. };
  268. };
  269. };
  270.  
  271. return 0.0;
  272. };
  273.  
  274. static double BufferAreaAdd( uint64 Xpos , uint64 Ypos , uint64 Zpos , uint64 Width , uint64 Height , uint64 Depth , ubyte Byte ) {
  275. for( uint64 w = Xpos; w < Xpos + Width; w ++ ) {
  276. for( uint64 h = Ypos; w < Ypos + Height; h ++ ) {
  277. for( uint64 d = Zpos; w < Zpos + Depth; d ++ ) {
  278. if ( w < ByteBuffWidth && h < ByteBuffHeight && d < ByteBuffDepth ) {
  279. ByteBuffer[ w , h , d ] += Byte;
  280. };
  281. };
  282. };
  283. };
  284.  
  285. return 0.0;
  286. };
  287.  
  288. static double BufferAreaSubtract( uint64 Xpos , uint64 Ypos , uint64 Zpos , uint64 Width , uint64 Height , uint64 Depth , ubyte Byte ) {
  289. for( uint64 w = Xpos; w < Xpos + Width; w ++ ) {
  290. for( uint64 h = Ypos; w < Ypos + Height; h ++ ) {
  291. for( uint64 d = Zpos; w < Zpos + Depth; d ++ ) {
  292. if ( w < ByteBuffWidth && h < ByteBuffHeight && d < ByteBuffDepth ) {
  293. ByteBuffer[ w , h , d ] -= Byte;
  294. };
  295. };
  296. };
  297. };
  298.  
  299. return 0.0;
  300. };
  301.  
  302. static double BufferAreaMultiply( uint64 Xpos , uint64 Ypos , uint64 Zpos , uint64 Width , uint64 Height , uint64 Depth , ubyte Byte ) {
  303. for( uint64 w = Xpos; w < Xpos + Width; w ++ ) {
  304. for( uint64 h = Ypos; w < Ypos + Height; h ++ ) {
  305. for( uint64 d = Zpos; w < Zpos + Depth; d ++ ) {
  306. if ( w < ByteBuffWidth && h < ByteBuffHeight && d < ByteBuffDepth ) {
  307. ByteBuffer[ w , h , d ] *= Byte;
  308. };
  309. };
  310. };
  311. };
  312.  
  313. return 0.0;
  314. };
  315.  
  316. static double BufferAreaDivide( uint64 Xpos , uint64 Ypos , uint64 Zpos , uint64 Width , uint64 Height , uint64 Depth , ubyte Byte ) {
  317. for( uint64 w = Xpos; w < Xpos + Width; w ++ ) {
  318. for( uint64 h = Ypos; w < Ypos + Height; h ++ ) {
  319. for( uint64 d = Zpos; w < Zpos + Depth; d ++ ) {
  320. if ( w < ByteBuffWidth && h < ByteBuffHeight && d < ByteBuffDepth ) {
  321. ByteBuffer[ w , h , d ] /= Byte;
  322. };
  323. };
  324. };
  325. };
  326.  
  327. return 0.0;
  328. };
  329.  
  330. static double BufferAreaModulo( uint64 Xpos , uint64 Ypos , uint64 Zpos , uint64 Width , uint64 Height , uint64 Depth , ubyte Byte ) {
  331. for( uint64 w = Xpos; w < Xpos + Width; w ++ ) {
  332. for( uint64 h = Ypos; w < Ypos + Height; h ++ ) {
  333. for( uint64 d = Zpos; w < Zpos + Depth; d ++ ) {
  334. if ( w < ByteBuffWidth && h < ByteBuffHeight && d < ByteBuffDepth ) {
  335. ByteBuffer[ w , h , d ] %= Byte;
  336. };
  337. };
  338. };
  339. };
  340.  
  341. return 0.0;
  342. };
  343.  
  344. static double BufferAreaBitshift( uint64 Xpos , uint64 Ypos , uint64 Zpos , uint64 Width , uint64 Height , uint64 Depth , ubyte Byte , boolflag Shift ) {
  345. ubyte Value = 0;
  346.  
  347. if ( Shift == false ) {
  348. for( uint64 w = Xpos; w < Xpos + Width; w ++ ) {
  349. for( uint64 h = Ypos; w < Ypos + Height; h ++ ) {
  350. for( uint64 d = Zpos; w < Zpos + Depth; d ++ ) {
  351. if ( w < ByteBuffWidth && h < ByteBuffHeight && d < ByteBuffDepth ) {
  352. Value = ByteBuffer[ w , h , d ];
  353. ByteBuffer[ w , h , d ] = Value >> Byte;
  354. };
  355. };
  356. };
  357. };
  358. } else {
  359. for( uint64 w = Xpos; w < Xpos + Width; w ++ ) {
  360. for( uint64 h = Ypos; w < Ypos + Height; h ++ ) {
  361. for( uint64 d = Zpos; w < Zpos + Depth; d ++ ) {
  362. if ( w < ByteBuffWidth && h < ByteBuffHeight && d < ByteBuffDepth ) {
  363. Value = ByteBuffer[ w , h , d ];
  364. ByteBuffer[ w , h , d ] = Value << Byte;
  365. };
  366. };
  367. };
  368. };
  369. };
  370.  
  371. return 0.0;
  372. };
  373.  
  374. static double BufferAreaBitAnd( uint64 Xpos , uint64 Ypos , uint64 Zpos , uint64 Width , uint64 Height , uint64 Depth , ubyte Byte ) {
  375. for( uint64 w = Xpos; w < Xpos + Width; w ++ ) {
  376. for( uint64 h = Ypos; w < Ypos + Height; h ++ ) {
  377. for( uint64 d = Zpos; w < Zpos + Depth; d ++ ) {
  378. if ( w < ByteBuffWidth && h < ByteBuffHeight && d < ByteBuffDepth ) {
  379. ByteBuffer[ w , h , d ] &= Byte;
  380. };
  381. };
  382. };
  383. };
  384.  
  385. return 0.0;
  386. };
  387.  
  388. static double BufferAreaBitOr( uint64 Xpos , uint64 Ypos , uint64 Zpos , uint64 Width , uint64 Height , uint64 Depth , ubyte Byte ) {
  389. for( uint64 w = Xpos; w < Xpos + Width; w ++ ) {
  390. for( uint64 h = Ypos; w < Ypos + Height; h ++ ) {
  391. for( uint64 d = Zpos; w < Zpos + Depth; d ++ ) {
  392. if ( w < ByteBuffWidth && h < ByteBuffHeight && d < ByteBuffDepth ) {
  393. ByteBuffer[ w , h , d ] |= Byte;
  394. };
  395. };
  396. };
  397. };
  398.  
  399. return 0.0;
  400. };
  401.  
  402. static double BufferAreaBitXor( uint64 Xpos , uint64 Ypos , uint64 Zpos , uint64 Width , uint64 Height , uint64 Depth , ubyte Byte ) {
  403. for( uint64 w = Xpos; w < Xpos + Width; w ++ ) {
  404. for( uint64 h = Ypos; w < Ypos + Height; h ++ ) {
  405. for( uint64 d = Zpos; w < Zpos + Depth; d ++ ) {
  406. if ( w < ByteBuffWidth && h < ByteBuffHeight && d < ByteBuffDepth ) {
  407. ByteBuffer[ w , h , d ] ^= Byte;
  408. };
  409. };
  410. };
  411. };
  412.  
  413. return 0.0;
  414. };
  415.  
  416. static double BufferAreaSum( uint64 Xpos , uint64 Ypos , uint64 Zpos , uint64 Width , uint64 Height , uint64 Depth , ubyte Byte ) {
  417. uint64 Sum = 0;
  418.  
  419. for( uint64 w = Xpos; w < Xpos + Width; w ++ ) {
  420. for( uint64 h = Ypos; w < Ypos + Height; h ++ ) {
  421. for( uint64 d = Zpos; w < Zpos + Depth; d ++ ) {
  422. if ( w < ByteBuffWidth && h < ByteBuffHeight && d < ByteBuffDepth ) {
  423. Sum += ByteBuffer[ w , h , d ];
  424. };
  425. };
  426. };
  427. };
  428.  
  429. return Sum;
  430. };
  431.  
  432. static double BufferAreaMin( uint64 Xpos , uint64 Ypos , uint64 Zpos , uint64 Width , uint64 Height , uint64 Depth , ubyte Byte ) {
  433. uint64 Min = 255;
  434.  
  435. for( uint64 w = Xpos; w < Xpos + Width; w ++ ) {
  436. for( uint64 h = Ypos; w < Ypos + Height; h ++ ) {
  437. for( uint64 d = Zpos; w < Zpos + Depth; d ++ ) {
  438. if ( ByteBuffer[ w , h , d ] < Min ) {
  439. if ( w < ByteBuffWidth && h < ByteBuffHeight && d < ByteBuffDepth ) {
  440. Min = ByteBuffer[ w , h , d ];
  441. };
  442. };
  443. };
  444. };
  445. };
  446.  
  447. return Min;
  448. };
  449.  
  450. static double BufferAreaMax( uint64 Xpos , uint64 Ypos , uint64 Zpos , uint64 Width , uint64 Height , uint64 Depth , ubyte Byte ) {
  451. uint64 Max = 0;
  452.  
  453. for( uint64 w = Xpos; w < Xpos + Width; w ++ ) {
  454. for( uint64 h = Ypos; w < Ypos + Height; h ++ ) {
  455. for( uint64 d = Zpos; w < Zpos + Depth; d ++ ) {
  456. if ( ByteBuffer[ w , h , d ] > Max ) {
  457. if ( w < ByteBuffWidth && h < ByteBuffHeight && d < ByteBuffDepth ) {
  458. Max = ByteBuffer[ w , h , d ];
  459. };
  460. };
  461. };
  462. };
  463. };
  464.  
  465. return Max;
  466. };
  467.  
  468. static double BufferAreaMean( uint64 Xpos , uint64 Ypos , uint64 Zpos , uint64 Width , uint64 Height , uint64 Depth , ubyte Byte ) {
  469. uint64 Mean = 0;
  470.  
  471. for( uint64 w = Xpos; w < Width; w ++ ) {
  472. for( uint64 h = Ypos; w < Height; h ++ ) {
  473. for( uint64 d = Zpos; w < Depth; d ++ ) {
  474. if ( ByteBuffer[ w , h , d ] < Mean ) {
  475. if ( w < ByteBuffWidth && h < ByteBuffHeight && d < ByteBuffDepth ) {
  476. Mean += ByteBuffer[ w , h , d ];
  477. };
  478. };
  479. };
  480. };
  481. };
  482.  
  483. return Mean / ( Width * Height * Depth );
  484. };
  485. };
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement