├── .gitignore ├── ABitmapClass ├── .cproject ├── .project ├── CMakeLists.txt └── src │ ├── Bitmap.cpp │ ├── Bitmap.h │ ├── BitmapFileHeader.h │ ├── BitmapInfoHeader.h │ └── main.cpp ├── AComplexNumberClass ├── .cproject ├── .project ├── CMakeLists.txt └── src │ ├── AComplexNumberClass.cpp │ ├── Complex.cpp │ └── Complex.h ├── AMandelbrotClass ├── .cproject ├── .project ├── CMakeLists.txt └── src │ ├── Bitmap.cpp │ ├── Bitmap.h │ ├── BitmapFileHeader.h │ ├── BitmapInfoHeader.h │ ├── Mandelbrot.cpp │ ├── Mandelbrot.h │ └── main.cpp ├── AZoomClass ├── .cproject ├── .project ├── CMakeLists.txt └── src │ ├── Bitmap.cpp │ ├── Bitmap.h │ ├── BitmapFileHeader.h │ ├── BitmapInfoHeader.h │ ├── Mandelbrot.cpp │ ├── Mandelbrot.h │ ├── Zoom.h │ └── main.cpp ├── AbstractClasses ├── .cproject ├── .project ├── CMakeLists.txt └── src │ └── AbstractClasses.cpp ├── AnRGBClass ├── .cproject ├── .project ├── CMakeLists.txt └── src │ ├── Bitmap.cpp │ ├── Bitmap.h │ ├── BitmapFileHeader.h │ ├── BitmapInfoHeader.h │ ├── FractalCreator.cpp │ ├── FractalCreator.h │ ├── Mandelbrot.cpp │ ├── Mandelbrot.h │ ├── RGB.cpp │ ├── RGB.h │ ├── Zoom.h │ ├── ZoomList.cpp │ ├── ZoomList.h │ └── main.cpp ├── ApplyingtheZoom ├── .cproject ├── .project ├── CMakeLists.txt └── src │ ├── Bitmap.cpp │ ├── Bitmap.h │ ├── BitmapFileHeader.h │ ├── BitmapInfoHeader.h │ ├── Mandelbrot.cpp │ ├── Mandelbrot.h │ ├── Zoom.h │ ├── ZoomList.cpp │ ├── ZoomList.h │ └── main.cpp ├── AutoPointers ├── .cproject ├── .project ├── CMakeLists.txt └── src │ ├── AutoPointers.cpp │ └── temp.cpp ├── BasicExceptions ├── .cproject ├── .project ├── CMakeLists.txt └── src │ └── BasicExceptions.cpp ├── BinaryFiles ├── .cproject ├── .project ├── CMakeLists.txt ├── src │ └── BinaryFiles.cpp └── test.bin ├── Bind ├── .cproject ├── .project ├── CMakeLists.txt └── src │ └── Bind.cpp ├── BitmapFileHeaders ├── .cproject ├── .project ├── CMakeLists.txt └── src │ ├── BitmapFileHeader.h │ └── FractalCreatorHelloWorld.cpp ├── BitmapHeaderValues ├── .cproject ├── .project ├── CMakeLists.txt └── src │ ├── Bitmap.cpp │ ├── Bitmap.h │ ├── BitmapFileHeader.h │ ├── BitmapInfoHeader.h │ └── main.cpp ├── BitmapInfoHeaders ├── .cproject ├── .project ├── CMakeLists.txt └── src │ ├── BitmapInfoHeader.h │ └── FractalCreatorHelloWorld.cpp ├── BitmapMemory ├── .cproject ├── .project ├── CMakeLists.txt └── src │ ├── Bitmap.cpp │ ├── Bitmap.h │ ├── BitmapFileHeader.h │ ├── BitmapInfoHeader.h │ └── main.cpp ├── CalculatingRangeTotals ├── .cproject ├── .project ├── CMakeLists.txt └── src │ ├── Bitmap.cpp │ ├── Bitmap.h │ ├── BitmapFileHeader.h │ ├── BitmapInfoHeader.h │ ├── FractalCreator.cpp │ ├── FractalCreator.h │ ├── Mandelbrot.cpp │ ├── Mandelbrot.h │ ├── RGB.cpp │ ├── RGB.h │ ├── Zoom.h │ ├── ZoomList.cpp │ ├── ZoomList.h │ └── main.cpp ├── CapturingThisWithLambdas ├── .cproject ├── .project ├── CMakeLists.txt └── src │ └── main.cpp ├── CatchingSubclassExceptions ├── .cproject ├── .project ├── CMakeLists.txt └── src │ └── CatchingSubclassExceptions.cpp ├── CenteringandScaling ├── .cproject ├── .project ├── CMakeLists.txt └── src │ ├── Bitmap.cpp │ ├── Bitmap.h │ ├── BitmapFileHeader.h │ ├── BitmapInfoHeader.h │ ├── Mandelbrot.cpp │ ├── Mandelbrot.h │ ├── Zoom.h │ ├── ZoomList.cpp │ ├── ZoomList.h │ └── main.cpp ├── CheckingtheRangeTotals ├── .cproject ├── .project ├── CMakeLists.txt └── src │ ├── Bitmap.cpp │ ├── Bitmap.h │ ├── BitmapFileHeader.h │ ├── BitmapInfoHeader.h │ ├── FractalCreator.cpp │ ├── FractalCreator.h │ ├── Mandelbrot.cpp │ ├── Mandelbrot.h │ ├── RGB.cpp │ ├── RGB.h │ ├── Zoom.h │ ├── ZoomList.cpp │ ├── ZoomList.h │ └── main.cpp ├── ColorTransforms ├── .cproject ├── .project ├── CMakeLists.txt └── src │ ├── Bitmap.cpp │ ├── Bitmap.h │ ├── BitmapFileHeader.h │ ├── BitmapInfoHeader.h │ ├── Mandelbrot.cpp │ ├── Mandelbrot.h │ └── main.cpp ├── ColourHistograms ├── .cproject ├── .project ├── CMakeLists.txt └── src │ ├── Bitmap.cpp │ ├── Bitmap.h │ ├── BitmapFileHeader.h │ ├── BitmapInfoHeader.h │ ├── Mandelbrot.cpp │ ├── Mandelbrot.h │ └── main.cpp ├── Complex Numbers Overview.pdf ├── ConstructorsandMemory ├── .cproject ├── .project ├── CMakeLists.txt └── src │ └── ElisionAndOptimization.cpp ├── CustomExceptions ├── .cproject ├── .project ├── CMakeLists.txt └── src │ └── CustomExceptions.cpp ├── CustomObjectsAsMapKeys ├── .cproject ├── .project ├── CMakeLists.txt └── src │ └── main.cpp ├── CustomObjectsAsMapValues ├── .cproject ├── .project ├── CMakeLists.txt └── src │ └── main.cpp ├── DecltypeAndTypeid ├── .cproject ├── .project ├── CMakeLists.txt └── src │ └── DecltypeAndTypeid.cpp ├── DelegatingConctructors ├── .cproject ├── .project ├── CMakeLists.txt └── src │ └── DelegatingConctructors.cpp ├── DynamicCasts ├── .cproject ├── .project ├── CMakeLists.txt └── src │ └── DynamicCasts.cpp ├── EliminatingMaxIterations ├── .cproject ├── .project ├── CMakeLists.txt └── src │ ├── Bitmap.cpp │ ├── Bitmap.h │ ├── BitmapFileHeader.h │ ├── BitmapInfoHeader.h │ ├── Mandelbrot.cpp │ ├── Mandelbrot.h │ └── main.cpp ├── ElisionandOptimization ├── .cproject ├── .project ├── CMakeLists.txt └── src │ └── ElisionAndOptimization.cpp ├── EnhancedForLoop ├── .cproject ├── .project ├── CMakeLists.txt └── src │ └── EnhancedForLoop.cpp ├── FractalCreatorHelloWorld ├── .cproject ├── .project ├── CMakeLists.txt └── src │ └── FractalCreatorHelloWorld.cpp ├── FunctionPointers ├── .cproject ├── .project ├── CMakeLists.txt └── src │ └── FunctionPointers.cpp ├── FunctionalTypes ├── .cproject ├── .project ├── CMakeLists.txt └── src │ └── FunctionalTypes.cpp ├── Functors ├── .cproject ├── .project ├── CMakeLists.txt └── src │ └── Functors.cpp ├── GettingPixelRanges ├── .cproject ├── .project ├── CMakeLists.txt └── src │ ├── Bitmap.cpp │ ├── Bitmap.h │ ├── BitmapFileHeader.h │ ├── BitmapInfoHeader.h │ ├── FractalCreator.cpp │ ├── FractalCreator.h │ ├── Mandelbrot.cpp │ ├── Mandelbrot.h │ ├── RGB.cpp │ ├── RGB.h │ ├── Zoom.h │ ├── ZoomList.cpp │ ├── ZoomList.h │ └── main.cpp ├── HelloWorld ├── .cproject ├── .project ├── CMakeLists.txt └── src │ └── main.cpp ├── ImplementingFractalCreator ├── .cproject ├── .project ├── CMakeLists.txt └── src │ ├── Bitmap.cpp │ ├── Bitmap.h │ ├── BitmapFileHeader.h │ ├── BitmapInfoHeader.h │ ├── FractalCreator.cpp │ ├── FractalCreator.h │ ├── Mandelbrot.cpp │ ├── Mandelbrot.h │ ├── Zoom.h │ ├── ZoomList.cpp │ ├── ZoomList.h │ └── main.cpp ├── ImprovingtheBasicFractal ├── .cproject ├── .project ├── CMakeLists.txt └── src │ ├── Bitmap.cpp │ ├── Bitmap.h │ ├── BitmapFileHeader.h │ ├── BitmapInfoHeader.h │ ├── Mandelbrot.cpp │ ├── Mandelbrot.h │ └── main.cpp ├── InitializationInC11 ├── .cproject ├── .project ├── CMakeLists.txt └── src │ └── main.cpp ├── InitializationInC98 ├── .cproject ├── .project ├── CMakeLists.txt └── src │ └── main.cpp ├── InitializerLists ├── .cproject ├── .project ├── CMakeLists.txt └── src │ └── InitializerLists.cpp ├── IterableClasses ├── .cproject ├── .project ├── CMakeLists.txt └── src │ ├── main.cpp │ └── ring.h ├── LValueReferences ├── .cproject ├── .project ├── CMakeLists.txt └── src │ └── LValueReferences.cpp ├── LambdaCaptureExpressions ├── .cproject ├── .project ├── CMakeLists.txt └── src │ └── LambdaCaptureExpressions.cpp ├── LambdaExpressions ├── .cproject ├── .project ├── CMakeLists.txt └── src │ └── LambdaExpressions.cpp ├── LambdaParametersAndReturnTypes ├── .cproject ├── .project ├── CMakeLists.txt └── src │ └── LambdaParametersAndReturnTypes.cpp ├── Lists ├── .cproject ├── .project ├── CMakeLists.txt └── src │ └── main.cpp ├── Maps ├── .cproject ├── .project ├── CMakeLists.txt └── src │ └── main.cpp ├── MoveAssignmentOperators ├── .cproject ├── .project ├── CMakeLists.txt └── src │ └── MoveAssignmentOperators.cpp ├── MoveConstructors ├── .cproject ├── .project ├── CMakeLists.txt └── src │ └── MoveConstructors.cpp ├── MultipleInheritance ├── .cproject ├── .project ├── CMakeLists.txt └── src │ └── MultipleInheritance.cpp ├── MutableLambdas ├── .cproject ├── .project ├── CMakeLists.txt └── src │ └── MutableLambdas.cpp ├── NestedTemplateClasses ├── .cproject ├── .project ├── CMakeLists.txt └── src │ ├── NestedTemplateClasses.cpp │ └── ring.h ├── ObjectInitialization ├── .cproject ├── .project ├── CMakeLists.txt └── src │ └── ObjectInitialization.cpp ├── ObjectSlicingandPolymorphism ├── .cproject ├── .project ├── CMakeLists.txt └── src │ └── ObjectSlicingAndPolymorphism.cpp ├── OverloadingComparisonOperators ├── .cproject ├── .project ├── CMakeLists.txt └── src │ ├── Complex.cpp │ ├── Complex.h │ └── OverloadingComparisonOperators.cpp ├── OverloadingPlus ├── .cproject ├── .project ├── CMakeLists.txt └── src │ ├── Complex.cpp │ ├── Complex.h │ └── Overloading Plus.cpp ├── OverloadingtheAssignmentOperator ├── .cproject ├── .project ├── CMakeLists.txt └── src │ └── OverloadingtheAssignmentOperator.cpp ├── OverloadingtheDereferenceOperator ├── .cproject ├── .project ├── CMakeLists.txt └── src │ ├── Complex.cpp │ ├── Complex.h │ └── Overloading the Dereference Operator.cpp ├── OverloadingtheInsertionOperatorforPrinting ├── .cproject ├── .project ├── CMakeLists.txt └── src │ ├── Complex.cpp │ ├── Complex.h │ └── Overloading the Insertion Operator for Printing.cpp ├── OverloadingtheLeftBitShiftOperator ├── .cproject ├── .project ├── CMakeLists.txt └── src │ └── OverloadingtheLeftBitShiftOperator.cpp ├── ParsingTextinFiles ├── .cproject ├── .project ├── CMakeLists.txt ├── src │ └── Parsing Text in Files.cpp └── stats.txt ├── PerfectForwarding ├── .cproject ├── .project ├── CMakeLists.txt └── src │ └── Perfect Forwarding.cpp ├── RangeBasedColoring ├── .cproject ├── .project ├── CMakeLists.txt └── src │ ├── Bitmap.cpp │ ├── Bitmap.h │ ├── BitmapFileHeader.h │ ├── BitmapInfoHeader.h │ ├── FractalCreator.cpp │ ├── FractalCreator.h │ ├── Mandelbrot.cpp │ ├── Mandelbrot.h │ ├── RGB.cpp │ ├── RGB.h │ ├── Zoom.h │ ├── ZoomList.cpp │ ├── ZoomList.h │ └── main.cpp ├── ReadingTextFiles ├── .cproject ├── .project ├── CMakeLists.txt ├── src │ └── Reading Text Files.cpp └── test.txt ├── ReadingandWritingBinaryFiles ├── .cproject ├── .project ├── CMakeLists.txt ├── data.bin └── src │ └── Reading and Writing Binary Files.cpp ├── ReinterpretCast ├── .cproject ├── .project ├── CMakeLists.txt └── src │ └── Reinterpret Cast.cpp ├── ReorganisingMain ├── .cproject ├── .project ├── CMakeLists.txt └── src │ ├── Bitmap.cpp │ ├── Bitmap.h │ ├── BitmapFileHeader.h │ ├── BitmapInfoHeader.h │ ├── FractalCreator.cpp │ ├── FractalCreator.h │ ├── Mandelbrot.cpp │ ├── Mandelbrot.h │ ├── Zoom.h │ ├── ZoomList.cpp │ ├── ZoomList.h │ └── main.cpp ├── RingBuffer ├── .cproject ├── .project ├── CMakeLists.txt └── src │ ├── main.cpp │ └── ring.h ├── RvalueReferences ├── .cproject ├── .project ├── CMakeLists.txt └── src │ └── Rvalue References.cpp ├── Scaling ├── .cproject ├── .project ├── CMakeLists.txt └── src │ ├── Bitmap.cpp │ ├── Bitmap.h │ ├── BitmapFileHeader.h │ ├── BitmapInfoHeader.h │ └── main.cpp ├── SettingPixels ├── .cproject ├── .project ├── CMakeLists.txt └── src │ ├── Bitmap.cpp │ ├── Bitmap.h │ ├── BitmapFileHeader.h │ ├── BitmapInfoHeader.h │ └── main.cpp ├── SharedPointers ├── .cproject ├── .project ├── CMakeLists.txt └── src │ └── Shared Pointers.cpp ├── SortingVectorsDequeFriend ├── .cproject ├── .project ├── CMakeLists.txt └── src │ └── main.cpp ├── SpecifyingColorRanges ├── .cproject ├── .project ├── CMakeLists.txt └── src │ ├── Bitmap.cpp │ ├── Bitmap.h │ ├── BitmapFileHeader.h │ ├── BitmapInfoHeader.h │ ├── FractalCreator.cpp │ ├── FractalCreator.h │ ├── Mandelbrot.cpp │ ├── Mandelbrot.h │ ├── RGB.cpp │ ├── RGB.h │ ├── Zoom.h │ ├── ZoomList.cpp │ ├── ZoomList.h │ └── main.cpp ├── StacksAndQueues ├── .cproject ├── .project ├── CMakeLists.txt └── src │ └── main.cpp ├── StandardExceptions ├── .cproject ├── .project ├── CMakeLists.txt └── src │ └── Standard Exceptions.cpp ├── StaticCast ├── .cproject ├── .project ├── CMakeLists.txt └── src │ └── Static Cast.cpp ├── StlComplexDataTypes ├── .cproject ├── .project ├── CMakeLists.txt └── src │ └── main.cpp ├── StoringIterations ├── .cproject ├── .project ├── CMakeLists.txt └── src │ ├── Bitmap.cpp │ ├── Bitmap.h │ ├── BitmapFileHeader.h │ ├── BitmapInfoHeader.h │ ├── Mandelbrot.cpp │ ├── Mandelbrot.h │ └── main.cpp ├── StructPadding ├── .cproject ├── .project ├── CMakeLists.txt └── src │ └── Binary Files.cpp ├── TemplateClasses ├── .cproject ├── .project ├── CMakeLists.txt └── src │ └── Template Classes.cpp ├── TemplateFunctions1 ├── .cproject ├── .project ├── CMakeLists.txt └── src │ └── Template Functions 1.cpp ├── TemplateFunctionsandTypeInference ├── .cproject ├── .project ├── CMakeLists.txt └── src │ └── TemplateFunctionsAndTypeInference.cpp ├── TheAutoKeyword ├── .cproject ├── .project ├── CMakeLists.txt └── src │ └── TheAutoKeyword.cpp ├── TheFractalAlgorithm ├── .cproject ├── .project ├── CMakeLists.txt └── src │ ├── Bitmap.cpp │ ├── Bitmap.h │ ├── BitmapFileHeader.h │ ├── BitmapInfoHeader.h │ ├── Mandelbrot.cpp │ ├── Mandelbrot.h │ └── main.cpp ├── TheZoomList ├── .cproject ├── .project ├── CMakeLists.txt └── src │ ├── Bitmap.cpp │ ├── Bitmap.h │ ├── BitmapFileHeader.h │ ├── BitmapInfoHeader.h │ ├── Mandelbrot.cpp │ ├── Mandelbrot.h │ ├── Zoom.h │ ├── ZoomList.cpp │ ├── ZoomList.h │ └── main.cpp ├── TwoDimensionalVectors ├── .cproject ├── .project ├── CMakeLists.txt └── src │ └── main.cpp ├── UsingFunctionPointersAnExample ├── .cproject ├── .project ├── CMakeLists.txt └── src │ └── Using Function Pointers - An Example.cpp ├── UsingtheHistogram ├── .cproject ├── .project ├── .settings │ ├── language.settings.xml │ └── org.eclipse.cdt.codan.core.prefs ├── CMakeLists.txt └── src │ ├── Bitmap.cpp │ ├── Bitmap.h │ ├── BitmapFileHeader.h │ ├── BitmapInfoHeader.h │ ├── Mandelbrot.cpp │ ├── Mandelbrot.h │ └── main.cpp ├── UsingtheRGBClass ├── .cproject ├── .project ├── CMakeLists.txt └── src │ ├── Bitmap.cpp │ ├── Bitmap.h │ ├── BitmapFileHeader.h │ ├── BitmapInfoHeader.h │ ├── FractalCreator.cpp │ ├── FractalCreator.h │ ├── Mandelbrot.cpp │ ├── Mandelbrot.h │ ├── RGB.cpp │ ├── RGB.h │ ├── Zoom.h │ ├── ZoomList.cpp │ ├── ZoomList.h │ └── main.cpp ├── ValidatingtheHistogram ├── .cproject ├── .project ├── CMakeLists.txt └── src │ ├── Bitmap.cpp │ ├── Bitmap.h │ ├── BitmapFileHeader.h │ ├── BitmapInfoHeader.h │ ├── Mandelbrot.cpp │ ├── Mandelbrot.h │ └── main.cpp ├── Vectors ├── .cproject ├── .project ├── CMakeLists.txt └── src │ └── Vectors.cpp ├── VectorsAndMemory ├── .cproject ├── .project ├── CMakeLists.txt └── src │ └── Vectors and Memory.cpp ├── WritingABitmap ├── .cproject ├── .project ├── CMakeLists.txt └── src │ ├── Bitmap.cpp │ ├── Bitmap.h │ ├── BitmapFileHeader.h │ ├── BitmapInfoHeader.h │ └── main.cpp ├── WritingTextFiles ├── .cproject ├── .project ├── CMakeLists.txt ├── src │ └── Writing Text Files.cpp └── text.txt ├── ZoomingIn ├── .cproject ├── .project ├── CMakeLists.txt └── src │ ├── Bitmap.cpp │ ├── Bitmap.h │ ├── BitmapFileHeader.h │ ├── BitmapInfoHeader.h │ ├── Mandelbrot.cpp │ ├── Mandelbrot.h │ ├── Zoom.h │ ├── ZoomList.cpp │ ├── ZoomList.h │ └── main.cpp └── lValuesandrValues ├── .cproject ├── .project ├── CMakeLists.txt └── src └── lValuesAndrValues.cpp /.gitignore: -------------------------------------------------------------------------------- 1 | **/CMakeCache.txt 2 | **/CMakeFiles/** 3 | **/Makefile 4 | **/cmake_install.cmake 5 | **/*.bmp 6 | **/bin/** 7 | **/bin/ 8 | 9 | -------------------------------------------------------------------------------- /ABitmapClass/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | set(CMAKE_ARCHIVE_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/lib) 2 | set(CMAKE_LIBRARY_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/lib) 3 | set(CMAKE_RUNTIME_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/bin) 4 | 5 | set (CMAKE_CXX_STANDARD 11) 6 | cmake_minimum_required(VERSION 3.0) 7 | 8 | get_filename_component(ProjectId ${CMAKE_CURRENT_SOURCE_DIR} NAME) 9 | string(REPLACE " " "_" ProjectId ${ProjectId}) 10 | 11 | project(${ProjectId}) 12 | 13 | file(GLOB project_sources src/*.cpp) 14 | file(GLOB project_headers src/*.h src/*.hpp) 15 | 16 | add_executable(${ProjectId} ${project_sources} ${project_headers}) 17 | -------------------------------------------------------------------------------- /ABitmapClass/src/Bitmap.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | * Bitmap.cpp 3 | * 4 | * Created on: Jul 2, 2015 5 | * Author: johnpurcell 6 | */ 7 | 8 | #include "Bitmap.h" 9 | 10 | namespace caveofprogramming { 11 | 12 | Bitmap::Bitmap(int width, int height): m_width(width), m_height(height) { 13 | // TODO Auto-generated constructor stub 14 | 15 | } 16 | 17 | bool Bitmap::write(string filename) { 18 | return false; 19 | } 20 | 21 | void Bitmap::setPixel(int x, int y, uint8_t red, uint8_t green, uint8_t blue) { 22 | 23 | } 24 | 25 | Bitmap::~Bitmap() { 26 | // TODO Auto-generated destructor stub 27 | } 28 | 29 | } /* namespace caveofprogramming */ 30 | -------------------------------------------------------------------------------- /ABitmapClass/src/Bitmap.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Bitmap.h 3 | * 4 | * Created on: Jul 2, 2015 5 | * Author: johnpurcell 6 | */ 7 | 8 | #ifndef BITMAP_H_ 9 | #define BITMAP_H_ 10 | 11 | #include 12 | #include 13 | using namespace std; 14 | 15 | namespace caveofprogramming { 16 | 17 | class Bitmap { 18 | private: 19 | int m_width{0}; 20 | int m_height{0}; 21 | 22 | public: 23 | Bitmap(int width, int height); 24 | void setPixel(int x, int y, uint8_t red, uint8_t green, uint8_t blue); 25 | bool write(string filename); 26 | virtual ~Bitmap(); 27 | }; 28 | 29 | } /* namespace caveofprogramming */ 30 | 31 | #endif /* BITMAP_H_ */ 32 | -------------------------------------------------------------------------------- /ABitmapClass/src/BitmapFileHeader.h: -------------------------------------------------------------------------------- 1 | /* 2 | * BitmapFileHeader.h 3 | * 4 | * Created on: Jun 21, 2015 5 | * Author: johnpurcell 6 | */ 7 | 8 | #ifndef BITMAPFILEHEADER_H_ 9 | #define BITMAPFILEHEADER_H_ 10 | 11 | #include 12 | 13 | using namespace std; 14 | 15 | namespace caveofprogramming { 16 | 17 | #pragma pack(push, 2) 18 | 19 | struct BitmapFileHeader { 20 | char header[2] { 'B', 'M' }; 21 | int32_t fileSize; 22 | int32_t reserved { 0 }; 23 | int32_t dataOffset; 24 | }; 25 | 26 | #pragma pack(pop) 27 | 28 | } 29 | 30 | #endif /* BITMAPFILEHEADER_H_ */ 31 | -------------------------------------------------------------------------------- /ABitmapClass/src/BitmapInfoHeader.h: -------------------------------------------------------------------------------- 1 | #ifndef BITMAPINFOHEADER_H_ 2 | #define BITMAPINFOHEADER_H_ 3 | 4 | #include 5 | 6 | using namespace std; 7 | 8 | namespace caveofprogramming { 9 | 10 | #pragma pack(push, 2) 11 | 12 | struct BitmapInfoHeader { 13 | int32_t headerSize{40}; 14 | int32_t width; 15 | int32_t height; 16 | int16_t planes{1}; 17 | int16_t bitsPerPixel{24}; 18 | int32_t compression{0}; 19 | int32_t dataSize{0}; 20 | int32_t horizontalResolution{2400}; 21 | int32_t verticalResolution{2400}; 22 | int32_t colors{0}; 23 | int32_t importantColors{0}; 24 | }; 25 | 26 | #pragma pack(pop) 27 | 28 | } 29 | 30 | #endif 31 | -------------------------------------------------------------------------------- /ABitmapClass/src/main.cpp: -------------------------------------------------------------------------------- 1 | //============================================================================ 2 | // Name : Fractal.cpp 3 | // Author : 4 | // Version : 5 | // Copyright : Your copyright notice 6 | // Description : Hello World in C++, Ansi-style 7 | //============================================================================ 8 | 9 | #include 10 | 11 | #include "Bitmap.h" 12 | 13 | using namespace std; 14 | using namespace caveofprogramming; 15 | 16 | int main() { 17 | 18 | Bitmap bitmap(800, 600); 19 | 20 | cout << "!!!Hello World!!!" << endl; // prints !!!Hello World!!! 21 | return 0; 22 | } 23 | -------------------------------------------------------------------------------- /AComplexNumberClass/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | set(CMAKE_ARCHIVE_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/lib) 2 | set(CMAKE_LIBRARY_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/lib) 3 | set(CMAKE_RUNTIME_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/bin) 4 | 5 | set (CMAKE_CXX_STANDARD 11) 6 | cmake_minimum_required(VERSION 3.0) 7 | 8 | get_filename_component(ProjectId ${CMAKE_CURRENT_SOURCE_DIR} NAME) 9 | string(REPLACE " " "_" ProjectId ${ProjectId}) 10 | 11 | project(${ProjectId}) 12 | 13 | file(GLOB project_sources src/*.cpp) 14 | file(GLOB project_headers src/*.h src/*.hpp) 15 | 16 | add_executable(${ProjectId} ${project_sources} ${project_headers}) 17 | -------------------------------------------------------------------------------- /AComplexNumberClass/src/AComplexNumberClass.cpp: -------------------------------------------------------------------------------- 1 | //============================================================================ 2 | // Name : A.cpp 3 | // Author : 4 | // Version : 5 | // Copyright : Your copyright notice 6 | // Description : Hello World in C++, Ansi-style 7 | //============================================================================ 8 | 9 | #include 10 | #include "Complex.h" 11 | 12 | using namespace std; 13 | using namespace caveofprogramming; 14 | 15 | int main() { 16 | 17 | Complex c1(2, 3); 18 | Complex c2(c1); 19 | 20 | Complex c3; 21 | 22 | c3 = c2; 23 | 24 | cout << c2 << ": " << c3 << endl; 25 | 26 | return 0; 27 | } 28 | -------------------------------------------------------------------------------- /AComplexNumberClass/src/Complex.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Complex.h 3 | * 4 | * Created on: 17 Oct 2014 5 | * Author: johnwpurcell 6 | */ 7 | 8 | #ifndef COMPLEX_H_ 9 | #define COMPLEX_H_ 10 | 11 | #include 12 | using namespace std; 13 | 14 | namespace caveofprogramming { 15 | 16 | class Complex { 17 | private: 18 | double real; 19 | double imaginary; 20 | 21 | public: 22 | Complex(); 23 | Complex(double real, double imaginary); 24 | Complex(const Complex &other); 25 | const Complex &operator=(const Complex &other); 26 | 27 | double getReal() const { 28 | return real; 29 | } 30 | double getImaginary() const { 31 | return imaginary; 32 | } 33 | }; 34 | 35 | ostream &operator<<(ostream &out, const Complex &c); 36 | 37 | } /* namespace caveofprogramming */ 38 | 39 | #endif /* COMPLEX_H_ */ 40 | -------------------------------------------------------------------------------- /AMandelbrotClass/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | set(CMAKE_ARCHIVE_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/lib) 2 | set(CMAKE_LIBRARY_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/lib) 3 | set(CMAKE_RUNTIME_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/bin) 4 | 5 | set (CMAKE_CXX_STANDARD 11) 6 | cmake_minimum_required(VERSION 3.0) 7 | 8 | get_filename_component(ProjectId ${CMAKE_CURRENT_SOURCE_DIR} NAME) 9 | string(REPLACE " " "_" ProjectId ${ProjectId}) 10 | 11 | project(${ProjectId}) 12 | 13 | file(GLOB project_sources src/*.cpp) 14 | file(GLOB project_headers src/*.h src/*.hpp) 15 | 16 | add_executable(${ProjectId} ${project_sources} ${project_headers}) 17 | -------------------------------------------------------------------------------- /AMandelbrotClass/src/Bitmap.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Bitmap.h 3 | * 4 | * Created on: Jul 2, 2015 5 | * Author: johnpurcell 6 | */ 7 | 8 | #ifndef BITMAP_H_ 9 | #define BITMAP_H_ 10 | 11 | #include 12 | #include 13 | #include 14 | using namespace std; 15 | 16 | namespace caveofprogramming { 17 | 18 | class Bitmap { 19 | private: 20 | int m_width{0}; 21 | int m_height{0}; 22 | unique_ptr m_pPixels{nullptr}; 23 | 24 | 25 | public: 26 | Bitmap(int width, int height); 27 | void setPixel(int x, int y, uint8_t red, uint8_t green, uint8_t blue); 28 | bool write(string filename); 29 | virtual ~Bitmap(); 30 | }; 31 | 32 | } /* namespace caveofprogramming */ 33 | 34 | #endif /* BITMAP_H_ */ 35 | -------------------------------------------------------------------------------- /AMandelbrotClass/src/BitmapFileHeader.h: -------------------------------------------------------------------------------- 1 | /* 2 | * BitmapFileHeader.h 3 | * 4 | * Created on: Jun 21, 2015 5 | * Author: johnpurcell 6 | */ 7 | 8 | #ifndef BITMAPFILEHEADER_H_ 9 | #define BITMAPFILEHEADER_H_ 10 | 11 | #include 12 | 13 | using namespace std; 14 | 15 | namespace caveofprogramming { 16 | 17 | #pragma pack(push, 2) 18 | 19 | struct BitmapFileHeader { 20 | char header[2] { 'B', 'M' }; 21 | int32_t fileSize; 22 | int32_t reserved { 0 }; 23 | int32_t dataOffset; 24 | }; 25 | 26 | #pragma pack(pop) 27 | 28 | } 29 | 30 | #endif /* BITMAPFILEHEADER_H_ */ 31 | -------------------------------------------------------------------------------- /AMandelbrotClass/src/BitmapInfoHeader.h: -------------------------------------------------------------------------------- 1 | #ifndef BITMAPINFOHEADER_H_ 2 | #define BITMAPINFOHEADER_H_ 3 | 4 | #include 5 | 6 | using namespace std; 7 | 8 | namespace caveofprogramming { 9 | 10 | #pragma pack(push, 2) 11 | 12 | struct BitmapInfoHeader { 13 | int32_t headerSize{40}; 14 | int32_t width; 15 | int32_t height; 16 | int16_t planes{1}; 17 | int16_t bitsPerPixel{24}; 18 | int32_t compression{0}; 19 | int32_t dataSize{0}; 20 | int32_t horizontalResolution{2400}; 21 | int32_t verticalResolution{2400}; 22 | int32_t colors{0}; 23 | int32_t importantColors{0}; 24 | }; 25 | 26 | #pragma pack(pop) 27 | 28 | } 29 | 30 | #endif 31 | -------------------------------------------------------------------------------- /AMandelbrotClass/src/Mandelbrot.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | * Mandelbrot.cpp 3 | * 4 | * Created on: Aug 21, 2015 5 | * Author: johnpurcell 6 | */ 7 | 8 | #include "Mandelbrot.h" 9 | 10 | namespace caveofprogramming { 11 | 12 | Mandelbrot::Mandelbrot() { 13 | // TODO Auto-generated constructor stub 14 | 15 | } 16 | 17 | Mandelbrot::~Mandelbrot() { 18 | // TODO Auto-generated destructor stub 19 | } 20 | 21 | int Mandelbrot::getIterations(double x, double y) { 22 | 23 | return 0; 24 | } 25 | 26 | } /* namespace caveofprogramming */ 27 | -------------------------------------------------------------------------------- /AMandelbrotClass/src/Mandelbrot.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Mandelbrot.h 3 | * 4 | * Created on: Aug 21, 2015 5 | * Author: johnpurcell 6 | */ 7 | 8 | #ifndef MANDELBROT_H_ 9 | #define MANDELBROT_H_ 10 | 11 | namespace caveofprogramming { 12 | 13 | class Mandelbrot { 14 | public: 15 | static const int MAX_ITERATIONS = 1000; 16 | 17 | public: 18 | Mandelbrot(); 19 | virtual ~Mandelbrot(); 20 | 21 | static int getIterations(double x, double y); 22 | }; 23 | 24 | } /* namespace caveofprogramming */ 25 | 26 | #endif /* MANDELBROT_H_ */ 27 | -------------------------------------------------------------------------------- /AZoomClass/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | set(CMAKE_ARCHIVE_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/lib) 2 | set(CMAKE_LIBRARY_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/lib) 3 | set(CMAKE_RUNTIME_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/bin) 4 | 5 | set (CMAKE_CXX_STANDARD 11) 6 | cmake_minimum_required(VERSION 3.0) 7 | 8 | get_filename_component(ProjectId ${CMAKE_CURRENT_SOURCE_DIR} NAME) 9 | string(REPLACE " " "_" ProjectId ${ProjectId}) 10 | 11 | project(${ProjectId}) 12 | 13 | file(GLOB project_sources src/*.cpp) 14 | file(GLOB project_headers src/*.h src/*.hpp) 15 | 16 | add_executable(${ProjectId} ${project_sources} ${project_headers}) 17 | -------------------------------------------------------------------------------- /AZoomClass/src/Bitmap.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Bitmap.h 3 | * 4 | * Created on: Jul 2, 2015 5 | * Author: johnpurcell 6 | */ 7 | 8 | #ifndef BITMAP_H_ 9 | #define BITMAP_H_ 10 | 11 | #include 12 | #include 13 | #include 14 | using namespace std; 15 | 16 | namespace caveofprogramming { 17 | 18 | class Bitmap { 19 | private: 20 | int m_width{0}; 21 | int m_height{0}; 22 | unique_ptr m_pPixels{nullptr}; 23 | 24 | 25 | public: 26 | Bitmap(int width, int height); 27 | void setPixel(int x, int y, uint8_t red, uint8_t green, uint8_t blue); 28 | bool write(string filename); 29 | virtual ~Bitmap(); 30 | }; 31 | 32 | } /* namespace caveofprogramming */ 33 | 34 | #endif /* BITMAP_H_ */ 35 | -------------------------------------------------------------------------------- /AZoomClass/src/BitmapFileHeader.h: -------------------------------------------------------------------------------- 1 | /* 2 | * BitmapFileHeader.h 3 | * 4 | * Created on: Jun 21, 2015 5 | * Author: johnpurcell 6 | */ 7 | 8 | #ifndef BITMAPFILEHEADER_H_ 9 | #define BITMAPFILEHEADER_H_ 10 | 11 | #include 12 | 13 | using namespace std; 14 | 15 | namespace caveofprogramming { 16 | 17 | #pragma pack(push, 2) 18 | 19 | struct BitmapFileHeader { 20 | char header[2] { 'B', 'M' }; 21 | int32_t fileSize; 22 | int32_t reserved { 0 }; 23 | int32_t dataOffset; 24 | }; 25 | 26 | #pragma pack(pop) 27 | 28 | } 29 | 30 | #endif /* BITMAPFILEHEADER_H_ */ 31 | -------------------------------------------------------------------------------- /AZoomClass/src/BitmapInfoHeader.h: -------------------------------------------------------------------------------- 1 | #ifndef BITMAPINFOHEADER_H_ 2 | #define BITMAPINFOHEADER_H_ 3 | 4 | #include 5 | 6 | using namespace std; 7 | 8 | namespace caveofprogramming { 9 | 10 | #pragma pack(push, 2) 11 | 12 | struct BitmapInfoHeader { 13 | int32_t headerSize{40}; 14 | int32_t width; 15 | int32_t height; 16 | int16_t planes{1}; 17 | int16_t bitsPerPixel{24}; 18 | int32_t compression{0}; 19 | int32_t dataSize{0}; 20 | int32_t horizontalResolution{2400}; 21 | int32_t verticalResolution{2400}; 22 | int32_t colors{0}; 23 | int32_t importantColors{0}; 24 | }; 25 | 26 | #pragma pack(pop) 27 | 28 | } 29 | 30 | #endif 31 | -------------------------------------------------------------------------------- /AZoomClass/src/Mandelbrot.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | * Mandelbrot.cpp 3 | * 4 | * Created on: Aug 21, 2015 5 | * Author: johnpurcell 6 | */ 7 | 8 | #include 9 | #include "Mandelbrot.h" 10 | 11 | using namespace std; 12 | 13 | namespace caveofprogramming { 14 | 15 | Mandelbrot::Mandelbrot() { 16 | // TODO Auto-generated constructor stub 17 | 18 | } 19 | 20 | Mandelbrot::~Mandelbrot() { 21 | // TODO Auto-generated destructor stub 22 | } 23 | 24 | int Mandelbrot::getIterations(double x, double y) { 25 | 26 | complex z = 0; 27 | complex c(x, y); 28 | 29 | int iterations = 0; 30 | 31 | while(iterations < MAX_ITERATIONS) { 32 | z = z*z + c; 33 | 34 | if(abs(z) > 2) { 35 | break; 36 | } 37 | 38 | iterations++; 39 | } 40 | 41 | return iterations; 42 | } 43 | 44 | } /* namespace caveofprogramming */ 45 | -------------------------------------------------------------------------------- /AZoomClass/src/Mandelbrot.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Mandelbrot.h 3 | * 4 | * Created on: Aug 21, 2015 5 | * Author: johnpurcell 6 | */ 7 | 8 | #ifndef MANDELBROT_H_ 9 | #define MANDELBROT_H_ 10 | 11 | namespace caveofprogramming { 12 | 13 | class Mandelbrot { 14 | public: 15 | static const int MAX_ITERATIONS = 1000; 16 | 17 | public: 18 | Mandelbrot(); 19 | virtual ~Mandelbrot(); 20 | 21 | static int getIterations(double x, double y); 22 | }; 23 | 24 | } /* namespace caveofprogramming */ 25 | 26 | #endif /* MANDELBROT_H_ */ 27 | -------------------------------------------------------------------------------- /AZoomClass/src/Zoom.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Zoom.h 3 | * 4 | * Created on: Sep 20, 2015 5 | * Author: johnpurcell 6 | */ 7 | 8 | #ifndef ZOOM_H_ 9 | #define ZOOM_H_ 10 | 11 | namespace caveofprogramming { 12 | 13 | struct Zoom { 14 | int x{0}; 15 | int y{0}; 16 | double scale{0.0}; 17 | 18 | Zoom(int x, int y, double scale) : x(x), y(y), scale(scale) {}; 19 | 20 | }; 21 | 22 | } /* namespace caveofprogramming */ 23 | 24 | #endif /* ZOOM_H_ */ 25 | -------------------------------------------------------------------------------- /AbstractClasses/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | set(CMAKE_ARCHIVE_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/lib) 2 | set(CMAKE_LIBRARY_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/lib) 3 | set(CMAKE_RUNTIME_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/bin) 4 | 5 | set (CMAKE_CXX_STANDARD 11) 6 | cmake_minimum_required(VERSION 3.0) 7 | 8 | get_filename_component(ProjectId ${CMAKE_CURRENT_SOURCE_DIR} NAME) 9 | string(REPLACE " " "_" ProjectId ${ProjectId}) 10 | 11 | project(${ProjectId}) 12 | 13 | file(GLOB project_sources src/*.cpp) 14 | file(GLOB project_headers src/*.h src/*.hpp) 15 | 16 | add_executable(${ProjectId} ${project_sources} ${project_headers}) 17 | -------------------------------------------------------------------------------- /AnRGBClass/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | set(CMAKE_ARCHIVE_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/lib) 2 | set(CMAKE_LIBRARY_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/lib) 3 | set(CMAKE_RUNTIME_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/bin) 4 | 5 | set (CMAKE_CXX_STANDARD 11) 6 | cmake_minimum_required(VERSION 3.0) 7 | 8 | get_filename_component(ProjectId ${CMAKE_CURRENT_SOURCE_DIR} NAME) 9 | string(REPLACE " " "_" ProjectId ${ProjectId}) 10 | 11 | project(${ProjectId}) 12 | 13 | file(GLOB project_sources src/*.cpp) 14 | file(GLOB project_headers src/*.h src/*.hpp) 15 | 16 | add_executable(${ProjectId} ${project_sources} ${project_headers}) 17 | -------------------------------------------------------------------------------- /AnRGBClass/src/Bitmap.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Bitmap.h 3 | * 4 | * Created on: Jul 2, 2015 5 | * Author: johnpurcell 6 | */ 7 | 8 | #ifndef BITMAP_H_ 9 | #define BITMAP_H_ 10 | 11 | #include 12 | #include 13 | #include 14 | using namespace std; 15 | 16 | namespace caveofprogramming { 17 | 18 | class Bitmap { 19 | private: 20 | int m_width{0}; 21 | int m_height{0}; 22 | unique_ptr m_pPixels{nullptr}; 23 | 24 | 25 | public: 26 | Bitmap(int width, int height); 27 | void setPixel(int x, int y, uint8_t red, uint8_t green, uint8_t blue); 28 | bool write(string filename); 29 | virtual ~Bitmap(); 30 | }; 31 | 32 | } /* namespace caveofprogramming */ 33 | 34 | #endif /* BITMAP_H_ */ 35 | -------------------------------------------------------------------------------- /AnRGBClass/src/BitmapFileHeader.h: -------------------------------------------------------------------------------- 1 | /* 2 | * BitmapFileHeader.h 3 | * 4 | * Created on: Jun 21, 2015 5 | * Author: johnpurcell 6 | */ 7 | 8 | #ifndef BITMAPFILEHEADER_H_ 9 | #define BITMAPFILEHEADER_H_ 10 | 11 | #include 12 | 13 | using namespace std; 14 | 15 | namespace caveofprogramming { 16 | 17 | #pragma pack(push, 2) 18 | 19 | struct BitmapFileHeader { 20 | char header[2] { 'B', 'M' }; 21 | int32_t fileSize; 22 | int32_t reserved { 0 }; 23 | int32_t dataOffset; 24 | }; 25 | 26 | #pragma pack(pop) 27 | 28 | } 29 | 30 | #endif /* BITMAPFILEHEADER_H_ */ 31 | -------------------------------------------------------------------------------- /AnRGBClass/src/BitmapInfoHeader.h: -------------------------------------------------------------------------------- 1 | #ifndef BITMAPINFOHEADER_H_ 2 | #define BITMAPINFOHEADER_H_ 3 | 4 | #include 5 | 6 | using namespace std; 7 | 8 | namespace caveofprogramming { 9 | 10 | #pragma pack(push, 2) 11 | 12 | struct BitmapInfoHeader { 13 | int32_t headerSize{40}; 14 | int32_t width; 15 | int32_t height; 16 | int16_t planes{1}; 17 | int16_t bitsPerPixel{24}; 18 | int32_t compression{0}; 19 | int32_t dataSize{0}; 20 | int32_t horizontalResolution{2400}; 21 | int32_t verticalResolution{2400}; 22 | int32_t colors{0}; 23 | int32_t importantColors{0}; 24 | }; 25 | 26 | #pragma pack(pop) 27 | 28 | } 29 | 30 | #endif 31 | -------------------------------------------------------------------------------- /AnRGBClass/src/Mandelbrot.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | * Mandelbrot.cpp 3 | * 4 | * Created on: Aug 21, 2015 5 | * Author: johnpurcell 6 | */ 7 | 8 | #include 9 | #include "Mandelbrot.h" 10 | 11 | using namespace std; 12 | 13 | namespace caveofprogramming { 14 | 15 | Mandelbrot::Mandelbrot() { 16 | // TODO Auto-generated constructor stub 17 | 18 | } 19 | 20 | Mandelbrot::~Mandelbrot() { 21 | // TODO Auto-generated destructor stub 22 | } 23 | 24 | int Mandelbrot::getIterations(double x, double y) { 25 | 26 | complex z = 0; 27 | complex c(x, y); 28 | 29 | int iterations = 0; 30 | 31 | while(iterations < MAX_ITERATIONS) { 32 | z = z*z + c; 33 | 34 | if(abs(z) > 2) { 35 | break; 36 | } 37 | 38 | iterations++; 39 | } 40 | 41 | return iterations; 42 | } 43 | 44 | } /* namespace caveofprogramming */ 45 | -------------------------------------------------------------------------------- /AnRGBClass/src/Mandelbrot.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Mandelbrot.h 3 | * 4 | * Created on: Aug 21, 2015 5 | * Author: johnpurcell 6 | */ 7 | 8 | #ifndef MANDELBROT_H_ 9 | #define MANDELBROT_H_ 10 | 11 | namespace caveofprogramming { 12 | 13 | class Mandelbrot { 14 | public: 15 | static const int MAX_ITERATIONS = 1000; 16 | 17 | public: 18 | Mandelbrot(); 19 | virtual ~Mandelbrot(); 20 | 21 | static int getIterations(double x, double y); 22 | }; 23 | 24 | } /* namespace caveofprogramming */ 25 | 26 | #endif /* MANDELBROT_H_ */ 27 | -------------------------------------------------------------------------------- /AnRGBClass/src/RGB.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | * RGB.cpp 3 | * 4 | * Created on: Sep 21, 2015 5 | * Author: johnpurcell 6 | */ 7 | 8 | #include "RGB.h" 9 | 10 | namespace caveofprogramming { 11 | 12 | RGB::RGB(double r, double g, double b): r(r), g(g), b(b) { 13 | // TODO Auto-generated constructor stub 14 | 15 | } 16 | 17 | RGB operator-(const RGB& first, const RGB& second) { 18 | return RGB(first.r - second.r, first.g - second.g, first.b - second.b); 19 | } 20 | 21 | } /* namespace caveofprogramming */ 22 | -------------------------------------------------------------------------------- /AnRGBClass/src/RGB.h: -------------------------------------------------------------------------------- 1 | /* 2 | * RGB.h 3 | * 4 | * Created on: Sep 21, 2015 5 | * Author: johnpurcell 6 | */ 7 | 8 | #ifndef RGB_H_ 9 | #define RGB_H_ 10 | 11 | namespace caveofprogramming { 12 | 13 | struct RGB { 14 | double r; 15 | double g; 16 | double b; 17 | 18 | RGB(double r, double g, double b); 19 | }; 20 | 21 | RGB operator-(const RGB& first, const RGB& second); 22 | 23 | } /* namespace caveofprogramming */ 24 | 25 | 26 | 27 | #endif /* RGB_H_ */ 28 | -------------------------------------------------------------------------------- /AnRGBClass/src/Zoom.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Zoom.h 3 | * 4 | * Created on: Sep 20, 2015 5 | * Author: johnpurcell 6 | */ 7 | 8 | #ifndef ZOOM_H_ 9 | #define ZOOM_H_ 10 | 11 | namespace caveofprogramming { 12 | 13 | struct Zoom { 14 | int x{0}; 15 | int y{0}; 16 | double scale{0.0}; 17 | 18 | Zoom(int x, int y, double scale) : x(x), y(y), scale(scale) {}; 19 | }; 20 | 21 | } /* namespace caveofprogramming */ 22 | 23 | #endif /* ZOOM_H_ */ 24 | -------------------------------------------------------------------------------- /AnRGBClass/src/ZoomList.h: -------------------------------------------------------------------------------- 1 | /* 2 | * ZoomList.h 3 | * 4 | * Created on: Sep 20, 2015 5 | * Author: johnpurcell 6 | */ 7 | 8 | #ifndef ZOOMLIST_H_ 9 | #define ZOOMLIST_H_ 10 | 11 | #include 12 | #include 13 | #include "Zoom.h" 14 | 15 | using namespace std; 16 | 17 | namespace caveofprogramming { 18 | 19 | class ZoomList { 20 | private: 21 | double m_xCenter{0}; 22 | double m_yCenter{0}; 23 | double m_scale{1.0}; 24 | 25 | int m_width{0}; 26 | int m_height{0}; 27 | vector zooms; 28 | 29 | public: 30 | ZoomList(int width, int height); 31 | void add(const Zoom& zoom); 32 | pair doZoom(int x, int y); 33 | }; 34 | 35 | } /* namespace caveofprogramming */ 36 | 37 | #endif /* ZOOMLIST_H_ */ 38 | -------------------------------------------------------------------------------- /AnRGBClass/src/main.cpp: -------------------------------------------------------------------------------- 1 | //============================================================================ 2 | // Name : Fractal.cpp 3 | // Author : 4 | // Version : 5 | // Copyright : Your copyright notice 6 | // Description : Hello World in C++, Ansi-style 7 | //============================================================================ 8 | 9 | #include 10 | 11 | #include "FractalCreator.h" 12 | #include "RGB.h" 13 | 14 | using namespace std; 15 | using namespace caveofprogramming; 16 | 17 | int main() { 18 | 19 | FractalCreator fractalCreator(800, 600); 20 | 21 | fractalCreator.run("test.bmp"); 22 | 23 | cout << "Finished." << endl; 24 | return 0; 25 | } 26 | -------------------------------------------------------------------------------- /ApplyingtheZoom/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | set(CMAKE_ARCHIVE_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/lib) 2 | set(CMAKE_LIBRARY_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/lib) 3 | set(CMAKE_RUNTIME_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/bin) 4 | 5 | set (CMAKE_CXX_STANDARD 11) 6 | cmake_minimum_required(VERSION 3.0) 7 | 8 | get_filename_component(ProjectId ${CMAKE_CURRENT_SOURCE_DIR} NAME) 9 | string(REPLACE " " "_" ProjectId ${ProjectId}) 10 | 11 | project(${ProjectId}) 12 | 13 | file(GLOB project_sources src/*.cpp) 14 | file(GLOB project_headers src/*.h src/*.hpp) 15 | 16 | add_executable(${ProjectId} ${project_sources} ${project_headers}) 17 | -------------------------------------------------------------------------------- /ApplyingtheZoom/src/Bitmap.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Bitmap.h 3 | * 4 | * Created on: Jul 2, 2015 5 | * Author: johnpurcell 6 | */ 7 | 8 | #ifndef BITMAP_H_ 9 | #define BITMAP_H_ 10 | 11 | #include 12 | #include 13 | #include 14 | using namespace std; 15 | 16 | namespace caveofprogramming { 17 | 18 | class Bitmap { 19 | private: 20 | int m_width{0}; 21 | int m_height{0}; 22 | unique_ptr m_pPixels{nullptr}; 23 | 24 | 25 | public: 26 | Bitmap(int width, int height); 27 | void setPixel(int x, int y, uint8_t red, uint8_t green, uint8_t blue); 28 | bool write(string filename); 29 | virtual ~Bitmap(); 30 | }; 31 | 32 | } /* namespace caveofprogramming */ 33 | 34 | #endif /* BITMAP_H_ */ 35 | -------------------------------------------------------------------------------- /ApplyingtheZoom/src/BitmapFileHeader.h: -------------------------------------------------------------------------------- 1 | /* 2 | * BitmapFileHeader.h 3 | * 4 | * Created on: Jun 21, 2015 5 | * Author: johnpurcell 6 | */ 7 | 8 | #ifndef BITMAPFILEHEADER_H_ 9 | #define BITMAPFILEHEADER_H_ 10 | 11 | #include 12 | 13 | using namespace std; 14 | 15 | namespace caveofprogramming { 16 | 17 | #pragma pack(push, 2) 18 | 19 | struct BitmapFileHeader { 20 | char header[2] { 'B', 'M' }; 21 | int32_t fileSize; 22 | int32_t reserved { 0 }; 23 | int32_t dataOffset; 24 | }; 25 | 26 | #pragma pack(pop) 27 | 28 | } 29 | 30 | #endif /* BITMAPFILEHEADER_H_ */ 31 | -------------------------------------------------------------------------------- /ApplyingtheZoom/src/BitmapInfoHeader.h: -------------------------------------------------------------------------------- 1 | #ifndef BITMAPINFOHEADER_H_ 2 | #define BITMAPINFOHEADER_H_ 3 | 4 | #include 5 | 6 | using namespace std; 7 | 8 | namespace caveofprogramming { 9 | 10 | #pragma pack(push, 2) 11 | 12 | struct BitmapInfoHeader { 13 | int32_t headerSize{40}; 14 | int32_t width; 15 | int32_t height; 16 | int16_t planes{1}; 17 | int16_t bitsPerPixel{24}; 18 | int32_t compression{0}; 19 | int32_t dataSize{0}; 20 | int32_t horizontalResolution{2400}; 21 | int32_t verticalResolution{2400}; 22 | int32_t colors{0}; 23 | int32_t importantColors{0}; 24 | }; 25 | 26 | #pragma pack(pop) 27 | 28 | } 29 | 30 | #endif 31 | -------------------------------------------------------------------------------- /ApplyingtheZoom/src/Mandelbrot.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | * Mandelbrot.cpp 3 | * 4 | * Created on: Aug 21, 2015 5 | * Author: johnpurcell 6 | */ 7 | 8 | #include 9 | #include "Mandelbrot.h" 10 | 11 | using namespace std; 12 | 13 | namespace caveofprogramming { 14 | 15 | Mandelbrot::Mandelbrot() { 16 | // TODO Auto-generated constructor stub 17 | 18 | } 19 | 20 | Mandelbrot::~Mandelbrot() { 21 | // TODO Auto-generated destructor stub 22 | } 23 | 24 | int Mandelbrot::getIterations(double x, double y) { 25 | 26 | complex z = 0; 27 | complex c(x, y); 28 | 29 | int iterations = 0; 30 | 31 | while(iterations < MAX_ITERATIONS) { 32 | z = z*z + c; 33 | 34 | if(abs(z) > 2) { 35 | break; 36 | } 37 | 38 | iterations++; 39 | } 40 | 41 | return iterations; 42 | } 43 | 44 | } /* namespace caveofprogramming */ 45 | -------------------------------------------------------------------------------- /ApplyingtheZoom/src/Mandelbrot.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Mandelbrot.h 3 | * 4 | * Created on: Aug 21, 2015 5 | * Author: johnpurcell 6 | */ 7 | 8 | #ifndef MANDELBROT_H_ 9 | #define MANDELBROT_H_ 10 | 11 | namespace caveofprogramming { 12 | 13 | class Mandelbrot { 14 | public: 15 | static const int MAX_ITERATIONS = 1000; 16 | 17 | public: 18 | Mandelbrot(); 19 | virtual ~Mandelbrot(); 20 | 21 | static int getIterations(double x, double y); 22 | }; 23 | 24 | } /* namespace caveofprogramming */ 25 | 26 | #endif /* MANDELBROT_H_ */ 27 | -------------------------------------------------------------------------------- /ApplyingtheZoom/src/Zoom.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Zoom.h 3 | * 4 | * Created on: Sep 20, 2015 5 | * Author: johnpurcell 6 | */ 7 | 8 | #ifndef ZOOM_H_ 9 | #define ZOOM_H_ 10 | 11 | namespace caveofprogramming { 12 | 13 | struct Zoom { 14 | int x{0}; 15 | int y{0}; 16 | double scale{0.0}; 17 | 18 | Zoom(int x, int y, double scale) : x(x), y(y), scale(scale) {}; 19 | }; 20 | 21 | } /* namespace caveofprogramming */ 22 | 23 | #endif /* ZOOM_H_ */ 24 | -------------------------------------------------------------------------------- /ApplyingtheZoom/src/ZoomList.h: -------------------------------------------------------------------------------- 1 | /* 2 | * ZoomList.h 3 | * 4 | * Created on: Sep 20, 2015 5 | * Author: johnpurcell 6 | */ 7 | 8 | #ifndef ZOOMLIST_H_ 9 | #define ZOOMLIST_H_ 10 | 11 | #include 12 | #include 13 | #include "Zoom.h" 14 | 15 | using namespace std; 16 | 17 | namespace caveofprogramming { 18 | 19 | class ZoomList { 20 | private: 21 | double m_xCenter{0}; 22 | double m_yCenter{0}; 23 | double m_scale{1.0}; 24 | 25 | int m_width{0}; 26 | int m_height{0}; 27 | vector zooms; 28 | 29 | public: 30 | ZoomList(int width, int height); 31 | void add(const Zoom& zoom); 32 | pair doZoom(int x, int y); 33 | }; 34 | 35 | } /* namespace caveofprogramming */ 36 | 37 | #endif /* ZOOMLIST_H_ */ 38 | -------------------------------------------------------------------------------- /AutoPointers/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | set(CMAKE_ARCHIVE_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/lib) 2 | set(CMAKE_LIBRARY_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/lib) 3 | set(CMAKE_RUNTIME_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/bin) 4 | 5 | set (CMAKE_CXX_STANDARD 11) 6 | cmake_minimum_required(VERSION 3.0) 7 | 8 | get_filename_component(ProjectId ${CMAKE_CURRENT_SOURCE_DIR} NAME) 9 | string(REPLACE " " "_" ProjectId ${ProjectId}) 10 | 11 | project(${ProjectId}) 12 | 13 | file(GLOB project_sources src/*.cpp) 14 | file(GLOB project_headers src/*.h src/*.hpp) 15 | 16 | add_executable(${ProjectId} ${project_sources} ${project_headers}) 17 | -------------------------------------------------------------------------------- /AutoPointers/src/AutoPointers.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | 4 | using namespace std; 5 | 6 | class Test { 7 | public: 8 | Test() { 9 | cout << "created" << endl; 10 | } 11 | 12 | void greet() { 13 | cout << "Hello" << endl; 14 | } 15 | 16 | ~Test() { 17 | cout << "destroyed" << endl; 18 | } 19 | }; 20 | 21 | class Temp { 22 | private: 23 | unique_ptr pTest; 24 | 25 | public: 26 | Temp(): pTest(new Test[2]) { 27 | 28 | } 29 | }; 30 | 31 | int main() { 32 | 33 | Temp temp; 34 | 35 | unique_ptr pTest(new Test[2]); 36 | 37 | pTest[1].greet(); 38 | 39 | cout << "Finished" << endl; 40 | 41 | return 0; 42 | } 43 | -------------------------------------------------------------------------------- /AutoPointers/src/temp.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | using namespace std; 3 | 4 | class Test { 5 | public: 6 | Test() { 7 | cout << "created" << endl; 8 | } 9 | 10 | void greet() { 11 | cout << "Hello" << endl; 12 | } 13 | 14 | ~Test() { 15 | cout << "destroyed" << endl; 16 | } 17 | }; 18 | -------------------------------------------------------------------------------- /BasicExceptions/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | set(CMAKE_ARCHIVE_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/lib) 2 | set(CMAKE_LIBRARY_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/lib) 3 | set(CMAKE_RUNTIME_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/bin) 4 | 5 | set (CMAKE_CXX_STANDARD 11) 6 | cmake_minimum_required(VERSION 3.0) 7 | 8 | get_filename_component(ProjectId ${CMAKE_CURRENT_SOURCE_DIR} NAME) 9 | string(REPLACE " " "_" ProjectId ${ProjectId}) 10 | 11 | project(${ProjectId}) 12 | 13 | file(GLOB project_sources src/*.cpp) 14 | file(GLOB project_headers src/*.h src/*.hpp) 15 | 16 | add_executable(${ProjectId} ${project_sources} ${project_headers}) 17 | -------------------------------------------------------------------------------- /BinaryFiles/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | set(CMAKE_ARCHIVE_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/lib) 2 | set(CMAKE_LIBRARY_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/lib) 3 | set(CMAKE_RUNTIME_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/bin) 4 | 5 | set (CMAKE_CXX_STANDARD 11) 6 | cmake_minimum_required(VERSION 3.0) 7 | 8 | get_filename_component(ProjectId ${CMAKE_CURRENT_SOURCE_DIR} NAME) 9 | string(REPLACE " " "_" ProjectId ${ProjectId}) 10 | 11 | project(${ProjectId}) 12 | 13 | file(GLOB project_sources src/*.cpp) 14 | file(GLOB project_headers src/*.h src/*.hpp) 15 | 16 | add_executable(${ProjectId} ${project_sources} ${project_headers}) 17 | -------------------------------------------------------------------------------- /BinaryFiles/test.bin: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/caveofprogramming/advanced-cplusplus/18f1d43d68c41b9e543d5350e9c47967b671d22a/BinaryFiles/test.bin -------------------------------------------------------------------------------- /Bind/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | set(CMAKE_ARCHIVE_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/lib) 2 | set(CMAKE_LIBRARY_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/lib) 3 | set(CMAKE_RUNTIME_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/bin) 4 | 5 | set (CMAKE_CXX_STANDARD 11) 6 | cmake_minimum_required(VERSION 3.0) 7 | 8 | get_filename_component(ProjectId ${CMAKE_CURRENT_SOURCE_DIR} NAME) 9 | string(REPLACE " " "_" ProjectId ${ProjectId}) 10 | 11 | project(${ProjectId}) 12 | 13 | file(GLOB project_sources src/*.cpp) 14 | file(GLOB project_headers src/*.h src/*.hpp) 15 | 16 | add_executable(${ProjectId} ${project_sources} ${project_headers}) 17 | -------------------------------------------------------------------------------- /BitmapFileHeaders/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | set(CMAKE_ARCHIVE_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/lib) 2 | set(CMAKE_LIBRARY_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/lib) 3 | set(CMAKE_RUNTIME_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/bin) 4 | 5 | set (CMAKE_CXX_STANDARD 11) 6 | cmake_minimum_required(VERSION 3.0) 7 | 8 | get_filename_component(ProjectId ${CMAKE_CURRENT_SOURCE_DIR} NAME) 9 | string(REPLACE " " "_" ProjectId ${ProjectId}) 10 | 11 | project(${ProjectId}) 12 | 13 | file(GLOB project_sources src/*.cpp) 14 | file(GLOB project_headers src/*.h src/*.hpp) 15 | 16 | add_executable(${ProjectId} ${project_sources} ${project_headers}) 17 | -------------------------------------------------------------------------------- /BitmapFileHeaders/src/BitmapFileHeader.h: -------------------------------------------------------------------------------- 1 | /* 2 | * BitmapFileHeader.h 3 | * 4 | * Created on: Jun 21, 2015 5 | * Author: johnpurcell 6 | */ 7 | 8 | #ifndef BITMAPFILEHEADER_H_ 9 | #define BITMAPFILEHEADER_H_ 10 | 11 | #include 12 | 13 | using namespace std; 14 | 15 | namespace caveofprogramming { 16 | 17 | #pragma pack(push, 2) 18 | 19 | struct BitmapFileHeader { 20 | char header[2] { 'B', 'M' }; 21 | int32_t fileSize; 22 | int32_t reserved { 0 }; 23 | int32_t dataOffset; 24 | }; 25 | 26 | #pragma pack(pop) 27 | 28 | } 29 | 30 | #endif /* BITMAPFILEHEADER_H_ */ 31 | -------------------------------------------------------------------------------- /BitmapFileHeaders/src/FractalCreatorHelloWorld.cpp: -------------------------------------------------------------------------------- 1 | //============================================================================ 2 | // Name : Fractal.cpp 3 | // Author : 4 | // Version : 5 | // Copyright : Your copyright notice 6 | // Description : Hello World in C++, Ansi-style 7 | //============================================================================ 8 | 9 | #include 10 | using namespace std; 11 | 12 | int main() { 13 | cout << "!!!Hello World!!!" << endl; // prints !!!Hello World!!! 14 | return 0; 15 | } 16 | -------------------------------------------------------------------------------- /BitmapHeaderValues/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | set(CMAKE_ARCHIVE_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/lib) 2 | set(CMAKE_LIBRARY_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/lib) 3 | set(CMAKE_RUNTIME_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/bin) 4 | 5 | set (CMAKE_CXX_STANDARD 11) 6 | cmake_minimum_required(VERSION 3.0) 7 | 8 | get_filename_component(ProjectId ${CMAKE_CURRENT_SOURCE_DIR} NAME) 9 | string(REPLACE " " "_" ProjectId ${ProjectId}) 10 | 11 | project(${ProjectId}) 12 | 13 | file(GLOB project_sources src/*.cpp) 14 | file(GLOB project_headers src/*.h src/*.hpp) 15 | 16 | add_executable(${ProjectId} ${project_sources} ${project_headers}) 17 | -------------------------------------------------------------------------------- /BitmapHeaderValues/src/Bitmap.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Bitmap.h 3 | * 4 | * Created on: Jul 2, 2015 5 | * Author: johnpurcell 6 | */ 7 | 8 | #ifndef BITMAP_H_ 9 | #define BITMAP_H_ 10 | 11 | #include 12 | #include 13 | #include 14 | using namespace std; 15 | 16 | namespace caveofprogramming { 17 | 18 | class Bitmap { 19 | private: 20 | int m_width{0}; 21 | int m_height{0}; 22 | unique_ptr m_pPixels{nullptr}; 23 | 24 | 25 | public: 26 | Bitmap(int width, int height); 27 | void setPixel(int x, int y, uint8_t red, uint8_t green, uint8_t blue); 28 | bool write(string filename); 29 | virtual ~Bitmap(); 30 | }; 31 | 32 | } /* namespace caveofprogramming */ 33 | 34 | #endif /* BITMAP_H_ */ 35 | -------------------------------------------------------------------------------- /BitmapHeaderValues/src/BitmapFileHeader.h: -------------------------------------------------------------------------------- 1 | /* 2 | * BitmapFileHeader.h 3 | * 4 | * Created on: Jun 21, 2015 5 | * Author: johnpurcell 6 | */ 7 | 8 | #ifndef BITMAPFILEHEADER_H_ 9 | #define BITMAPFILEHEADER_H_ 10 | 11 | #include 12 | 13 | using namespace std; 14 | 15 | namespace caveofprogramming { 16 | 17 | #pragma pack(push, 2) 18 | 19 | struct BitmapFileHeader { 20 | char header[2] { 'B', 'M' }; 21 | int32_t fileSize; 22 | int32_t reserved { 0 }; 23 | int32_t dataOffset; 24 | }; 25 | 26 | #pragma pack(pop) 27 | 28 | } 29 | 30 | #endif /* BITMAPFILEHEADER_H_ */ 31 | -------------------------------------------------------------------------------- /BitmapHeaderValues/src/BitmapInfoHeader.h: -------------------------------------------------------------------------------- 1 | #ifndef BITMAPINFOHEADER_H_ 2 | #define BITMAPINFOHEADER_H_ 3 | 4 | #include 5 | 6 | using namespace std; 7 | 8 | namespace caveofprogramming { 9 | 10 | #pragma pack(push, 2) 11 | 12 | struct BitmapInfoHeader { 13 | int32_t headerSize{40}; 14 | int32_t width; 15 | int32_t height; 16 | int16_t planes{1}; 17 | int16_t bitsPerPixel{24}; 18 | int32_t compression{0}; 19 | int32_t dataSize{0}; 20 | int32_t horizontalResolution{2400}; 21 | int32_t verticalResolution{2400}; 22 | int32_t colors{0}; 23 | int32_t importantColors{0}; 24 | }; 25 | 26 | #pragma pack(pop) 27 | 28 | } 29 | 30 | #endif 31 | -------------------------------------------------------------------------------- /BitmapHeaderValues/src/main.cpp: -------------------------------------------------------------------------------- 1 | //============================================================================ 2 | // Name : Fractal.cpp 3 | // Author : 4 | // Version : 5 | // Copyright : Your copyright notice 6 | // Description : Hello World in C++, Ansi-style 7 | //============================================================================ 8 | 9 | #include 10 | #include "BitmapInfoHeader.h" 11 | #include "BitmapFileHeader.h" 12 | #include "Bitmap.h" 13 | 14 | using namespace std; 15 | using namespace caveofprogramming; 16 | 17 | int main() { 18 | cout << "!!!Hello World!!!" << endl; // prints !!!Hello World!!! 19 | return 0; 20 | } 21 | -------------------------------------------------------------------------------- /BitmapInfoHeaders/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | set(CMAKE_ARCHIVE_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/lib) 2 | set(CMAKE_LIBRARY_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/lib) 3 | set(CMAKE_RUNTIME_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/bin) 4 | 5 | set (CMAKE_CXX_STANDARD 11) 6 | cmake_minimum_required(VERSION 3.0) 7 | 8 | get_filename_component(ProjectId ${CMAKE_CURRENT_SOURCE_DIR} NAME) 9 | string(REPLACE " " "_" ProjectId ${ProjectId}) 10 | 11 | project(${ProjectId}) 12 | 13 | file(GLOB project_sources src/*.cpp) 14 | file(GLOB project_headers src/*.h src/*.hpp) 15 | 16 | add_executable(${ProjectId} ${project_sources} ${project_headers}) 17 | -------------------------------------------------------------------------------- /BitmapInfoHeaders/src/BitmapInfoHeader.h: -------------------------------------------------------------------------------- 1 | #ifndef BITMAPINFOHEADER_H_ 2 | #define BITMAPINFOHEADER_H_ 3 | 4 | #include 5 | 6 | using namespace std; 7 | 8 | namespace caveofprogramming { 9 | 10 | #pragma pack(push, 2) 11 | 12 | struct BitmapInfoHeader { 13 | int32_t headerSize{40}; 14 | int32_t width; 15 | int32_t height; 16 | int16_t planes{1}; 17 | int16_t bitsPerPixel{24}; 18 | int32_t compression{0}; 19 | int32_t dataSize{0}; 20 | int32_t horizontalResolution{2400}; 21 | int32_t verticalResolution{2400}; 22 | int32_t colors{0}; 23 | int32_t importantColors{0}; 24 | }; 25 | 26 | #pragma pack(pop) 27 | 28 | } 29 | 30 | #endif 31 | -------------------------------------------------------------------------------- /BitmapInfoHeaders/src/FractalCreatorHelloWorld.cpp: -------------------------------------------------------------------------------- 1 | //============================================================================ 2 | // Name : Fractal.cpp 3 | // Author : 4 | // Version : 5 | // Copyright : Your copyright notice 6 | // Description : Hello World in C++, Ansi-style 7 | //============================================================================ 8 | 9 | #include 10 | using namespace std; 11 | 12 | int main() { 13 | cout << "!!!Hello World!!!" << endl; // prints !!!Hello World!!! 14 | return 0; 15 | } 16 | -------------------------------------------------------------------------------- /BitmapMemory/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | set(CMAKE_ARCHIVE_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/lib) 2 | set(CMAKE_LIBRARY_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/lib) 3 | set(CMAKE_RUNTIME_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/bin) 4 | 5 | set (CMAKE_CXX_STANDARD 11) 6 | cmake_minimum_required(VERSION 3.0) 7 | 8 | get_filename_component(ProjectId ${CMAKE_CURRENT_SOURCE_DIR} NAME) 9 | string(REPLACE " " "_" ProjectId ${ProjectId}) 10 | 11 | project(${ProjectId}) 12 | 13 | file(GLOB project_sources src/*.cpp) 14 | file(GLOB project_headers src/*.h src/*.hpp) 15 | 16 | add_executable(${ProjectId} ${project_sources} ${project_headers}) 17 | -------------------------------------------------------------------------------- /BitmapMemory/src/Bitmap.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | * Bitmap.cpp 3 | * 4 | * Created on: Jul 2, 2015 5 | * Author: johnpurcell 6 | */ 7 | 8 | #include "Bitmap.h" 9 | 10 | namespace caveofprogramming { 11 | 12 | Bitmap::Bitmap(int width, int height): m_width(width), m_height(height), m_pPixels(new uint8_t[width*height*3]) { 13 | // TODO Auto-generated constructor stub 14 | 15 | } 16 | 17 | bool Bitmap::write(string filename) { 18 | return false; 19 | } 20 | 21 | void Bitmap::setPixel(int x, int y, uint8_t red, uint8_t green, uint8_t blue) { 22 | 23 | } 24 | 25 | Bitmap::~Bitmap() { 26 | // TODO Auto-generated destructor stub 27 | } 28 | 29 | } /* namespace caveofprogramming */ 30 | -------------------------------------------------------------------------------- /BitmapMemory/src/Bitmap.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Bitmap.h 3 | * 4 | * Created on: Jul 2, 2015 5 | * Author: johnpurcell 6 | */ 7 | 8 | #ifndef BITMAP_H_ 9 | #define BITMAP_H_ 10 | 11 | #include 12 | #include 13 | #include 14 | 15 | using namespace std; 16 | 17 | namespace caveofprogramming { 18 | 19 | class Bitmap { 20 | private: 21 | int m_width{0}; 22 | int m_height{0}; 23 | unique_ptr m_pPixels{nullptr}; 24 | 25 | public: 26 | Bitmap(int width, int height); 27 | void setPixel(int x, int y, uint8_t red, uint8_t green, uint8_t blue); 28 | bool write(string filename); 29 | virtual ~Bitmap(); 30 | }; 31 | 32 | } /* namespace caveofprogramming */ 33 | 34 | #endif /* BITMAP_H_ */ 35 | -------------------------------------------------------------------------------- /BitmapMemory/src/BitmapFileHeader.h: -------------------------------------------------------------------------------- 1 | /* 2 | * BitmapFileHeader.h 3 | * 4 | * Created on: Jun 21, 2015 5 | * Author: johnpurcell 6 | */ 7 | 8 | #ifndef BITMAPFILEHEADER_H_ 9 | #define BITMAPFILEHEADER_H_ 10 | 11 | #include 12 | 13 | using namespace std; 14 | 15 | namespace caveofprogramming { 16 | 17 | #pragma pack(push, 2) 18 | 19 | struct BitmapFileHeader { 20 | char header[2] { 'B', 'M' }; 21 | int32_t fileSize; 22 | int32_t reserved { 0 }; 23 | int32_t dataOffset; 24 | }; 25 | 26 | #pragma pack(pop) 27 | 28 | } 29 | 30 | #endif /* BITMAPFILEHEADER_H_ */ 31 | -------------------------------------------------------------------------------- /BitmapMemory/src/BitmapInfoHeader.h: -------------------------------------------------------------------------------- 1 | #ifndef BITMAPINFOHEADER_H_ 2 | #define BITMAPINFOHEADER_H_ 3 | 4 | #include 5 | 6 | using namespace std; 7 | 8 | namespace caveofprogramming { 9 | 10 | #pragma pack(push, 2) 11 | 12 | struct BitmapInfoHeader { 13 | int32_t headerSize{40}; 14 | int32_t width; 15 | int32_t height; 16 | int16_t planes{1}; 17 | int16_t bitsPerPixel{24}; 18 | int32_t compression{0}; 19 | int32_t dataSize{0}; 20 | int32_t horizontalResolution{2400}; 21 | int32_t verticalResolution{2400}; 22 | int32_t colors{0}; 23 | int32_t importantColors{0}; 24 | }; 25 | 26 | #pragma pack(pop) 27 | 28 | } 29 | 30 | #endif 31 | -------------------------------------------------------------------------------- /BitmapMemory/src/main.cpp: -------------------------------------------------------------------------------- 1 | //============================================================================ 2 | // Name : Fractal.cpp 3 | // Author : 4 | // Version : 5 | // Copyright : Your copyright notice 6 | // Description : Hello World in C++, Ansi-style 7 | //============================================================================ 8 | 9 | #include 10 | 11 | #include "Bitmap.h" 12 | 13 | using namespace std; 14 | using namespace caveofprogramming; 15 | 16 | int main() { 17 | 18 | Bitmap bitmap(800, 600); 19 | 20 | cout << "!!!Hello World!!!" << endl; // prints !!!Hello World!!! 21 | return 0; 22 | } 23 | -------------------------------------------------------------------------------- /CalculatingRangeTotals/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | set(CMAKE_ARCHIVE_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/lib) 2 | set(CMAKE_LIBRARY_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/lib) 3 | set(CMAKE_RUNTIME_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/bin) 4 | 5 | set (CMAKE_CXX_STANDARD 11) 6 | cmake_minimum_required(VERSION 3.0) 7 | 8 | get_filename_component(ProjectId ${CMAKE_CURRENT_SOURCE_DIR} NAME) 9 | string(REPLACE " " "_" ProjectId ${ProjectId}) 10 | 11 | project(${ProjectId}) 12 | 13 | file(GLOB project_sources src/*.cpp) 14 | file(GLOB project_headers src/*.h src/*.hpp) 15 | 16 | add_executable(${ProjectId} ${project_sources} ${project_headers}) 17 | -------------------------------------------------------------------------------- /CalculatingRangeTotals/src/Bitmap.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Bitmap.h 3 | * 4 | * Created on: Jul 2, 2015 5 | * Author: johnpurcell 6 | */ 7 | 8 | #ifndef BITMAP_H_ 9 | #define BITMAP_H_ 10 | 11 | #include 12 | #include 13 | #include 14 | using namespace std; 15 | 16 | namespace caveofprogramming { 17 | 18 | class Bitmap { 19 | private: 20 | int m_width{0}; 21 | int m_height{0}; 22 | unique_ptr m_pPixels{nullptr}; 23 | 24 | 25 | public: 26 | Bitmap(int width, int height); 27 | void setPixel(int x, int y, uint8_t red, uint8_t green, uint8_t blue); 28 | bool write(string filename); 29 | virtual ~Bitmap(); 30 | }; 31 | 32 | } /* namespace caveofprogramming */ 33 | 34 | #endif /* BITMAP_H_ */ 35 | -------------------------------------------------------------------------------- /CalculatingRangeTotals/src/BitmapFileHeader.h: -------------------------------------------------------------------------------- 1 | /* 2 | * BitmapFileHeader.h 3 | * 4 | * Created on: Jun 21, 2015 5 | * Author: johnpurcell 6 | */ 7 | 8 | #ifndef BITMAPFILEHEADER_H_ 9 | #define BITMAPFILEHEADER_H_ 10 | 11 | #include 12 | 13 | using namespace std; 14 | 15 | namespace caveofprogramming { 16 | 17 | #pragma pack(push, 2) 18 | 19 | struct BitmapFileHeader { 20 | char header[2] { 'B', 'M' }; 21 | int32_t fileSize; 22 | int32_t reserved { 0 }; 23 | int32_t dataOffset; 24 | }; 25 | 26 | #pragma pack(pop) 27 | 28 | } 29 | 30 | #endif /* BITMAPFILEHEADER_H_ */ 31 | -------------------------------------------------------------------------------- /CalculatingRangeTotals/src/BitmapInfoHeader.h: -------------------------------------------------------------------------------- 1 | #ifndef BITMAPINFOHEADER_H_ 2 | #define BITMAPINFOHEADER_H_ 3 | 4 | #include 5 | 6 | using namespace std; 7 | 8 | namespace caveofprogramming { 9 | 10 | #pragma pack(push, 2) 11 | 12 | struct BitmapInfoHeader { 13 | int32_t headerSize{40}; 14 | int32_t width; 15 | int32_t height; 16 | int16_t planes{1}; 17 | int16_t bitsPerPixel{24}; 18 | int32_t compression{0}; 19 | int32_t dataSize{0}; 20 | int32_t horizontalResolution{2400}; 21 | int32_t verticalResolution{2400}; 22 | int32_t colors{0}; 23 | int32_t importantColors{0}; 24 | }; 25 | 26 | #pragma pack(pop) 27 | 28 | } 29 | 30 | #endif 31 | -------------------------------------------------------------------------------- /CalculatingRangeTotals/src/Mandelbrot.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Mandelbrot.h 3 | * 4 | * Created on: Aug 21, 2015 5 | * Author: johnpurcell 6 | */ 7 | 8 | #ifndef MANDELBROT_H_ 9 | #define MANDELBROT_H_ 10 | 11 | namespace caveofprogramming { 12 | 13 | class Mandelbrot { 14 | public: 15 | static const int MAX_ITERATIONS = 1000; 16 | 17 | public: 18 | Mandelbrot(); 19 | virtual ~Mandelbrot(); 20 | 21 | static int getIterations(double x, double y); 22 | }; 23 | 24 | } /* namespace caveofprogramming */ 25 | 26 | #endif /* MANDELBROT_H_ */ 27 | -------------------------------------------------------------------------------- /CalculatingRangeTotals/src/RGB.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | * RGB.cpp 3 | * 4 | * Created on: Sep 21, 2015 5 | * Author: johnpurcell 6 | */ 7 | 8 | #include "RGB.h" 9 | 10 | namespace caveofprogramming { 11 | 12 | RGB::RGB(double r, double g, double b): r(r), g(g), b(b) { 13 | // TODO Auto-generated constructor stub 14 | 15 | } 16 | 17 | RGB operator-(const RGB& first, const RGB& second) { 18 | return RGB(first.r - second.r, first.g - second.g, first.b - second.b); 19 | } 20 | 21 | } /* namespace caveofprogramming */ 22 | -------------------------------------------------------------------------------- /CalculatingRangeTotals/src/RGB.h: -------------------------------------------------------------------------------- 1 | /* 2 | * RGB.h 3 | * 4 | * Created on: Sep 21, 2015 5 | * Author: johnpurcell 6 | */ 7 | 8 | #ifndef RGB_H_ 9 | #define RGB_H_ 10 | 11 | namespace caveofprogramming { 12 | 13 | struct RGB { 14 | double r; 15 | double g; 16 | double b; 17 | 18 | RGB(double r, double g, double b); 19 | }; 20 | 21 | RGB operator-(const RGB& first, const RGB& second); 22 | 23 | } /* namespace caveofprogramming */ 24 | 25 | 26 | 27 | #endif /* RGB_H_ */ 28 | -------------------------------------------------------------------------------- /CalculatingRangeTotals/src/Zoom.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Zoom.h 3 | * 4 | * Created on: Sep 20, 2015 5 | * Author: johnpurcell 6 | */ 7 | 8 | #ifndef ZOOM_H_ 9 | #define ZOOM_H_ 10 | 11 | namespace caveofprogramming { 12 | 13 | struct Zoom { 14 | int x{0}; 15 | int y{0}; 16 | double scale{0.0}; 17 | 18 | Zoom(int x, int y, double scale) : x(x), y(y), scale(scale) {}; 19 | }; 20 | 21 | } /* namespace caveofprogramming */ 22 | 23 | #endif /* ZOOM_H_ */ 24 | -------------------------------------------------------------------------------- /CalculatingRangeTotals/src/ZoomList.h: -------------------------------------------------------------------------------- 1 | /* 2 | * ZoomList.h 3 | * 4 | * Created on: Sep 20, 2015 5 | * Author: johnpurcell 6 | */ 7 | 8 | #ifndef ZOOMLIST_H_ 9 | #define ZOOMLIST_H_ 10 | 11 | #include 12 | #include 13 | #include "Zoom.h" 14 | 15 | using namespace std; 16 | 17 | namespace caveofprogramming { 18 | 19 | class ZoomList { 20 | private: 21 | double m_xCenter{0}; 22 | double m_yCenter{0}; 23 | double m_scale{1.0}; 24 | 25 | int m_width{0}; 26 | int m_height{0}; 27 | vector zooms; 28 | 29 | public: 30 | ZoomList(int width, int height); 31 | void add(const Zoom& zoom); 32 | pair doZoom(int x, int y); 33 | }; 34 | 35 | } /* namespace caveofprogramming */ 36 | 37 | #endif /* ZOOMLIST_H_ */ 38 | -------------------------------------------------------------------------------- /CapturingThisWithLambdas/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | set(CMAKE_ARCHIVE_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/lib) 2 | set(CMAKE_LIBRARY_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/lib) 3 | set(CMAKE_RUNTIME_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/bin) 4 | 5 | set (CMAKE_CXX_STANDARD 11) 6 | cmake_minimum_required(VERSION 3.0) 7 | 8 | get_filename_component(ProjectId ${CMAKE_CURRENT_SOURCE_DIR} NAME) 9 | string(REPLACE " " "_" ProjectId ${ProjectId}) 10 | 11 | project(${ProjectId}) 12 | 13 | file(GLOB project_sources src/*.cpp) 14 | file(GLOB project_headers src/*.h src/*.hpp) 15 | 16 | add_executable(${ProjectId} ${project_sources} ${project_headers}) 17 | -------------------------------------------------------------------------------- /CapturingThisWithLambdas/src/main.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | using namespace std; 4 | 5 | class Test { 6 | private: 7 | int one { 1 }; 8 | int two { 2 }; 9 | 10 | public: 11 | void run() { 12 | int three { 3 }; 13 | int four { 4 }; 14 | 15 | auto pLambda = [&, this]() { 16 | one = 111; 17 | cout << one << endl; 18 | cout << two << endl; 19 | cout << three << endl; 20 | cout << four << endl; 21 | }; 22 | pLambda(); 23 | } 24 | 25 | }; 26 | 27 | int main() { 28 | Test test; 29 | test.run(); 30 | 31 | return 0; 32 | } 33 | -------------------------------------------------------------------------------- /CatchingSubclassExceptions/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | set(CMAKE_ARCHIVE_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/lib) 2 | set(CMAKE_LIBRARY_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/lib) 3 | set(CMAKE_RUNTIME_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/bin) 4 | 5 | set (CMAKE_CXX_STANDARD 11) 6 | cmake_minimum_required(VERSION 3.0) 7 | 8 | get_filename_component(ProjectId ${CMAKE_CURRENT_SOURCE_DIR} NAME) 9 | string(REPLACE " " "_" ProjectId ${ProjectId}) 10 | 11 | project(${ProjectId}) 12 | 13 | file(GLOB project_sources src/*.cpp) 14 | file(GLOB project_headers src/*.h src/*.hpp) 15 | 16 | add_executable(${ProjectId} ${project_sources} ${project_headers}) 17 | -------------------------------------------------------------------------------- /CenteringandScaling/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | set(CMAKE_ARCHIVE_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/lib) 2 | set(CMAKE_LIBRARY_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/lib) 3 | set(CMAKE_RUNTIME_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/bin) 4 | 5 | set (CMAKE_CXX_STANDARD 11) 6 | cmake_minimum_required(VERSION 3.0) 7 | 8 | get_filename_component(ProjectId ${CMAKE_CURRENT_SOURCE_DIR} NAME) 9 | string(REPLACE " " "_" ProjectId ${ProjectId}) 10 | 11 | project(${ProjectId}) 12 | 13 | file(GLOB project_sources src/*.cpp) 14 | file(GLOB project_headers src/*.h src/*.hpp) 15 | 16 | add_executable(${ProjectId} ${project_sources} ${project_headers}) 17 | -------------------------------------------------------------------------------- /CenteringandScaling/src/Bitmap.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Bitmap.h 3 | * 4 | * Created on: Jul 2, 2015 5 | * Author: johnpurcell 6 | */ 7 | 8 | #ifndef BITMAP_H_ 9 | #define BITMAP_H_ 10 | 11 | #include 12 | #include 13 | #include 14 | using namespace std; 15 | 16 | namespace caveofprogramming { 17 | 18 | class Bitmap { 19 | private: 20 | int m_width{0}; 21 | int m_height{0}; 22 | unique_ptr m_pPixels{nullptr}; 23 | 24 | 25 | public: 26 | Bitmap(int width, int height); 27 | void setPixel(int x, int y, uint8_t red, uint8_t green, uint8_t blue); 28 | bool write(string filename); 29 | virtual ~Bitmap(); 30 | }; 31 | 32 | } /* namespace caveofprogramming */ 33 | 34 | #endif /* BITMAP_H_ */ 35 | -------------------------------------------------------------------------------- /CenteringandScaling/src/BitmapFileHeader.h: -------------------------------------------------------------------------------- 1 | /* 2 | * BitmapFileHeader.h 3 | * 4 | * Created on: Jun 21, 2015 5 | * Author: johnpurcell 6 | */ 7 | 8 | #ifndef BITMAPFILEHEADER_H_ 9 | #define BITMAPFILEHEADER_H_ 10 | 11 | #include 12 | 13 | using namespace std; 14 | 15 | namespace caveofprogramming { 16 | 17 | #pragma pack(push, 2) 18 | 19 | struct BitmapFileHeader { 20 | char header[2] { 'B', 'M' }; 21 | int32_t fileSize; 22 | int32_t reserved { 0 }; 23 | int32_t dataOffset; 24 | }; 25 | 26 | #pragma pack(pop) 27 | 28 | } 29 | 30 | #endif /* BITMAPFILEHEADER_H_ */ 31 | -------------------------------------------------------------------------------- /CenteringandScaling/src/BitmapInfoHeader.h: -------------------------------------------------------------------------------- 1 | #ifndef BITMAPINFOHEADER_H_ 2 | #define BITMAPINFOHEADER_H_ 3 | 4 | #include 5 | 6 | using namespace std; 7 | 8 | namespace caveofprogramming { 9 | 10 | #pragma pack(push, 2) 11 | 12 | struct BitmapInfoHeader { 13 | int32_t headerSize{40}; 14 | int32_t width; 15 | int32_t height; 16 | int16_t planes{1}; 17 | int16_t bitsPerPixel{24}; 18 | int32_t compression{0}; 19 | int32_t dataSize{0}; 20 | int32_t horizontalResolution{2400}; 21 | int32_t verticalResolution{2400}; 22 | int32_t colors{0}; 23 | int32_t importantColors{0}; 24 | }; 25 | 26 | #pragma pack(pop) 27 | 28 | } 29 | 30 | #endif 31 | -------------------------------------------------------------------------------- /CenteringandScaling/src/Mandelbrot.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | * Mandelbrot.cpp 3 | * 4 | * Created on: Aug 21, 2015 5 | * Author: johnpurcell 6 | */ 7 | 8 | #include 9 | #include "Mandelbrot.h" 10 | 11 | using namespace std; 12 | 13 | namespace caveofprogramming { 14 | 15 | Mandelbrot::Mandelbrot() { 16 | // TODO Auto-generated constructor stub 17 | 18 | } 19 | 20 | Mandelbrot::~Mandelbrot() { 21 | // TODO Auto-generated destructor stub 22 | } 23 | 24 | int Mandelbrot::getIterations(double x, double y) { 25 | 26 | complex z = 0; 27 | complex c(x, y); 28 | 29 | int iterations = 0; 30 | 31 | while(iterations < MAX_ITERATIONS) { 32 | z = z*z + c; 33 | 34 | if(abs(z) > 2) { 35 | break; 36 | } 37 | 38 | iterations++; 39 | } 40 | 41 | return iterations; 42 | } 43 | 44 | } /* namespace caveofprogramming */ 45 | -------------------------------------------------------------------------------- /CenteringandScaling/src/Mandelbrot.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Mandelbrot.h 3 | * 4 | * Created on: Aug 21, 2015 5 | * Author: johnpurcell 6 | */ 7 | 8 | #ifndef MANDELBROT_H_ 9 | #define MANDELBROT_H_ 10 | 11 | namespace caveofprogramming { 12 | 13 | class Mandelbrot { 14 | public: 15 | static const int MAX_ITERATIONS = 1000; 16 | 17 | public: 18 | Mandelbrot(); 19 | virtual ~Mandelbrot(); 20 | 21 | static int getIterations(double x, double y); 22 | }; 23 | 24 | } /* namespace caveofprogramming */ 25 | 26 | #endif /* MANDELBROT_H_ */ 27 | -------------------------------------------------------------------------------- /CenteringandScaling/src/Zoom.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Zoom.h 3 | * 4 | * Created on: Sep 20, 2015 5 | * Author: johnpurcell 6 | */ 7 | 8 | #ifndef ZOOM_H_ 9 | #define ZOOM_H_ 10 | 11 | namespace caveofprogramming { 12 | 13 | struct Zoom { 14 | int x{0}; 15 | int y{0}; 16 | double scale{0.0}; 17 | 18 | Zoom(int x, int y, double scale) : x(x), y(y), scale(scale) {}; 19 | }; 20 | 21 | } /* namespace caveofprogramming */ 22 | 23 | #endif /* ZOOM_H_ */ 24 | -------------------------------------------------------------------------------- /CenteringandScaling/src/ZoomList.h: -------------------------------------------------------------------------------- 1 | /* 2 | * ZoomList.h 3 | * 4 | * Created on: Sep 20, 2015 5 | * Author: johnpurcell 6 | */ 7 | 8 | #ifndef ZOOMLIST_H_ 9 | #define ZOOMLIST_H_ 10 | 11 | #include 12 | #include 13 | #include "Zoom.h" 14 | 15 | using namespace std; 16 | 17 | namespace caveofprogramming { 18 | 19 | class ZoomList { 20 | private: 21 | double m_xCenter{0}; 22 | double m_yCenter{0}; 23 | double m_scale{1.0}; 24 | 25 | int m_width{0}; 26 | int m_height{0}; 27 | vector zooms; 28 | 29 | public: 30 | ZoomList(int width, int height); 31 | void add(const Zoom& zoom); 32 | pair doZoom(int x, int y); 33 | }; 34 | 35 | } /* namespace caveofprogramming */ 36 | 37 | #endif /* ZOOMLIST_H_ */ 38 | -------------------------------------------------------------------------------- /CheckingtheRangeTotals/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | set(CMAKE_ARCHIVE_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/lib) 2 | set(CMAKE_LIBRARY_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/lib) 3 | set(CMAKE_RUNTIME_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/bin) 4 | 5 | set (CMAKE_CXX_STANDARD 11) 6 | cmake_minimum_required(VERSION 3.0) 7 | 8 | get_filename_component(ProjectId ${CMAKE_CURRENT_SOURCE_DIR} NAME) 9 | string(REPLACE " " "_" ProjectId ${ProjectId}) 10 | 11 | project(${ProjectId}) 12 | 13 | file(GLOB project_sources src/*.cpp) 14 | file(GLOB project_headers src/*.h src/*.hpp) 15 | 16 | add_executable(${ProjectId} ${project_sources} ${project_headers}) 17 | -------------------------------------------------------------------------------- /CheckingtheRangeTotals/src/Bitmap.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Bitmap.h 3 | * 4 | * Created on: Jul 2, 2015 5 | * Author: johnpurcell 6 | */ 7 | 8 | #ifndef BITMAP_H_ 9 | #define BITMAP_H_ 10 | 11 | #include 12 | #include 13 | #include 14 | using namespace std; 15 | 16 | namespace caveofprogramming { 17 | 18 | class Bitmap { 19 | private: 20 | int m_width{0}; 21 | int m_height{0}; 22 | unique_ptr m_pPixels{nullptr}; 23 | 24 | 25 | public: 26 | Bitmap(int width, int height); 27 | void setPixel(int x, int y, uint8_t red, uint8_t green, uint8_t blue); 28 | bool write(string filename); 29 | virtual ~Bitmap(); 30 | }; 31 | 32 | } /* namespace caveofprogramming */ 33 | 34 | #endif /* BITMAP_H_ */ 35 | -------------------------------------------------------------------------------- /CheckingtheRangeTotals/src/BitmapFileHeader.h: -------------------------------------------------------------------------------- 1 | /* 2 | * BitmapFileHeader.h 3 | * 4 | * Created on: Jun 21, 2015 5 | * Author: johnpurcell 6 | */ 7 | 8 | #ifndef BITMAPFILEHEADER_H_ 9 | #define BITMAPFILEHEADER_H_ 10 | 11 | #include 12 | 13 | using namespace std; 14 | 15 | namespace caveofprogramming { 16 | 17 | #pragma pack(push, 2) 18 | 19 | struct BitmapFileHeader { 20 | char header[2] { 'B', 'M' }; 21 | int32_t fileSize; 22 | int32_t reserved { 0 }; 23 | int32_t dataOffset; 24 | }; 25 | 26 | #pragma pack(pop) 27 | 28 | } 29 | 30 | #endif /* BITMAPFILEHEADER_H_ */ 31 | -------------------------------------------------------------------------------- /CheckingtheRangeTotals/src/BitmapInfoHeader.h: -------------------------------------------------------------------------------- 1 | #ifndef BITMAPINFOHEADER_H_ 2 | #define BITMAPINFOHEADER_H_ 3 | 4 | #include 5 | 6 | using namespace std; 7 | 8 | namespace caveofprogramming { 9 | 10 | #pragma pack(push, 2) 11 | 12 | struct BitmapInfoHeader { 13 | int32_t headerSize{40}; 14 | int32_t width; 15 | int32_t height; 16 | int16_t planes{1}; 17 | int16_t bitsPerPixel{24}; 18 | int32_t compression{0}; 19 | int32_t dataSize{0}; 20 | int32_t horizontalResolution{2400}; 21 | int32_t verticalResolution{2400}; 22 | int32_t colors{0}; 23 | int32_t importantColors{0}; 24 | }; 25 | 26 | #pragma pack(pop) 27 | 28 | } 29 | 30 | #endif 31 | -------------------------------------------------------------------------------- /CheckingtheRangeTotals/src/Mandelbrot.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Mandelbrot.h 3 | * 4 | * Created on: Aug 21, 2015 5 | * Author: johnpurcell 6 | */ 7 | 8 | #ifndef MANDELBROT_H_ 9 | #define MANDELBROT_H_ 10 | 11 | namespace caveofprogramming { 12 | 13 | class Mandelbrot { 14 | public: 15 | static const int MAX_ITERATIONS = 1000; 16 | 17 | public: 18 | Mandelbrot(); 19 | virtual ~Mandelbrot(); 20 | 21 | static int getIterations(double x, double y); 22 | }; 23 | 24 | } /* namespace caveofprogramming */ 25 | 26 | #endif /* MANDELBROT_H_ */ 27 | -------------------------------------------------------------------------------- /CheckingtheRangeTotals/src/RGB.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | * RGB.cpp 3 | * 4 | * Created on: Sep 21, 2015 5 | * Author: johnpurcell 6 | */ 7 | 8 | #include "RGB.h" 9 | 10 | namespace caveofprogramming { 11 | 12 | RGB::RGB(double r, double g, double b): r(r), g(g), b(b) { 13 | // TODO Auto-generated constructor stub 14 | 15 | } 16 | 17 | RGB operator-(const RGB& first, const RGB& second) { 18 | return RGB(first.r - second.r, first.g - second.g, first.b - second.b); 19 | } 20 | 21 | } /* namespace caveofprogramming */ 22 | -------------------------------------------------------------------------------- /CheckingtheRangeTotals/src/RGB.h: -------------------------------------------------------------------------------- 1 | /* 2 | * RGB.h 3 | * 4 | * Created on: Sep 21, 2015 5 | * Author: johnpurcell 6 | */ 7 | 8 | #ifndef RGB_H_ 9 | #define RGB_H_ 10 | 11 | namespace caveofprogramming { 12 | 13 | struct RGB { 14 | double r; 15 | double g; 16 | double b; 17 | 18 | RGB(double r, double g, double b); 19 | }; 20 | 21 | RGB operator-(const RGB& first, const RGB& second); 22 | 23 | } /* namespace caveofprogramming */ 24 | 25 | 26 | 27 | #endif /* RGB_H_ */ 28 | -------------------------------------------------------------------------------- /CheckingtheRangeTotals/src/Zoom.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Zoom.h 3 | * 4 | * Created on: Sep 20, 2015 5 | * Author: johnpurcell 6 | */ 7 | 8 | #ifndef ZOOM_H_ 9 | #define ZOOM_H_ 10 | 11 | namespace caveofprogramming { 12 | 13 | struct Zoom { 14 | int x{0}; 15 | int y{0}; 16 | double scale{0.0}; 17 | 18 | Zoom(int x, int y, double scale) : x(x), y(y), scale(scale) {}; 19 | }; 20 | 21 | } /* namespace caveofprogramming */ 22 | 23 | #endif /* ZOOM_H_ */ 24 | -------------------------------------------------------------------------------- /CheckingtheRangeTotals/src/ZoomList.h: -------------------------------------------------------------------------------- 1 | /* 2 | * ZoomList.h 3 | * 4 | * Created on: Sep 20, 2015 5 | * Author: johnpurcell 6 | */ 7 | 8 | #ifndef ZOOMLIST_H_ 9 | #define ZOOMLIST_H_ 10 | 11 | #include 12 | #include 13 | #include "Zoom.h" 14 | 15 | using namespace std; 16 | 17 | namespace caveofprogramming { 18 | 19 | class ZoomList { 20 | private: 21 | double m_xCenter{0}; 22 | double m_yCenter{0}; 23 | double m_scale{1.0}; 24 | 25 | int m_width{0}; 26 | int m_height{0}; 27 | vector zooms; 28 | 29 | public: 30 | ZoomList(int width, int height); 31 | void add(const Zoom& zoom); 32 | pair doZoom(int x, int y); 33 | }; 34 | 35 | } /* namespace caveofprogramming */ 36 | 37 | #endif /* ZOOMLIST_H_ */ 38 | -------------------------------------------------------------------------------- /ColorTransforms/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | set(CMAKE_ARCHIVE_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/lib) 2 | set(CMAKE_LIBRARY_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/lib) 3 | set(CMAKE_RUNTIME_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/bin) 4 | 5 | set (CMAKE_CXX_STANDARD 11) 6 | cmake_minimum_required(VERSION 3.0) 7 | 8 | get_filename_component(ProjectId ${CMAKE_CURRENT_SOURCE_DIR} NAME) 9 | string(REPLACE " " "_" ProjectId ${ProjectId}) 10 | 11 | project(${ProjectId}) 12 | 13 | file(GLOB project_sources src/*.cpp) 14 | file(GLOB project_headers src/*.h src/*.hpp) 15 | 16 | add_executable(${ProjectId} ${project_sources} ${project_headers}) 17 | -------------------------------------------------------------------------------- /ColorTransforms/src/Bitmap.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Bitmap.h 3 | * 4 | * Created on: Jul 2, 2015 5 | * Author: johnpurcell 6 | */ 7 | 8 | #ifndef BITMAP_H_ 9 | #define BITMAP_H_ 10 | 11 | #include 12 | #include 13 | #include 14 | using namespace std; 15 | 16 | namespace caveofprogramming { 17 | 18 | class Bitmap { 19 | private: 20 | int m_width{0}; 21 | int m_height{0}; 22 | unique_ptr m_pPixels{nullptr}; 23 | 24 | 25 | public: 26 | Bitmap(int width, int height); 27 | void setPixel(int x, int y, uint8_t red, uint8_t green, uint8_t blue); 28 | bool write(string filename); 29 | virtual ~Bitmap(); 30 | }; 31 | 32 | } /* namespace caveofprogramming */ 33 | 34 | #endif /* BITMAP_H_ */ 35 | -------------------------------------------------------------------------------- /ColorTransforms/src/BitmapFileHeader.h: -------------------------------------------------------------------------------- 1 | /* 2 | * BitmapFileHeader.h 3 | * 4 | * Created on: Jun 21, 2015 5 | * Author: johnpurcell 6 | */ 7 | 8 | #ifndef BITMAPFILEHEADER_H_ 9 | #define BITMAPFILEHEADER_H_ 10 | 11 | #include 12 | 13 | using namespace std; 14 | 15 | namespace caveofprogramming { 16 | 17 | #pragma pack(push, 2) 18 | 19 | struct BitmapFileHeader { 20 | char header[2] { 'B', 'M' }; 21 | int32_t fileSize; 22 | int32_t reserved { 0 }; 23 | int32_t dataOffset; 24 | }; 25 | 26 | #pragma pack(pop) 27 | 28 | } 29 | 30 | #endif /* BITMAPFILEHEADER_H_ */ 31 | -------------------------------------------------------------------------------- /ColorTransforms/src/BitmapInfoHeader.h: -------------------------------------------------------------------------------- 1 | #ifndef BITMAPINFOHEADER_H_ 2 | #define BITMAPINFOHEADER_H_ 3 | 4 | #include 5 | 6 | using namespace std; 7 | 8 | namespace caveofprogramming { 9 | 10 | #pragma pack(push, 2) 11 | 12 | struct BitmapInfoHeader { 13 | int32_t headerSize{40}; 14 | int32_t width; 15 | int32_t height; 16 | int16_t planes{1}; 17 | int16_t bitsPerPixel{24}; 18 | int32_t compression{0}; 19 | int32_t dataSize{0}; 20 | int32_t horizontalResolution{2400}; 21 | int32_t verticalResolution{2400}; 22 | int32_t colors{0}; 23 | int32_t importantColors{0}; 24 | }; 25 | 26 | #pragma pack(pop) 27 | 28 | } 29 | 30 | #endif 31 | -------------------------------------------------------------------------------- /ColorTransforms/src/Mandelbrot.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | * Mandelbrot.cpp 3 | * 4 | * Created on: Aug 21, 2015 5 | * Author: johnpurcell 6 | */ 7 | 8 | #include 9 | #include "Mandelbrot.h" 10 | 11 | using namespace std; 12 | 13 | namespace caveofprogramming { 14 | 15 | Mandelbrot::Mandelbrot() { 16 | // TODO Auto-generated constructor stub 17 | 18 | } 19 | 20 | Mandelbrot::~Mandelbrot() { 21 | // TODO Auto-generated destructor stub 22 | } 23 | 24 | int Mandelbrot::getIterations(double x, double y) { 25 | 26 | complex z = 0; 27 | complex c(x, y); 28 | 29 | int iterations = 0; 30 | 31 | while(iterations < MAX_ITERATIONS) { 32 | z = z*z + c; 33 | 34 | if(abs(z) > 2) { 35 | break; 36 | } 37 | 38 | iterations++; 39 | } 40 | 41 | return iterations; 42 | } 43 | 44 | } /* namespace caveofprogramming */ 45 | -------------------------------------------------------------------------------- /ColorTransforms/src/Mandelbrot.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Mandelbrot.h 3 | * 4 | * Created on: Aug 21, 2015 5 | * Author: johnpurcell 6 | */ 7 | 8 | #ifndef MANDELBROT_H_ 9 | #define MANDELBROT_H_ 10 | 11 | namespace caveofprogramming { 12 | 13 | class Mandelbrot { 14 | public: 15 | static const int MAX_ITERATIONS = 1000; 16 | 17 | public: 18 | Mandelbrot(); 19 | virtual ~Mandelbrot(); 20 | 21 | static int getIterations(double x, double y); 22 | }; 23 | 24 | } /* namespace caveofprogramming */ 25 | 26 | #endif /* MANDELBROT_H_ */ 27 | -------------------------------------------------------------------------------- /ColourHistograms/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | set(CMAKE_ARCHIVE_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/lib) 2 | set(CMAKE_LIBRARY_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/lib) 3 | set(CMAKE_RUNTIME_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/bin) 4 | 5 | set (CMAKE_CXX_STANDARD 11) 6 | cmake_minimum_required(VERSION 3.0) 7 | 8 | get_filename_component(ProjectId ${CMAKE_CURRENT_SOURCE_DIR} NAME) 9 | string(REPLACE " " "_" ProjectId ${ProjectId}) 10 | 11 | project(${ProjectId}) 12 | 13 | file(GLOB project_sources src/*.cpp) 14 | file(GLOB project_headers src/*.h src/*.hpp) 15 | 16 | add_executable(${ProjectId} ${project_sources} ${project_headers}) 17 | -------------------------------------------------------------------------------- /ColourHistograms/src/Bitmap.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Bitmap.h 3 | * 4 | * Created on: Jul 2, 2015 5 | * Author: johnpurcell 6 | */ 7 | 8 | #ifndef BITMAP_H_ 9 | #define BITMAP_H_ 10 | 11 | #include 12 | #include 13 | #include 14 | using namespace std; 15 | 16 | namespace caveofprogramming { 17 | 18 | class Bitmap { 19 | private: 20 | int m_width{0}; 21 | int m_height{0}; 22 | unique_ptr m_pPixels{nullptr}; 23 | 24 | 25 | public: 26 | Bitmap(int width, int height); 27 | void setPixel(int x, int y, uint8_t red, uint8_t green, uint8_t blue); 28 | bool write(string filename); 29 | virtual ~Bitmap(); 30 | }; 31 | 32 | } /* namespace caveofprogramming */ 33 | 34 | #endif /* BITMAP_H_ */ 35 | -------------------------------------------------------------------------------- /ColourHistograms/src/BitmapFileHeader.h: -------------------------------------------------------------------------------- 1 | /* 2 | * BitmapFileHeader.h 3 | * 4 | * Created on: Jun 21, 2015 5 | * Author: johnpurcell 6 | */ 7 | 8 | #ifndef BITMAPFILEHEADER_H_ 9 | #define BITMAPFILEHEADER_H_ 10 | 11 | #include 12 | 13 | using namespace std; 14 | 15 | namespace caveofprogramming { 16 | 17 | #pragma pack(push, 2) 18 | 19 | struct BitmapFileHeader { 20 | char header[2] { 'B', 'M' }; 21 | int32_t fileSize; 22 | int32_t reserved { 0 }; 23 | int32_t dataOffset; 24 | }; 25 | 26 | #pragma pack(pop) 27 | 28 | } 29 | 30 | #endif /* BITMAPFILEHEADER_H_ */ 31 | -------------------------------------------------------------------------------- /ColourHistograms/src/BitmapInfoHeader.h: -------------------------------------------------------------------------------- 1 | #ifndef BITMAPINFOHEADER_H_ 2 | #define BITMAPINFOHEADER_H_ 3 | 4 | #include 5 | 6 | using namespace std; 7 | 8 | namespace caveofprogramming { 9 | 10 | #pragma pack(push, 2) 11 | 12 | struct BitmapInfoHeader { 13 | int32_t headerSize{40}; 14 | int32_t width; 15 | int32_t height; 16 | int16_t planes{1}; 17 | int16_t bitsPerPixel{24}; 18 | int32_t compression{0}; 19 | int32_t dataSize{0}; 20 | int32_t horizontalResolution{2400}; 21 | int32_t verticalResolution{2400}; 22 | int32_t colors{0}; 23 | int32_t importantColors{0}; 24 | }; 25 | 26 | #pragma pack(pop) 27 | 28 | } 29 | 30 | #endif 31 | -------------------------------------------------------------------------------- /ColourHistograms/src/Mandelbrot.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | * Mandelbrot.cpp 3 | * 4 | * Created on: Aug 21, 2015 5 | * Author: johnpurcell 6 | */ 7 | 8 | #include 9 | #include "Mandelbrot.h" 10 | 11 | using namespace std; 12 | 13 | namespace caveofprogramming { 14 | 15 | Mandelbrot::Mandelbrot() { 16 | // TODO Auto-generated constructor stub 17 | 18 | } 19 | 20 | Mandelbrot::~Mandelbrot() { 21 | // TODO Auto-generated destructor stub 22 | } 23 | 24 | int Mandelbrot::getIterations(double x, double y) { 25 | 26 | complex z = 0; 27 | complex c(x, y); 28 | 29 | int iterations = 0; 30 | 31 | while(iterations < MAX_ITERATIONS) { 32 | z = z*z + c; 33 | 34 | if(abs(z) > 2) { 35 | break; 36 | } 37 | 38 | iterations++; 39 | } 40 | 41 | return iterations; 42 | } 43 | 44 | } /* namespace caveofprogramming */ 45 | -------------------------------------------------------------------------------- /ColourHistograms/src/Mandelbrot.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Mandelbrot.h 3 | * 4 | * Created on: Aug 21, 2015 5 | * Author: johnpurcell 6 | */ 7 | 8 | #ifndef MANDELBROT_H_ 9 | #define MANDELBROT_H_ 10 | 11 | namespace caveofprogramming { 12 | 13 | class Mandelbrot { 14 | public: 15 | static const int MAX_ITERATIONS = 1000; 16 | 17 | public: 18 | Mandelbrot(); 19 | virtual ~Mandelbrot(); 20 | 21 | static int getIterations(double x, double y); 22 | }; 23 | 24 | } /* namespace caveofprogramming */ 25 | 26 | #endif /* MANDELBROT_H_ */ 27 | -------------------------------------------------------------------------------- /Complex Numbers Overview.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/caveofprogramming/advanced-cplusplus/18f1d43d68c41b9e543d5350e9c47967b671d22a/Complex Numbers Overview.pdf -------------------------------------------------------------------------------- /ConstructorsandMemory/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | set(CMAKE_ARCHIVE_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/lib) 2 | set(CMAKE_LIBRARY_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/lib) 3 | set(CMAKE_RUNTIME_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/bin) 4 | 5 | set (CMAKE_CXX_STANDARD 11) 6 | cmake_minimum_required(VERSION 3.0) 7 | 8 | get_filename_component(ProjectId ${CMAKE_CURRENT_SOURCE_DIR} NAME) 9 | string(REPLACE " " "_" ProjectId ${ProjectId}) 10 | 11 | project(${ProjectId}) 12 | 13 | file(GLOB project_sources src/*.cpp) 14 | file(GLOB project_headers src/*.h src/*.hpp) 15 | 16 | add_executable(${ProjectId} ${project_sources} ${project_headers}) 17 | -------------------------------------------------------------------------------- /CustomExceptions/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | set(CMAKE_ARCHIVE_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/lib) 2 | set(CMAKE_LIBRARY_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/lib) 3 | set(CMAKE_RUNTIME_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/bin) 4 | 5 | set (CMAKE_CXX_STANDARD 11) 6 | cmake_minimum_required(VERSION 3.0) 7 | 8 | get_filename_component(ProjectId ${CMAKE_CURRENT_SOURCE_DIR} NAME) 9 | string(REPLACE " " "_" ProjectId ${ProjectId}) 10 | 11 | project(${ProjectId}) 12 | 13 | file(GLOB project_sources src/*.cpp) 14 | file(GLOB project_headers src/*.h src/*.hpp) 15 | 16 | add_executable(${ProjectId} ${project_sources} ${project_headers}) 17 | -------------------------------------------------------------------------------- /CustomObjectsAsMapKeys/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | set(CMAKE_ARCHIVE_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/lib) 2 | set(CMAKE_LIBRARY_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/lib) 3 | set(CMAKE_RUNTIME_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/bin) 4 | 5 | set (CMAKE_CXX_STANDARD 11) 6 | cmake_minimum_required(VERSION 3.0) 7 | 8 | get_filename_component(ProjectId ${CMAKE_CURRENT_SOURCE_DIR} NAME) 9 | string(REPLACE " " "_" ProjectId ${ProjectId}) 10 | 11 | project(${ProjectId}) 12 | 13 | file(GLOB project_sources src/*.cpp) 14 | file(GLOB project_headers src/*.h src/*.hpp) 15 | 16 | add_executable(${ProjectId} ${project_sources} ${project_headers}) 17 | -------------------------------------------------------------------------------- /CustomObjectsAsMapValues/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | set(CMAKE_ARCHIVE_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/lib) 2 | set(CMAKE_LIBRARY_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/lib) 3 | set(CMAKE_RUNTIME_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/bin) 4 | 5 | set (CMAKE_CXX_STANDARD 11) 6 | cmake_minimum_required(VERSION 3.0) 7 | 8 | get_filename_component(ProjectId ${CMAKE_CURRENT_SOURCE_DIR} NAME) 9 | string(REPLACE " " "_" ProjectId ${ProjectId}) 10 | 11 | project(${ProjectId}) 12 | 13 | file(GLOB project_sources src/*.cpp) 14 | file(GLOB project_headers src/*.h src/*.hpp) 15 | 16 | add_executable(${ProjectId} ${project_sources} ${project_headers}) 17 | -------------------------------------------------------------------------------- /DecltypeAndTypeid/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | set(CMAKE_ARCHIVE_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/lib) 2 | set(CMAKE_LIBRARY_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/lib) 3 | set(CMAKE_RUNTIME_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/bin) 4 | 5 | set (CMAKE_CXX_STANDARD 11) 6 | cmake_minimum_required(VERSION 3.0) 7 | 8 | get_filename_component(ProjectId ${CMAKE_CURRENT_SOURCE_DIR} NAME) 9 | string(REPLACE " " "_" ProjectId ${ProjectId}) 10 | 11 | project(${ProjectId}) 12 | 13 | file(GLOB project_sources src/*.cpp) 14 | file(GLOB project_headers src/*.h src/*.hpp) 15 | 16 | add_executable(${ProjectId} ${project_sources} ${project_headers}) 17 | -------------------------------------------------------------------------------- /DelegatingConctructors/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | set(CMAKE_ARCHIVE_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/lib) 2 | set(CMAKE_LIBRARY_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/lib) 3 | set(CMAKE_RUNTIME_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/bin) 4 | 5 | set (CMAKE_CXX_STANDARD 11) 6 | cmake_minimum_required(VERSION 3.0) 7 | 8 | get_filename_component(ProjectId ${CMAKE_CURRENT_SOURCE_DIR} NAME) 9 | string(REPLACE " " "_" ProjectId ${ProjectId}) 10 | 11 | project(${ProjectId}) 12 | 13 | file(GLOB project_sources src/*.cpp) 14 | file(GLOB project_headers src/*.h src/*.hpp) 15 | 16 | add_executable(${ProjectId} ${project_sources} ${project_headers}) 17 | -------------------------------------------------------------------------------- /DynamicCasts/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | set(CMAKE_ARCHIVE_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/lib) 2 | set(CMAKE_LIBRARY_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/lib) 3 | set(CMAKE_RUNTIME_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/bin) 4 | 5 | set (CMAKE_CXX_STANDARD 11) 6 | cmake_minimum_required(VERSION 3.0) 7 | 8 | get_filename_component(ProjectId ${CMAKE_CURRENT_SOURCE_DIR} NAME) 9 | string(REPLACE " " "_" ProjectId ${ProjectId}) 10 | 11 | project(${ProjectId}) 12 | 13 | file(GLOB project_sources src/*.cpp) 14 | file(GLOB project_headers src/*.h src/*.hpp) 15 | 16 | add_executable(${ProjectId} ${project_sources} ${project_headers}) 17 | -------------------------------------------------------------------------------- /EliminatingMaxIterations/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | set(CMAKE_ARCHIVE_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/lib) 2 | set(CMAKE_LIBRARY_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/lib) 3 | set(CMAKE_RUNTIME_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/bin) 4 | 5 | set (CMAKE_CXX_STANDARD 11) 6 | cmake_minimum_required(VERSION 3.0) 7 | 8 | get_filename_component(ProjectId ${CMAKE_CURRENT_SOURCE_DIR} NAME) 9 | string(REPLACE " " "_" ProjectId ${ProjectId}) 10 | 11 | project(${ProjectId}) 12 | 13 | file(GLOB project_sources src/*.cpp) 14 | file(GLOB project_headers src/*.h src/*.hpp) 15 | 16 | add_executable(${ProjectId} ${project_sources} ${project_headers}) 17 | -------------------------------------------------------------------------------- /EliminatingMaxIterations/src/Bitmap.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Bitmap.h 3 | * 4 | * Created on: Jul 2, 2015 5 | * Author: johnpurcell 6 | */ 7 | 8 | #ifndef BITMAP_H_ 9 | #define BITMAP_H_ 10 | 11 | #include 12 | #include 13 | #include 14 | using namespace std; 15 | 16 | namespace caveofprogramming { 17 | 18 | class Bitmap { 19 | private: 20 | int m_width{0}; 21 | int m_height{0}; 22 | unique_ptr m_pPixels{nullptr}; 23 | 24 | 25 | public: 26 | Bitmap(int width, int height); 27 | void setPixel(int x, int y, uint8_t red, uint8_t green, uint8_t blue); 28 | bool write(string filename); 29 | virtual ~Bitmap(); 30 | }; 31 | 32 | } /* namespace caveofprogramming */ 33 | 34 | #endif /* BITMAP_H_ */ 35 | -------------------------------------------------------------------------------- /EliminatingMaxIterations/src/BitmapFileHeader.h: -------------------------------------------------------------------------------- 1 | /* 2 | * BitmapFileHeader.h 3 | * 4 | * Created on: Jun 21, 2015 5 | * Author: johnpurcell 6 | */ 7 | 8 | #ifndef BITMAPFILEHEADER_H_ 9 | #define BITMAPFILEHEADER_H_ 10 | 11 | #include 12 | 13 | using namespace std; 14 | 15 | namespace caveofprogramming { 16 | 17 | #pragma pack(push, 2) 18 | 19 | struct BitmapFileHeader { 20 | char header[2] { 'B', 'M' }; 21 | int32_t fileSize; 22 | int32_t reserved { 0 }; 23 | int32_t dataOffset; 24 | }; 25 | 26 | #pragma pack(pop) 27 | 28 | } 29 | 30 | #endif /* BITMAPFILEHEADER_H_ */ 31 | -------------------------------------------------------------------------------- /EliminatingMaxIterations/src/BitmapInfoHeader.h: -------------------------------------------------------------------------------- 1 | #ifndef BITMAPINFOHEADER_H_ 2 | #define BITMAPINFOHEADER_H_ 3 | 4 | #include 5 | 6 | using namespace std; 7 | 8 | namespace caveofprogramming { 9 | 10 | #pragma pack(push, 2) 11 | 12 | struct BitmapInfoHeader { 13 | int32_t headerSize{40}; 14 | int32_t width; 15 | int32_t height; 16 | int16_t planes{1}; 17 | int16_t bitsPerPixel{24}; 18 | int32_t compression{0}; 19 | int32_t dataSize{0}; 20 | int32_t horizontalResolution{2400}; 21 | int32_t verticalResolution{2400}; 22 | int32_t colors{0}; 23 | int32_t importantColors{0}; 24 | }; 25 | 26 | #pragma pack(pop) 27 | 28 | } 29 | 30 | #endif 31 | -------------------------------------------------------------------------------- /EliminatingMaxIterations/src/Mandelbrot.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Mandelbrot.h 3 | * 4 | * Created on: Aug 21, 2015 5 | * Author: johnpurcell 6 | */ 7 | 8 | #ifndef MANDELBROT_H_ 9 | #define MANDELBROT_H_ 10 | 11 | namespace caveofprogramming { 12 | 13 | class Mandelbrot { 14 | public: 15 | static const int MAX_ITERATIONS = 1000; 16 | 17 | public: 18 | Mandelbrot(); 19 | virtual ~Mandelbrot(); 20 | 21 | static int getIterations(double x, double y); 22 | }; 23 | 24 | } /* namespace caveofprogramming */ 25 | 26 | #endif /* MANDELBROT_H_ */ 27 | -------------------------------------------------------------------------------- /ElisionandOptimization/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | set(CMAKE_ARCHIVE_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/lib) 2 | set(CMAKE_LIBRARY_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/lib) 3 | set(CMAKE_RUNTIME_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/bin) 4 | 5 | set (CMAKE_CXX_STANDARD 11) 6 | cmake_minimum_required(VERSION 3.0) 7 | 8 | get_filename_component(ProjectId ${CMAKE_CURRENT_SOURCE_DIR} NAME) 9 | string(REPLACE " " "_" ProjectId ${ProjectId}) 10 | 11 | project(${ProjectId}) 12 | 13 | file(GLOB project_sources src/*.cpp) 14 | file(GLOB project_headers src/*.h src/*.hpp) 15 | 16 | add_executable(${ProjectId} ${project_sources} ${project_headers}) 17 | -------------------------------------------------------------------------------- /EnhancedForLoop/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | set(CMAKE_ARCHIVE_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/lib) 2 | set(CMAKE_LIBRARY_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/lib) 3 | set(CMAKE_RUNTIME_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/bin) 4 | 5 | set (CMAKE_CXX_STANDARD 11) 6 | cmake_minimum_required(VERSION 3.0) 7 | 8 | get_filename_component(ProjectId ${CMAKE_CURRENT_SOURCE_DIR} NAME) 9 | string(REPLACE " " "_" ProjectId ${ProjectId}) 10 | 11 | project(${ProjectId}) 12 | 13 | file(GLOB project_sources src/*.cpp) 14 | file(GLOB project_headers src/*.h src/*.hpp) 15 | 16 | add_executable(${ProjectId} ${project_sources} ${project_headers}) 17 | -------------------------------------------------------------------------------- /FractalCreatorHelloWorld/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | set(CMAKE_ARCHIVE_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/lib) 2 | set(CMAKE_LIBRARY_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/lib) 3 | set(CMAKE_RUNTIME_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/bin) 4 | 5 | set (CMAKE_CXX_STANDARD 11) 6 | cmake_minimum_required(VERSION 3.0) 7 | 8 | get_filename_component(ProjectId ${CMAKE_CURRENT_SOURCE_DIR} NAME) 9 | string(REPLACE " " "_" ProjectId ${ProjectId}) 10 | 11 | project(${ProjectId}) 12 | 13 | file(GLOB project_sources src/*.cpp) 14 | file(GLOB project_headers src/*.h src/*.hpp) 15 | 16 | add_executable(${ProjectId} ${project_sources} ${project_headers}) 17 | -------------------------------------------------------------------------------- /FractalCreatorHelloWorld/src/FractalCreatorHelloWorld.cpp: -------------------------------------------------------------------------------- 1 | //============================================================================ 2 | // Name : Fractal.cpp 3 | // Author : 4 | // Version : 5 | // Copyright : Your copyright notice 6 | // Description : Hello World in C++, Ansi-style 7 | //============================================================================ 8 | 9 | #include 10 | using namespace std; 11 | 12 | int main() { 13 | cout << "!!!Hello World!!!" << endl; // prints !!!Hello World!!! 14 | return 0; 15 | } 16 | -------------------------------------------------------------------------------- /FunctionPointers/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | set(CMAKE_ARCHIVE_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/lib) 2 | set(CMAKE_LIBRARY_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/lib) 3 | set(CMAKE_RUNTIME_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/bin) 4 | 5 | set (CMAKE_CXX_STANDARD 11) 6 | cmake_minimum_required(VERSION 3.0) 7 | 8 | get_filename_component(ProjectId ${CMAKE_CURRENT_SOURCE_DIR} NAME) 9 | string(REPLACE " " "_" ProjectId ${ProjectId}) 10 | 11 | project(${ProjectId}) 12 | 13 | file(GLOB project_sources src/*.cpp) 14 | file(GLOB project_headers src/*.h src/*.hpp) 15 | 16 | add_executable(${ProjectId} ${project_sources} ${project_headers}) 17 | -------------------------------------------------------------------------------- /FunctionPointers/src/FunctionPointers.cpp: -------------------------------------------------------------------------------- 1 | //============================================================================ 2 | // Name : Function.cpp 3 | // Author : 4 | // Version : 5 | // Copyright : Your copyright notice 6 | // Description : Hello World in C++, Ansi-style 7 | //============================================================================ 8 | 9 | #include 10 | 11 | using namespace std; 12 | 13 | void test(int value) { 14 | cout << "Hello: " << value << endl; 15 | } 16 | 17 | int main() { 18 | test(7); 19 | 20 | void (*pTest)(int) = test; 21 | 22 | pTest(8); 23 | 24 | 25 | 26 | return 0; 27 | } 28 | -------------------------------------------------------------------------------- /FunctionalTypes/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | set(CMAKE_ARCHIVE_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/lib) 2 | set(CMAKE_LIBRARY_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/lib) 3 | set(CMAKE_RUNTIME_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/bin) 4 | 5 | set (CMAKE_CXX_STANDARD 11) 6 | cmake_minimum_required(VERSION 3.0) 7 | 8 | get_filename_component(ProjectId ${CMAKE_CURRENT_SOURCE_DIR} NAME) 9 | string(REPLACE " " "_" ProjectId ${ProjectId}) 10 | 11 | project(${ProjectId}) 12 | 13 | file(GLOB project_sources src/*.cpp) 14 | file(GLOB project_headers src/*.h src/*.hpp) 15 | 16 | add_executable(${ProjectId} ${project_sources} ${project_headers}) 17 | -------------------------------------------------------------------------------- /Functors/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | set(CMAKE_ARCHIVE_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/lib) 2 | set(CMAKE_LIBRARY_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/lib) 3 | set(CMAKE_RUNTIME_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/bin) 4 | 5 | set (CMAKE_CXX_STANDARD 11) 6 | cmake_minimum_required(VERSION 3.0) 7 | 8 | get_filename_component(ProjectId ${CMAKE_CURRENT_SOURCE_DIR} NAME) 9 | string(REPLACE " " "_" ProjectId ${ProjectId}) 10 | 11 | project(${ProjectId}) 12 | 13 | file(GLOB project_sources src/*.cpp) 14 | file(GLOB project_headers src/*.h src/*.hpp) 15 | 16 | add_executable(${ProjectId} ${project_sources} ${project_headers}) 17 | -------------------------------------------------------------------------------- /GettingPixelRanges/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | set(CMAKE_ARCHIVE_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/lib) 2 | set(CMAKE_LIBRARY_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/lib) 3 | set(CMAKE_RUNTIME_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/bin) 4 | 5 | set (CMAKE_CXX_STANDARD 11) 6 | cmake_minimum_required(VERSION 3.0) 7 | 8 | get_filename_component(ProjectId ${CMAKE_CURRENT_SOURCE_DIR} NAME) 9 | string(REPLACE " " "_" ProjectId ${ProjectId}) 10 | 11 | project(${ProjectId}) 12 | 13 | file(GLOB project_sources src/*.cpp) 14 | file(GLOB project_headers src/*.h src/*.hpp) 15 | 16 | add_executable(${ProjectId} ${project_sources} ${project_headers}) 17 | -------------------------------------------------------------------------------- /GettingPixelRanges/src/Bitmap.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Bitmap.h 3 | * 4 | * Created on: Jul 2, 2015 5 | * Author: johnpurcell 6 | */ 7 | 8 | #ifndef BITMAP_H_ 9 | #define BITMAP_H_ 10 | 11 | #include 12 | #include 13 | #include 14 | using namespace std; 15 | 16 | namespace caveofprogramming { 17 | 18 | class Bitmap { 19 | private: 20 | int m_width{0}; 21 | int m_height{0}; 22 | unique_ptr m_pPixels{nullptr}; 23 | 24 | 25 | public: 26 | Bitmap(int width, int height); 27 | void setPixel(int x, int y, uint8_t red, uint8_t green, uint8_t blue); 28 | bool write(string filename); 29 | virtual ~Bitmap(); 30 | }; 31 | 32 | } /* namespace caveofprogramming */ 33 | 34 | #endif /* BITMAP_H_ */ 35 | -------------------------------------------------------------------------------- /GettingPixelRanges/src/BitmapFileHeader.h: -------------------------------------------------------------------------------- 1 | /* 2 | * BitmapFileHeader.h 3 | * 4 | * Created on: Jun 21, 2015 5 | * Author: johnpurcell 6 | */ 7 | 8 | #ifndef BITMAPFILEHEADER_H_ 9 | #define BITMAPFILEHEADER_H_ 10 | 11 | #include 12 | 13 | using namespace std; 14 | 15 | namespace caveofprogramming { 16 | 17 | #pragma pack(push, 2) 18 | 19 | struct BitmapFileHeader { 20 | char header[2] { 'B', 'M' }; 21 | int32_t fileSize; 22 | int32_t reserved { 0 }; 23 | int32_t dataOffset; 24 | }; 25 | 26 | #pragma pack(pop) 27 | 28 | } 29 | 30 | #endif /* BITMAPFILEHEADER_H_ */ 31 | -------------------------------------------------------------------------------- /GettingPixelRanges/src/BitmapInfoHeader.h: -------------------------------------------------------------------------------- 1 | #ifndef BITMAPINFOHEADER_H_ 2 | #define BITMAPINFOHEADER_H_ 3 | 4 | #include 5 | 6 | using namespace std; 7 | 8 | namespace caveofprogramming { 9 | 10 | #pragma pack(push, 2) 11 | 12 | struct BitmapInfoHeader { 13 | int32_t headerSize{40}; 14 | int32_t width; 15 | int32_t height; 16 | int16_t planes{1}; 17 | int16_t bitsPerPixel{24}; 18 | int32_t compression{0}; 19 | int32_t dataSize{0}; 20 | int32_t horizontalResolution{2400}; 21 | int32_t verticalResolution{2400}; 22 | int32_t colors{0}; 23 | int32_t importantColors{0}; 24 | }; 25 | 26 | #pragma pack(pop) 27 | 28 | } 29 | 30 | #endif 31 | -------------------------------------------------------------------------------- /GettingPixelRanges/src/Mandelbrot.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | * Mandelbrot.cpp 3 | * 4 | * Created on: Aug 21, 2015 5 | * Author: johnpurcell 6 | */ 7 | 8 | #include 9 | #include "Mandelbrot.h" 10 | 11 | using namespace std; 12 | 13 | namespace caveofprogramming { 14 | 15 | Mandelbrot::Mandelbrot() { 16 | // TODO Auto-generated constructor stub 17 | 18 | } 19 | 20 | Mandelbrot::~Mandelbrot() { 21 | // TODO Auto-generated destructor stub 22 | } 23 | 24 | int Mandelbrot::getIterations(double x, double y) { 25 | 26 | complex z = 0; 27 | complex c(x, y); 28 | 29 | int iterations = 0; 30 | 31 | while(iterations < MAX_ITERATIONS) { 32 | z = z*z + c; 33 | 34 | if(abs(z) > 2) { 35 | break; 36 | } 37 | 38 | iterations++; 39 | } 40 | 41 | return iterations; 42 | } 43 | 44 | } /* namespace caveofprogramming */ 45 | -------------------------------------------------------------------------------- /GettingPixelRanges/src/Mandelbrot.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Mandelbrot.h 3 | * 4 | * Created on: Aug 21, 2015 5 | * Author: johnpurcell 6 | */ 7 | 8 | #ifndef MANDELBROT_H_ 9 | #define MANDELBROT_H_ 10 | 11 | namespace caveofprogramming { 12 | 13 | class Mandelbrot { 14 | public: 15 | static const int MAX_ITERATIONS = 1000; 16 | 17 | public: 18 | Mandelbrot(); 19 | virtual ~Mandelbrot(); 20 | 21 | static int getIterations(double x, double y); 22 | }; 23 | 24 | } /* namespace caveofprogramming */ 25 | 26 | #endif /* MANDELBROT_H_ */ 27 | -------------------------------------------------------------------------------- /GettingPixelRanges/src/RGB.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | * RGB.cpp 3 | * 4 | * Created on: Sep 21, 2015 5 | * Author: johnpurcell 6 | */ 7 | 8 | #include "RGB.h" 9 | 10 | namespace caveofprogramming { 11 | 12 | RGB::RGB(double r, double g, double b): r(r), g(g), b(b) { 13 | // TODO Auto-generated constructor stub 14 | 15 | } 16 | 17 | RGB operator-(const RGB& first, const RGB& second) { 18 | return RGB(first.r - second.r, first.g - second.g, first.b - second.b); 19 | } 20 | 21 | } /* namespace caveofprogramming */ 22 | -------------------------------------------------------------------------------- /GettingPixelRanges/src/RGB.h: -------------------------------------------------------------------------------- 1 | /* 2 | * RGB.h 3 | * 4 | * Created on: Sep 21, 2015 5 | * Author: johnpurcell 6 | */ 7 | 8 | #ifndef RGB_H_ 9 | #define RGB_H_ 10 | 11 | namespace caveofprogramming { 12 | 13 | struct RGB { 14 | double r; 15 | double g; 16 | double b; 17 | 18 | RGB(double r, double g, double b); 19 | }; 20 | 21 | RGB operator-(const RGB& first, const RGB& second); 22 | 23 | } /* namespace caveofprogramming */ 24 | 25 | 26 | 27 | #endif /* RGB_H_ */ 28 | -------------------------------------------------------------------------------- /GettingPixelRanges/src/Zoom.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Zoom.h 3 | * 4 | * Created on: Sep 20, 2015 5 | * Author: johnpurcell 6 | */ 7 | 8 | #ifndef ZOOM_H_ 9 | #define ZOOM_H_ 10 | 11 | namespace caveofprogramming { 12 | 13 | struct Zoom { 14 | int x{0}; 15 | int y{0}; 16 | double scale{0.0}; 17 | 18 | Zoom(int x, int y, double scale) : x(x), y(y), scale(scale) {}; 19 | }; 20 | 21 | } /* namespace caveofprogramming */ 22 | 23 | #endif /* ZOOM_H_ */ 24 | -------------------------------------------------------------------------------- /GettingPixelRanges/src/ZoomList.h: -------------------------------------------------------------------------------- 1 | /* 2 | * ZoomList.h 3 | * 4 | * Created on: Sep 20, 2015 5 | * Author: johnpurcell 6 | */ 7 | 8 | #ifndef ZOOMLIST_H_ 9 | #define ZOOMLIST_H_ 10 | 11 | #include 12 | #include 13 | #include "Zoom.h" 14 | 15 | using namespace std; 16 | 17 | namespace caveofprogramming { 18 | 19 | class ZoomList { 20 | private: 21 | double m_xCenter{0}; 22 | double m_yCenter{0}; 23 | double m_scale{1.0}; 24 | 25 | int m_width{0}; 26 | int m_height{0}; 27 | vector zooms; 28 | 29 | public: 30 | ZoomList(int width, int height); 31 | void add(const Zoom& zoom); 32 | pair doZoom(int x, int y); 33 | }; 34 | 35 | } /* namespace caveofprogramming */ 36 | 37 | #endif /* ZOOMLIST_H_ */ 38 | -------------------------------------------------------------------------------- /HelloWorld/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | set(CMAKE_ARCHIVE_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/lib) 2 | set(CMAKE_LIBRARY_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/lib) 3 | set(CMAKE_RUNTIME_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/bin) 4 | 5 | set (CMAKE_CXX_STANDARD 11) 6 | cmake_minimum_required(VERSION 3.0) 7 | 8 | get_filename_component(ProjectId ${CMAKE_CURRENT_SOURCE_DIR} NAME) 9 | string(REPLACE " " "_" ProjectId ${ProjectId}) 10 | 11 | project(${ProjectId}) 12 | 13 | file(GLOB project_sources src/*.cpp) 14 | file(GLOB project_headers src/*.h src/*.hpp) 15 | 16 | add_executable(${ProjectId} ${project_sources} ${project_headers}) 17 | -------------------------------------------------------------------------------- /HelloWorld/src/main.cpp: -------------------------------------------------------------------------------- 1 | //============================================================================ 2 | // Name : 3 | // Author : John Purcell 4 | // Version : 5 | // Copyright : Your copyright notice 6 | // Description : Hello World in C++, Ansi-style 7 | //============================================================================ 8 | 9 | #include 10 | 11 | using namespace std; 12 | 13 | int main() { 14 | cout << "Hello World" << endl; 15 | 16 | return 0; 17 | } 18 | -------------------------------------------------------------------------------- /ImplementingFractalCreator/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | set(CMAKE_ARCHIVE_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/lib) 2 | set(CMAKE_LIBRARY_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/lib) 3 | set(CMAKE_RUNTIME_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/bin) 4 | 5 | set (CMAKE_CXX_STANDARD 11) 6 | cmake_minimum_required(VERSION 3.0) 7 | 8 | get_filename_component(ProjectId ${CMAKE_CURRENT_SOURCE_DIR} NAME) 9 | string(REPLACE " " "_" ProjectId ${ProjectId}) 10 | 11 | project(${ProjectId}) 12 | 13 | file(GLOB project_sources src/*.cpp) 14 | file(GLOB project_headers src/*.h src/*.hpp) 15 | 16 | add_executable(${ProjectId} ${project_sources} ${project_headers}) 17 | -------------------------------------------------------------------------------- /ImplementingFractalCreator/src/Bitmap.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Bitmap.h 3 | * 4 | * Created on: Jul 2, 2015 5 | * Author: johnpurcell 6 | */ 7 | 8 | #ifndef BITMAP_H_ 9 | #define BITMAP_H_ 10 | 11 | #include 12 | #include 13 | #include 14 | using namespace std; 15 | 16 | namespace caveofprogramming { 17 | 18 | class Bitmap { 19 | private: 20 | int m_width{0}; 21 | int m_height{0}; 22 | unique_ptr m_pPixels{nullptr}; 23 | 24 | 25 | public: 26 | Bitmap(int width, int height); 27 | void setPixel(int x, int y, uint8_t red, uint8_t green, uint8_t blue); 28 | bool write(string filename); 29 | virtual ~Bitmap(); 30 | }; 31 | 32 | } /* namespace caveofprogramming */ 33 | 34 | #endif /* BITMAP_H_ */ 35 | -------------------------------------------------------------------------------- /ImplementingFractalCreator/src/BitmapFileHeader.h: -------------------------------------------------------------------------------- 1 | /* 2 | * BitmapFileHeader.h 3 | * 4 | * Created on: Jun 21, 2015 5 | * Author: johnpurcell 6 | */ 7 | 8 | #ifndef BITMAPFILEHEADER_H_ 9 | #define BITMAPFILEHEADER_H_ 10 | 11 | #include 12 | 13 | using namespace std; 14 | 15 | namespace caveofprogramming { 16 | 17 | #pragma pack(push, 2) 18 | 19 | struct BitmapFileHeader { 20 | char header[2] { 'B', 'M' }; 21 | int32_t fileSize; 22 | int32_t reserved { 0 }; 23 | int32_t dataOffset; 24 | }; 25 | 26 | #pragma pack(pop) 27 | 28 | } 29 | 30 | #endif /* BITMAPFILEHEADER_H_ */ 31 | -------------------------------------------------------------------------------- /ImplementingFractalCreator/src/BitmapInfoHeader.h: -------------------------------------------------------------------------------- 1 | #ifndef BITMAPINFOHEADER_H_ 2 | #define BITMAPINFOHEADER_H_ 3 | 4 | #include 5 | 6 | using namespace std; 7 | 8 | namespace caveofprogramming { 9 | 10 | #pragma pack(push, 2) 11 | 12 | struct BitmapInfoHeader { 13 | int32_t headerSize{40}; 14 | int32_t width; 15 | int32_t height; 16 | int16_t planes{1}; 17 | int16_t bitsPerPixel{24}; 18 | int32_t compression{0}; 19 | int32_t dataSize{0}; 20 | int32_t horizontalResolution{2400}; 21 | int32_t verticalResolution{2400}; 22 | int32_t colors{0}; 23 | int32_t importantColors{0}; 24 | }; 25 | 26 | #pragma pack(pop) 27 | 28 | } 29 | 30 | #endif 31 | -------------------------------------------------------------------------------- /ImplementingFractalCreator/src/Mandelbrot.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Mandelbrot.h 3 | * 4 | * Created on: Aug 21, 2015 5 | * Author: johnpurcell 6 | */ 7 | 8 | #ifndef MANDELBROT_H_ 9 | #define MANDELBROT_H_ 10 | 11 | namespace caveofprogramming { 12 | 13 | class Mandelbrot { 14 | public: 15 | static const int MAX_ITERATIONS = 1000; 16 | 17 | public: 18 | Mandelbrot(); 19 | virtual ~Mandelbrot(); 20 | 21 | static int getIterations(double x, double y); 22 | }; 23 | 24 | } /* namespace caveofprogramming */ 25 | 26 | #endif /* MANDELBROT_H_ */ 27 | -------------------------------------------------------------------------------- /ImplementingFractalCreator/src/Zoom.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Zoom.h 3 | * 4 | * Created on: Sep 20, 2015 5 | * Author: johnpurcell 6 | */ 7 | 8 | #ifndef ZOOM_H_ 9 | #define ZOOM_H_ 10 | 11 | namespace caveofprogramming { 12 | 13 | struct Zoom { 14 | int x{0}; 15 | int y{0}; 16 | double scale{0.0}; 17 | 18 | Zoom(int x, int y, double scale) : x(x), y(y), scale(scale) {}; 19 | }; 20 | 21 | } /* namespace caveofprogramming */ 22 | 23 | #endif /* ZOOM_H_ */ 24 | -------------------------------------------------------------------------------- /ImplementingFractalCreator/src/ZoomList.h: -------------------------------------------------------------------------------- 1 | /* 2 | * ZoomList.h 3 | * 4 | * Created on: Sep 20, 2015 5 | * Author: johnpurcell 6 | */ 7 | 8 | #ifndef ZOOMLIST_H_ 9 | #define ZOOMLIST_H_ 10 | 11 | #include 12 | #include 13 | #include "Zoom.h" 14 | 15 | using namespace std; 16 | 17 | namespace caveofprogramming { 18 | 19 | class ZoomList { 20 | private: 21 | double m_xCenter{0}; 22 | double m_yCenter{0}; 23 | double m_scale{1.0}; 24 | 25 | int m_width{0}; 26 | int m_height{0}; 27 | vector zooms; 28 | 29 | public: 30 | ZoomList(int width, int height); 31 | void add(const Zoom& zoom); 32 | pair doZoom(int x, int y); 33 | }; 34 | 35 | } /* namespace caveofprogramming */ 36 | 37 | #endif /* ZOOMLIST_H_ */ 38 | -------------------------------------------------------------------------------- /ImprovingtheBasicFractal/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | set(CMAKE_ARCHIVE_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/lib) 2 | set(CMAKE_LIBRARY_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/lib) 3 | set(CMAKE_RUNTIME_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/bin) 4 | 5 | set (CMAKE_CXX_STANDARD 11) 6 | cmake_minimum_required(VERSION 3.0) 7 | 8 | get_filename_component(ProjectId ${CMAKE_CURRENT_SOURCE_DIR} NAME) 9 | string(REPLACE " " "_" ProjectId ${ProjectId}) 10 | 11 | project(${ProjectId}) 12 | 13 | file(GLOB project_sources src/*.cpp) 14 | file(GLOB project_headers src/*.h src/*.hpp) 15 | 16 | add_executable(${ProjectId} ${project_sources} ${project_headers}) 17 | -------------------------------------------------------------------------------- /ImprovingtheBasicFractal/src/Bitmap.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Bitmap.h 3 | * 4 | * Created on: Jul 2, 2015 5 | * Author: johnpurcell 6 | */ 7 | 8 | #ifndef BITMAP_H_ 9 | #define BITMAP_H_ 10 | 11 | #include 12 | #include 13 | #include 14 | using namespace std; 15 | 16 | namespace caveofprogramming { 17 | 18 | class Bitmap { 19 | private: 20 | int m_width{0}; 21 | int m_height{0}; 22 | unique_ptr m_pPixels{nullptr}; 23 | 24 | 25 | public: 26 | Bitmap(int width, int height); 27 | void setPixel(int x, int y, uint8_t red, uint8_t green, uint8_t blue); 28 | bool write(string filename); 29 | virtual ~Bitmap(); 30 | }; 31 | 32 | } /* namespace caveofprogramming */ 33 | 34 | #endif /* BITMAP_H_ */ 35 | -------------------------------------------------------------------------------- /ImprovingtheBasicFractal/src/BitmapFileHeader.h: -------------------------------------------------------------------------------- 1 | /* 2 | * BitmapFileHeader.h 3 | * 4 | * Created on: Jun 21, 2015 5 | * Author: johnpurcell 6 | */ 7 | 8 | #ifndef BITMAPFILEHEADER_H_ 9 | #define BITMAPFILEHEADER_H_ 10 | 11 | #include 12 | 13 | using namespace std; 14 | 15 | namespace caveofprogramming { 16 | 17 | #pragma pack(push, 2) 18 | 19 | struct BitmapFileHeader { 20 | char header[2] { 'B', 'M' }; 21 | int32_t fileSize; 22 | int32_t reserved { 0 }; 23 | int32_t dataOffset; 24 | }; 25 | 26 | #pragma pack(pop) 27 | 28 | } 29 | 30 | #endif /* BITMAPFILEHEADER_H_ */ 31 | -------------------------------------------------------------------------------- /ImprovingtheBasicFractal/src/BitmapInfoHeader.h: -------------------------------------------------------------------------------- 1 | #ifndef BITMAPINFOHEADER_H_ 2 | #define BITMAPINFOHEADER_H_ 3 | 4 | #include 5 | 6 | using namespace std; 7 | 8 | namespace caveofprogramming { 9 | 10 | #pragma pack(push, 2) 11 | 12 | struct BitmapInfoHeader { 13 | int32_t headerSize{40}; 14 | int32_t width; 15 | int32_t height; 16 | int16_t planes{1}; 17 | int16_t bitsPerPixel{24}; 18 | int32_t compression{0}; 19 | int32_t dataSize{0}; 20 | int32_t horizontalResolution{2400}; 21 | int32_t verticalResolution{2400}; 22 | int32_t colors{0}; 23 | int32_t importantColors{0}; 24 | }; 25 | 26 | #pragma pack(pop) 27 | 28 | } 29 | 30 | #endif 31 | -------------------------------------------------------------------------------- /ImprovingtheBasicFractal/src/Mandelbrot.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Mandelbrot.h 3 | * 4 | * Created on: Aug 21, 2015 5 | * Author: johnpurcell 6 | */ 7 | 8 | #ifndef MANDELBROT_H_ 9 | #define MANDELBROT_H_ 10 | 11 | namespace caveofprogramming { 12 | 13 | class Mandelbrot { 14 | public: 15 | static const int MAX_ITERATIONS = 1000; 16 | 17 | public: 18 | Mandelbrot(); 19 | virtual ~Mandelbrot(); 20 | 21 | static int getIterations(double x, double y); 22 | }; 23 | 24 | } /* namespace caveofprogramming */ 25 | 26 | #endif /* MANDELBROT_H_ */ 27 | -------------------------------------------------------------------------------- /InitializationInC11/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | set(CMAKE_ARCHIVE_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/lib) 2 | set(CMAKE_LIBRARY_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/lib) 3 | set(CMAKE_RUNTIME_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/bin) 4 | 5 | set (CMAKE_CXX_STANDARD 11) 6 | cmake_minimum_required(VERSION 3.0) 7 | 8 | get_filename_component(ProjectId ${CMAKE_CURRENT_SOURCE_DIR} NAME) 9 | string(REPLACE " " "_" ProjectId ${ProjectId}) 10 | 11 | project(${ProjectId}) 12 | 13 | file(GLOB project_sources src/*.cpp) 14 | file(GLOB project_headers src/*.h src/*.hpp) 15 | 16 | add_executable(${ProjectId} ${project_sources} ${project_headers}) 17 | -------------------------------------------------------------------------------- /InitializationInC98/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | set(CMAKE_ARCHIVE_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/lib) 2 | set(CMAKE_LIBRARY_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/lib) 3 | set(CMAKE_RUNTIME_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/bin) 4 | 5 | set (CMAKE_CXX_STANDARD 11) 6 | cmake_minimum_required(VERSION 3.0) 7 | 8 | get_filename_component(ProjectId ${CMAKE_CURRENT_SOURCE_DIR} NAME) 9 | string(REPLACE " " "_" ProjectId ${ProjectId}) 10 | 11 | project(${ProjectId}) 12 | 13 | file(GLOB project_sources src/*.cpp) 14 | file(GLOB project_headers src/*.h src/*.hpp) 15 | 16 | add_executable(${ProjectId} ${project_sources} ${project_headers}) 17 | -------------------------------------------------------------------------------- /InitializerLists/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | set(CMAKE_ARCHIVE_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/lib) 2 | set(CMAKE_LIBRARY_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/lib) 3 | set(CMAKE_RUNTIME_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/bin) 4 | 5 | set (CMAKE_CXX_STANDARD 11) 6 | cmake_minimum_required(VERSION 3.0) 7 | 8 | get_filename_component(ProjectId ${CMAKE_CURRENT_SOURCE_DIR} NAME) 9 | string(REPLACE " " "_" ProjectId ${ProjectId}) 10 | 11 | project(${ProjectId}) 12 | 13 | file(GLOB project_sources src/*.cpp) 14 | file(GLOB project_headers src/*.h src/*.hpp) 15 | 16 | add_executable(${ProjectId} ${project_sources} ${project_headers}) 17 | -------------------------------------------------------------------------------- /IterableClasses/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | set(CMAKE_ARCHIVE_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/lib) 2 | set(CMAKE_LIBRARY_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/lib) 3 | set(CMAKE_RUNTIME_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/bin) 4 | 5 | set (CMAKE_CXX_STANDARD 11) 6 | cmake_minimum_required(VERSION 3.0) 7 | 8 | get_filename_component(ProjectId ${CMAKE_CURRENT_SOURCE_DIR} NAME) 9 | string(REPLACE " " "_" ProjectId ${ProjectId}) 10 | 11 | project(${ProjectId}) 12 | 13 | file(GLOB project_sources src/*.cpp) 14 | file(GLOB project_headers src/*.h src/*.hpp) 15 | 16 | add_executable(${ProjectId} ${project_sources} ${project_headers}) 17 | -------------------------------------------------------------------------------- /LValueReferences/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | set(CMAKE_ARCHIVE_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/lib) 2 | set(CMAKE_LIBRARY_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/lib) 3 | set(CMAKE_RUNTIME_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/bin) 4 | 5 | set (CMAKE_CXX_STANDARD 11) 6 | cmake_minimum_required(VERSION 3.0) 7 | 8 | get_filename_component(ProjectId ${CMAKE_CURRENT_SOURCE_DIR} NAME) 9 | string(REPLACE " " "_" ProjectId ${ProjectId}) 10 | 11 | project(${ProjectId}) 12 | 13 | file(GLOB project_sources src/*.cpp) 14 | file(GLOB project_headers src/*.h src/*.hpp) 15 | 16 | add_executable(${ProjectId} ${project_sources} ${project_headers}) 17 | -------------------------------------------------------------------------------- /LambdaCaptureExpressions/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | set(CMAKE_ARCHIVE_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/lib) 2 | set(CMAKE_LIBRARY_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/lib) 3 | set(CMAKE_RUNTIME_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/bin) 4 | 5 | set (CMAKE_CXX_STANDARD 11) 6 | cmake_minimum_required(VERSION 3.0) 7 | 8 | get_filename_component(ProjectId ${CMAKE_CURRENT_SOURCE_DIR} NAME) 9 | string(REPLACE " " "_" ProjectId ${ProjectId}) 10 | 11 | project(${ProjectId}) 12 | 13 | file(GLOB project_sources src/*.cpp) 14 | file(GLOB project_headers src/*.h src/*.hpp) 15 | 16 | add_executable(${ProjectId} ${project_sources} ${project_headers}) 17 | -------------------------------------------------------------------------------- /LambdaExpressions/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | set(CMAKE_ARCHIVE_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/lib) 2 | set(CMAKE_LIBRARY_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/lib) 3 | set(CMAKE_RUNTIME_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/bin) 4 | 5 | set (CMAKE_CXX_STANDARD 11) 6 | cmake_minimum_required(VERSION 3.0) 7 | 8 | get_filename_component(ProjectId ${CMAKE_CURRENT_SOURCE_DIR} NAME) 9 | string(REPLACE " " "_" ProjectId ${ProjectId}) 10 | 11 | project(${ProjectId}) 12 | 13 | file(GLOB project_sources src/*.cpp) 14 | file(GLOB project_headers src/*.h src/*.hpp) 15 | 16 | add_executable(${ProjectId} ${project_sources} ${project_headers}) 17 | -------------------------------------------------------------------------------- /LambdaExpressions/src/LambdaExpressions.cpp: -------------------------------------------------------------------------------- 1 | //============================================================================ 2 | // Name : Elision.cpp 3 | // Author : 4 | // Version : 5 | // Copyright : Your copyright notice 6 | // Description : Hello World in C++, Ansi-style 7 | //============================================================================ 8 | 9 | #include 10 | 11 | using namespace std; 12 | 13 | void test(void (*pFunc)()) 14 | { 15 | pFunc(); 16 | } 17 | 18 | int main() { 19 | 20 | auto func = []() 21 | { 22 | cout << "Hello" << endl; 23 | }; 24 | 25 | func(); 26 | 27 | test(func); 28 | 29 | test([]() {cout << "Hello again" << endl; }); 30 | return 0; 31 | } 32 | -------------------------------------------------------------------------------- /LambdaParametersAndReturnTypes/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | set(CMAKE_ARCHIVE_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/lib) 2 | set(CMAKE_LIBRARY_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/lib) 3 | set(CMAKE_RUNTIME_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/bin) 4 | 5 | set (CMAKE_CXX_STANDARD 11) 6 | cmake_minimum_required(VERSION 3.0) 7 | 8 | get_filename_component(ProjectId ${CMAKE_CURRENT_SOURCE_DIR} NAME) 9 | string(REPLACE " " "_" ProjectId ${ProjectId}) 10 | 11 | project(${ProjectId}) 12 | 13 | file(GLOB project_sources src/*.cpp) 14 | file(GLOB project_headers src/*.h src/*.hpp) 15 | 16 | add_executable(${ProjectId} ${project_sources} ${project_headers}) 17 | -------------------------------------------------------------------------------- /Lists/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | set(CMAKE_ARCHIVE_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/lib) 2 | set(CMAKE_LIBRARY_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/lib) 3 | set(CMAKE_RUNTIME_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/bin) 4 | 5 | set (CMAKE_CXX_STANDARD 11) 6 | cmake_minimum_required(VERSION 3.0) 7 | 8 | get_filename_component(ProjectId ${CMAKE_CURRENT_SOURCE_DIR} NAME) 9 | string(REPLACE " " "_" ProjectId ${ProjectId}) 10 | 11 | project(${ProjectId}) 12 | 13 | file(GLOB project_sources src/*.cpp) 14 | file(GLOB project_headers src/*.h src/*.hpp) 15 | 16 | add_executable(${ProjectId} ${project_sources} ${project_headers}) 17 | -------------------------------------------------------------------------------- /Maps/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | set(CMAKE_ARCHIVE_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/lib) 2 | set(CMAKE_LIBRARY_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/lib) 3 | set(CMAKE_RUNTIME_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/bin) 4 | 5 | set (CMAKE_CXX_STANDARD 11) 6 | cmake_minimum_required(VERSION 3.0) 7 | 8 | get_filename_component(ProjectId ${CMAKE_CURRENT_SOURCE_DIR} NAME) 9 | string(REPLACE " " "_" ProjectId ${ProjectId}) 10 | 11 | project(${ProjectId}) 12 | 13 | file(GLOB project_sources src/*.cpp) 14 | file(GLOB project_headers src/*.h src/*.hpp) 15 | 16 | add_executable(${ProjectId} ${project_sources} ${project_headers}) 17 | -------------------------------------------------------------------------------- /MoveAssignmentOperators/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | set(CMAKE_ARCHIVE_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/lib) 2 | set(CMAKE_LIBRARY_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/lib) 3 | set(CMAKE_RUNTIME_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/bin) 4 | 5 | set (CMAKE_CXX_STANDARD 11) 6 | cmake_minimum_required(VERSION 3.0) 7 | 8 | get_filename_component(ProjectId ${CMAKE_CURRENT_SOURCE_DIR} NAME) 9 | string(REPLACE " " "_" ProjectId ${ProjectId}) 10 | 11 | project(${ProjectId}) 12 | 13 | file(GLOB project_sources src/*.cpp) 14 | file(GLOB project_headers src/*.h src/*.hpp) 15 | 16 | add_executable(${ProjectId} ${project_sources} ${project_headers}) 17 | -------------------------------------------------------------------------------- /MoveConstructors/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | set(CMAKE_ARCHIVE_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/lib) 2 | set(CMAKE_LIBRARY_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/lib) 3 | set(CMAKE_RUNTIME_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/bin) 4 | 5 | set (CMAKE_CXX_STANDARD 11) 6 | cmake_minimum_required(VERSION 3.0) 7 | 8 | get_filename_component(ProjectId ${CMAKE_CURRENT_SOURCE_DIR} NAME) 9 | string(REPLACE " " "_" ProjectId ${ProjectId}) 10 | 11 | project(${ProjectId}) 12 | 13 | file(GLOB project_sources src/*.cpp) 14 | file(GLOB project_headers src/*.h src/*.hpp) 15 | 16 | add_executable(${ProjectId} ${project_sources} ${project_headers}) 17 | -------------------------------------------------------------------------------- /MultipleInheritance/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | set(CMAKE_ARCHIVE_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/lib) 2 | set(CMAKE_LIBRARY_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/lib) 3 | set(CMAKE_RUNTIME_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/bin) 4 | 5 | set (CMAKE_CXX_STANDARD 11) 6 | cmake_minimum_required(VERSION 3.0) 7 | 8 | get_filename_component(ProjectId ${CMAKE_CURRENT_SOURCE_DIR} NAME) 9 | string(REPLACE " " "_" ProjectId ${ProjectId}) 10 | 11 | project(${ProjectId}) 12 | 13 | file(GLOB project_sources src/*.cpp) 14 | file(GLOB project_headers src/*.h src/*.hpp) 15 | 16 | add_executable(${ProjectId} ${project_sources} ${project_headers}) 17 | -------------------------------------------------------------------------------- /MutableLambdas/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | set(CMAKE_ARCHIVE_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/lib) 2 | set(CMAKE_LIBRARY_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/lib) 3 | set(CMAKE_RUNTIME_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/bin) 4 | 5 | set (CMAKE_CXX_STANDARD 11) 6 | cmake_minimum_required(VERSION 3.0) 7 | 8 | get_filename_component(ProjectId ${CMAKE_CURRENT_SOURCE_DIR} NAME) 9 | string(REPLACE " " "_" ProjectId ${ProjectId}) 10 | 11 | project(${ProjectId}) 12 | 13 | file(GLOB project_sources src/*.cpp) 14 | file(GLOB project_headers src/*.h src/*.hpp) 15 | 16 | add_executable(${ProjectId} ${project_sources} ${project_headers}) 17 | -------------------------------------------------------------------------------- /MutableLambdas/src/MutableLambdas.cpp: -------------------------------------------------------------------------------- 1 | //============================================================================ 2 | // Name : Mutable.cpp 3 | // Author : John Purcell 4 | // Version : 5 | // Copyright : Your copyright notice 6 | // Description : Hello World in C++, Ansi-style 7 | //============================================================================ 8 | 9 | #include 10 | using namespace std; 11 | 12 | int main() { 13 | 14 | int cats = 5; 15 | 16 | [cats]() mutable { 17 | cats = 8; 18 | cout << cats << endl; 19 | }(); 20 | 21 | cout << cats << endl; 22 | 23 | return 0; 24 | } 25 | -------------------------------------------------------------------------------- /NestedTemplateClasses/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | set(CMAKE_ARCHIVE_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/lib) 2 | set(CMAKE_LIBRARY_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/lib) 3 | set(CMAKE_RUNTIME_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/bin) 4 | 5 | set (CMAKE_CXX_STANDARD 11) 6 | cmake_minimum_required(VERSION 3.0) 7 | 8 | get_filename_component(ProjectId ${CMAKE_CURRENT_SOURCE_DIR} NAME) 9 | string(REPLACE " " "_" ProjectId ${ProjectId}) 10 | 11 | project(${ProjectId}) 12 | 13 | file(GLOB project_sources src/*.cpp) 14 | file(GLOB project_headers src/*.h src/*.hpp) 15 | 16 | add_executable(${ProjectId} ${project_sources} ${project_headers}) 17 | -------------------------------------------------------------------------------- /ObjectInitialization/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | set(CMAKE_ARCHIVE_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/lib) 2 | set(CMAKE_LIBRARY_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/lib) 3 | set(CMAKE_RUNTIME_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/bin) 4 | 5 | set (CMAKE_CXX_STANDARD 11) 6 | cmake_minimum_required(VERSION 3.0) 7 | 8 | get_filename_component(ProjectId ${CMAKE_CURRENT_SOURCE_DIR} NAME) 9 | string(REPLACE " " "_" ProjectId ${ProjectId}) 10 | 11 | project(${ProjectId}) 12 | 13 | file(GLOB project_sources src/*.cpp) 14 | file(GLOB project_headers src/*.h src/*.hpp) 15 | 16 | add_executable(${ProjectId} ${project_sources} ${project_headers}) 17 | -------------------------------------------------------------------------------- /ObjectSlicingandPolymorphism/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | set(CMAKE_ARCHIVE_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/lib) 2 | set(CMAKE_LIBRARY_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/lib) 3 | set(CMAKE_RUNTIME_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/bin) 4 | 5 | set (CMAKE_CXX_STANDARD 11) 6 | cmake_minimum_required(VERSION 3.0) 7 | 8 | get_filename_component(ProjectId ${CMAKE_CURRENT_SOURCE_DIR} NAME) 9 | string(REPLACE " " "_" ProjectId ${ProjectId}) 10 | 11 | project(${ProjectId}) 12 | 13 | file(GLOB project_sources src/*.cpp) 14 | file(GLOB project_headers src/*.h src/*.hpp) 15 | 16 | add_executable(${ProjectId} ${project_sources} ${project_headers}) 17 | -------------------------------------------------------------------------------- /OverloadingComparisonOperators/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | set(CMAKE_ARCHIVE_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/lib) 2 | set(CMAKE_LIBRARY_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/lib) 3 | set(CMAKE_RUNTIME_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/bin) 4 | 5 | set (CMAKE_CXX_STANDARD 11) 6 | cmake_minimum_required(VERSION 3.0) 7 | 8 | get_filename_component(ProjectId ${CMAKE_CURRENT_SOURCE_DIR} NAME) 9 | string(REPLACE " " "_" ProjectId ${ProjectId}) 10 | 11 | project(${ProjectId}) 12 | 13 | file(GLOB project_sources src/*.cpp) 14 | file(GLOB project_headers src/*.h src/*.hpp) 15 | 16 | add_executable(${ProjectId} ${project_sources} ${project_headers}) 17 | -------------------------------------------------------------------------------- /OverloadingPlus/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | set(CMAKE_ARCHIVE_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/lib) 2 | set(CMAKE_LIBRARY_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/lib) 3 | set(CMAKE_RUNTIME_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/bin) 4 | 5 | set (CMAKE_CXX_STANDARD 11) 6 | cmake_minimum_required(VERSION 3.0) 7 | 8 | get_filename_component(ProjectId ${CMAKE_CURRENT_SOURCE_DIR} NAME) 9 | string(REPLACE " " "_" ProjectId ${ProjectId}) 10 | 11 | project(${ProjectId}) 12 | 13 | file(GLOB project_sources src/*.cpp) 14 | file(GLOB project_headers src/*.h src/*.hpp) 15 | 16 | add_executable(${ProjectId} ${project_sources} ${project_headers}) 17 | -------------------------------------------------------------------------------- /OverloadingtheAssignmentOperator/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | set(CMAKE_ARCHIVE_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/lib) 2 | set(CMAKE_LIBRARY_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/lib) 3 | set(CMAKE_RUNTIME_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/bin) 4 | 5 | set (CMAKE_CXX_STANDARD 11) 6 | cmake_minimum_required(VERSION 3.0) 7 | 8 | get_filename_component(ProjectId ${CMAKE_CURRENT_SOURCE_DIR} NAME) 9 | string(REPLACE " " "_" ProjectId ${ProjectId}) 10 | 11 | project(${ProjectId}) 12 | 13 | file(GLOB project_sources src/*.cpp) 14 | file(GLOB project_headers src/*.h src/*.hpp) 15 | 16 | add_executable(${ProjectId} ${project_sources} ${project_headers}) 17 | -------------------------------------------------------------------------------- /OverloadingtheDereferenceOperator/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | set(CMAKE_ARCHIVE_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/lib) 2 | set(CMAKE_LIBRARY_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/lib) 3 | set(CMAKE_RUNTIME_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/bin) 4 | 5 | set (CMAKE_CXX_STANDARD 11) 6 | cmake_minimum_required(VERSION 3.0) 7 | 8 | get_filename_component(ProjectId ${CMAKE_CURRENT_SOURCE_DIR} NAME) 9 | string(REPLACE " " "_" ProjectId ${ProjectId}) 10 | 11 | project(${ProjectId}) 12 | 13 | file(GLOB project_sources src/*.cpp) 14 | file(GLOB project_headers src/*.h src/*.hpp) 15 | 16 | add_executable(${ProjectId} ${project_sources} ${project_headers}) 17 | -------------------------------------------------------------------------------- /OverloadingtheDereferenceOperator/src/Overloading the Dereference Operator.cpp: -------------------------------------------------------------------------------- 1 | //============================================================================ 2 | // Name : Overloading.cpp 3 | // Author : 4 | // Version : 5 | // Copyright : Your copyright notice 6 | // Description : Hello World in C++, Ansi-style 7 | //============================================================================ 8 | 9 | #include 10 | #include "Complex.h" 11 | using namespace std; 12 | using namespace caveofprogramming; 13 | 14 | int main() { 15 | 16 | Complex c1(2, 4); 17 | 18 | cout << *c1 + *Complex(4, 3) << endl; 19 | 20 | return 0; 21 | } 22 | -------------------------------------------------------------------------------- /OverloadingtheInsertionOperatorforPrinting/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | set(CMAKE_ARCHIVE_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/lib) 2 | set(CMAKE_LIBRARY_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/lib) 3 | set(CMAKE_RUNTIME_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/bin) 4 | 5 | set (CMAKE_CXX_STANDARD 11) 6 | cmake_minimum_required(VERSION 3.0) 7 | 8 | get_filename_component(ProjectId ${CMAKE_CURRENT_SOURCE_DIR} NAME) 9 | string(REPLACE " " "_" ProjectId ${ProjectId}) 10 | 11 | project(${ProjectId}) 12 | 13 | file(GLOB project_sources src/*.cpp) 14 | file(GLOB project_headers src/*.h src/*.hpp) 15 | 16 | add_executable(${ProjectId} ${project_sources} ${project_headers}) 17 | -------------------------------------------------------------------------------- /OverloadingtheLeftBitShiftOperator/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | set(CMAKE_ARCHIVE_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/lib) 2 | set(CMAKE_LIBRARY_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/lib) 3 | set(CMAKE_RUNTIME_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/bin) 4 | 5 | set (CMAKE_CXX_STANDARD 11) 6 | cmake_minimum_required(VERSION 3.0) 7 | 8 | get_filename_component(ProjectId ${CMAKE_CURRENT_SOURCE_DIR} NAME) 9 | string(REPLACE " " "_" ProjectId ${ProjectId}) 10 | 11 | project(${ProjectId}) 12 | 13 | file(GLOB project_sources src/*.cpp) 14 | file(GLOB project_headers src/*.h src/*.hpp) 15 | 16 | add_executable(${ProjectId} ${project_sources} ${project_headers}) 17 | -------------------------------------------------------------------------------- /ParsingTextinFiles/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | set(CMAKE_ARCHIVE_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/lib) 2 | set(CMAKE_LIBRARY_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/lib) 3 | set(CMAKE_RUNTIME_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/bin) 4 | 5 | set (CMAKE_CXX_STANDARD 11) 6 | cmake_minimum_required(VERSION 3.0) 7 | 8 | get_filename_component(ProjectId ${CMAKE_CURRENT_SOURCE_DIR} NAME) 9 | string(REPLACE " " "_" ProjectId ${ProjectId}) 10 | 11 | project(${ProjectId}) 12 | 13 | file(GLOB project_sources src/*.cpp) 14 | file(GLOB project_headers src/*.h src/*.hpp) 15 | 16 | add_executable(${ProjectId} ${project_sources} ${project_headers}) 17 | -------------------------------------------------------------------------------- /ParsingTextinFiles/stats.txt: -------------------------------------------------------------------------------- 1 | Population UK: 64000000 2 | Population France: 66400000 3 | -------------------------------------------------------------------------------- /PerfectForwarding/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | set(CMAKE_ARCHIVE_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/lib) 2 | set(CMAKE_LIBRARY_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/lib) 3 | set(CMAKE_RUNTIME_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/bin) 4 | 5 | set (CMAKE_CXX_STANDARD 11) 6 | cmake_minimum_required(VERSION 3.0) 7 | 8 | get_filename_component(ProjectId ${CMAKE_CURRENT_SOURCE_DIR} NAME) 9 | string(REPLACE " " "_" ProjectId ${ProjectId}) 10 | 11 | project(${ProjectId}) 12 | 13 | file(GLOB project_sources src/*.cpp) 14 | file(GLOB project_headers src/*.h src/*.hpp) 15 | 16 | add_executable(${ProjectId} ${project_sources} ${project_headers}) 17 | -------------------------------------------------------------------------------- /PerfectForwarding/src/Perfect Forwarding.cpp: -------------------------------------------------------------------------------- 1 | //============================================================================ 2 | // Name : Perfect.cpp 3 | // Author : 4 | // Version : 5 | // Copyright : Your copyright notice 6 | // Description : Hello World in C++, Ansi-style 7 | //============================================================================ 8 | 9 | #include 10 | using namespace std; 11 | 12 | class Test { 13 | 14 | }; 15 | 16 | template 17 | void call(T &&arg) { 18 | check(forward(arg)); 19 | } 20 | 21 | void check(Test &test) { 22 | cout << "lvalue" << endl; 23 | } 24 | 25 | void check(Test &&test) { 26 | cout << "rvalue" << endl; 27 | } 28 | 29 | int main() { 30 | 31 | Test test; 32 | 33 | call(test); 34 | 35 | return 0; 36 | } 37 | -------------------------------------------------------------------------------- /RangeBasedColoring/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | set(CMAKE_ARCHIVE_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/lib) 2 | set(CMAKE_LIBRARY_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/lib) 3 | set(CMAKE_RUNTIME_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/bin) 4 | 5 | set (CMAKE_CXX_STANDARD 11) 6 | cmake_minimum_required(VERSION 3.0) 7 | 8 | get_filename_component(ProjectId ${CMAKE_CURRENT_SOURCE_DIR} NAME) 9 | string(REPLACE " " "_" ProjectId ${ProjectId}) 10 | 11 | project(${ProjectId}) 12 | 13 | file(GLOB project_sources src/*.cpp) 14 | file(GLOB project_headers src/*.h src/*.hpp) 15 | 16 | add_executable(${ProjectId} ${project_sources} ${project_headers}) 17 | -------------------------------------------------------------------------------- /RangeBasedColoring/src/Bitmap.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Bitmap.h 3 | * 4 | * Created on: Jul 2, 2015 5 | * Author: johnpurcell 6 | */ 7 | 8 | #ifndef BITMAP_H_ 9 | #define BITMAP_H_ 10 | 11 | #include 12 | #include 13 | #include 14 | using namespace std; 15 | 16 | namespace caveofprogramming { 17 | 18 | class Bitmap { 19 | private: 20 | int m_width{0}; 21 | int m_height{0}; 22 | unique_ptr m_pPixels{nullptr}; 23 | 24 | 25 | public: 26 | Bitmap(int width, int height); 27 | void setPixel(int x, int y, uint8_t red, uint8_t green, uint8_t blue); 28 | bool write(string filename); 29 | virtual ~Bitmap(); 30 | }; 31 | 32 | } /* namespace caveofprogramming */ 33 | 34 | #endif /* BITMAP_H_ */ 35 | -------------------------------------------------------------------------------- /RangeBasedColoring/src/BitmapFileHeader.h: -------------------------------------------------------------------------------- 1 | /* 2 | * BitmapFileHeader.h 3 | * 4 | * Created on: Jun 21, 2015 5 | * Author: johnpurcell 6 | */ 7 | 8 | #ifndef BITMAPFILEHEADER_H_ 9 | #define BITMAPFILEHEADER_H_ 10 | 11 | #include 12 | 13 | using namespace std; 14 | 15 | namespace caveofprogramming { 16 | 17 | #pragma pack(push, 2) 18 | 19 | struct BitmapFileHeader { 20 | char header[2] { 'B', 'M' }; 21 | int32_t fileSize; 22 | int32_t reserved { 0 }; 23 | int32_t dataOffset; 24 | }; 25 | 26 | #pragma pack(pop) 27 | 28 | } 29 | 30 | #endif /* BITMAPFILEHEADER_H_ */ 31 | -------------------------------------------------------------------------------- /RangeBasedColoring/src/BitmapInfoHeader.h: -------------------------------------------------------------------------------- 1 | #ifndef BITMAPINFOHEADER_H_ 2 | #define BITMAPINFOHEADER_H_ 3 | 4 | #include 5 | 6 | using namespace std; 7 | 8 | namespace caveofprogramming { 9 | 10 | #pragma pack(push, 2) 11 | 12 | struct BitmapInfoHeader { 13 | int32_t headerSize{40}; 14 | int32_t width; 15 | int32_t height; 16 | int16_t planes{1}; 17 | int16_t bitsPerPixel{24}; 18 | int32_t compression{0}; 19 | int32_t dataSize{0}; 20 | int32_t horizontalResolution{2400}; 21 | int32_t verticalResolution{2400}; 22 | int32_t colors{0}; 23 | int32_t importantColors{0}; 24 | }; 25 | 26 | #pragma pack(pop) 27 | 28 | } 29 | 30 | #endif 31 | -------------------------------------------------------------------------------- /RangeBasedColoring/src/Mandelbrot.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | * Mandelbrot.cpp 3 | * 4 | * Created on: Aug 21, 2015 5 | * Author: johnpurcell 6 | */ 7 | 8 | #include 9 | #include "Mandelbrot.h" 10 | 11 | using namespace std; 12 | 13 | namespace caveofprogramming { 14 | 15 | Mandelbrot::Mandelbrot() { 16 | // TODO Auto-generated constructor stub 17 | 18 | } 19 | 20 | Mandelbrot::~Mandelbrot() { 21 | // TODO Auto-generated destructor stub 22 | } 23 | 24 | int Mandelbrot::getIterations(double x, double y) { 25 | 26 | complex z = 0; 27 | complex c(x, y); 28 | 29 | int iterations = 0; 30 | 31 | while(iterations < MAX_ITERATIONS) { 32 | z = z*z + c; 33 | 34 | if(abs(z) > 2) { 35 | break; 36 | } 37 | 38 | iterations++; 39 | } 40 | 41 | return iterations; 42 | } 43 | 44 | } /* namespace caveofprogramming */ 45 | -------------------------------------------------------------------------------- /RangeBasedColoring/src/Mandelbrot.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Mandelbrot.h 3 | * 4 | * Created on: Aug 21, 2015 5 | * Author: johnpurcell 6 | */ 7 | 8 | #ifndef MANDELBROT_H_ 9 | #define MANDELBROT_H_ 10 | 11 | namespace caveofprogramming { 12 | 13 | class Mandelbrot { 14 | public: 15 | static const int MAX_ITERATIONS = 1000; 16 | 17 | public: 18 | Mandelbrot(); 19 | virtual ~Mandelbrot(); 20 | 21 | static int getIterations(double x, double y); 22 | }; 23 | 24 | } /* namespace caveofprogramming */ 25 | 26 | #endif /* MANDELBROT_H_ */ 27 | -------------------------------------------------------------------------------- /RangeBasedColoring/src/RGB.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | * RGB.cpp 3 | * 4 | * Created on: Sep 21, 2015 5 | * Author: johnpurcell 6 | */ 7 | 8 | #include "RGB.h" 9 | 10 | namespace caveofprogramming { 11 | 12 | RGB::RGB(double r, double g, double b): r(r), g(g), b(b) { 13 | // TODO Auto-generated constructor stub 14 | 15 | } 16 | 17 | RGB operator-(const RGB& first, const RGB& second) { 18 | return RGB(first.r - second.r, first.g - second.g, first.b - second.b); 19 | } 20 | 21 | } /* namespace caveofprogramming */ 22 | -------------------------------------------------------------------------------- /RangeBasedColoring/src/RGB.h: -------------------------------------------------------------------------------- 1 | /* 2 | * RGB.h 3 | * 4 | * Created on: Sep 21, 2015 5 | * Author: johnpurcell 6 | */ 7 | 8 | #ifndef RGB_H_ 9 | #define RGB_H_ 10 | 11 | namespace caveofprogramming { 12 | 13 | struct RGB { 14 | double r; 15 | double g; 16 | double b; 17 | 18 | RGB(double r, double g, double b); 19 | }; 20 | 21 | RGB operator-(const RGB& first, const RGB& second); 22 | 23 | } /* namespace caveofprogramming */ 24 | 25 | 26 | 27 | #endif /* RGB_H_ */ 28 | -------------------------------------------------------------------------------- /RangeBasedColoring/src/Zoom.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Zoom.h 3 | * 4 | * Created on: Sep 20, 2015 5 | * Author: johnpurcell 6 | */ 7 | 8 | #ifndef ZOOM_H_ 9 | #define ZOOM_H_ 10 | 11 | namespace caveofprogramming { 12 | 13 | struct Zoom { 14 | int x{0}; 15 | int y{0}; 16 | double scale{0.0}; 17 | 18 | Zoom(int x, int y, double scale) : x(x), y(y), scale(scale) {}; 19 | }; 20 | 21 | } /* namespace caveofprogramming */ 22 | 23 | #endif /* ZOOM_H_ */ 24 | -------------------------------------------------------------------------------- /RangeBasedColoring/src/ZoomList.h: -------------------------------------------------------------------------------- 1 | /* 2 | * ZoomList.h 3 | * 4 | * Created on: Sep 20, 2015 5 | * Author: johnpurcell 6 | */ 7 | 8 | #ifndef ZOOMLIST_H_ 9 | #define ZOOMLIST_H_ 10 | 11 | #include 12 | #include 13 | #include "Zoom.h" 14 | 15 | using namespace std; 16 | 17 | namespace caveofprogramming { 18 | 19 | class ZoomList { 20 | private: 21 | double m_xCenter{0}; 22 | double m_yCenter{0}; 23 | double m_scale{1.0}; 24 | 25 | int m_width{0}; 26 | int m_height{0}; 27 | vector zooms; 28 | 29 | public: 30 | ZoomList(int width, int height); 31 | void add(const Zoom& zoom); 32 | pair doZoom(int x, int y); 33 | }; 34 | 35 | } /* namespace caveofprogramming */ 36 | 37 | #endif /* ZOOMLIST_H_ */ 38 | -------------------------------------------------------------------------------- /ReadingTextFiles/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | set(CMAKE_ARCHIVE_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/lib) 2 | set(CMAKE_LIBRARY_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/lib) 3 | set(CMAKE_RUNTIME_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/bin) 4 | 5 | set (CMAKE_CXX_STANDARD 11) 6 | cmake_minimum_required(VERSION 3.0) 7 | 8 | get_filename_component(ProjectId ${CMAKE_CURRENT_SOURCE_DIR} NAME) 9 | string(REPLACE " " "_" ProjectId ${ProjectId}) 10 | 11 | project(${ProjectId}) 12 | 13 | file(GLOB project_sources src/*.cpp) 14 | file(GLOB project_headers src/*.h src/*.hpp) 15 | 16 | add_executable(${ProjectId} ${project_sources} ${project_headers}) 17 | -------------------------------------------------------------------------------- /ReadingTextFiles/test.txt: -------------------------------------------------------------------------------- 1 | This is a line. 2 | This is another line. 3 | Here's the third line. 4 | -------------------------------------------------------------------------------- /ReadingandWritingBinaryFiles/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | set(CMAKE_ARCHIVE_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/lib) 2 | set(CMAKE_LIBRARY_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/lib) 3 | set(CMAKE_RUNTIME_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/bin) 4 | 5 | set (CMAKE_CXX_STANDARD 11) 6 | cmake_minimum_required(VERSION 3.0) 7 | 8 | get_filename_component(ProjectId ${CMAKE_CURRENT_SOURCE_DIR} NAME) 9 | string(REPLACE " " "_" ProjectId ${ProjectId}) 10 | 11 | project(${ProjectId}) 12 | 13 | file(GLOB project_sources src/*.cpp) 14 | file(GLOB project_headers src/*.h src/*.hpp) 15 | 16 | add_executable(${ProjectId} ${project_sources} ${project_headers}) 17 | -------------------------------------------------------------------------------- /ReadingandWritingBinaryFiles/data.bin: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/caveofprogramming/advanced-cplusplus/18f1d43d68c41b9e543d5350e9c47967b671d22a/ReadingandWritingBinaryFiles/data.bin -------------------------------------------------------------------------------- /ReinterpretCast/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | set(CMAKE_ARCHIVE_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/lib) 2 | set(CMAKE_LIBRARY_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/lib) 3 | set(CMAKE_RUNTIME_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/bin) 4 | 5 | set (CMAKE_CXX_STANDARD 11) 6 | cmake_minimum_required(VERSION 3.0) 7 | 8 | get_filename_component(ProjectId ${CMAKE_CURRENT_SOURCE_DIR} NAME) 9 | string(REPLACE " " "_" ProjectId ${ProjectId}) 10 | 11 | project(${ProjectId}) 12 | 13 | file(GLOB project_sources src/*.cpp) 14 | file(GLOB project_headers src/*.h src/*.hpp) 15 | 16 | add_executable(${ProjectId} ${project_sources} ${project_headers}) 17 | -------------------------------------------------------------------------------- /ReorganisingMain/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | set(CMAKE_ARCHIVE_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/lib) 2 | set(CMAKE_LIBRARY_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/lib) 3 | set(CMAKE_RUNTIME_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/bin) 4 | 5 | set (CMAKE_CXX_STANDARD 11) 6 | cmake_minimum_required(VERSION 3.0) 7 | 8 | get_filename_component(ProjectId ${CMAKE_CURRENT_SOURCE_DIR} NAME) 9 | string(REPLACE " " "_" ProjectId ${ProjectId}) 10 | 11 | project(${ProjectId}) 12 | 13 | file(GLOB project_sources src/*.cpp) 14 | file(GLOB project_headers src/*.h src/*.hpp) 15 | 16 | add_executable(${ProjectId} ${project_sources} ${project_headers}) 17 | -------------------------------------------------------------------------------- /ReorganisingMain/src/Bitmap.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Bitmap.h 3 | * 4 | * Created on: Jul 2, 2015 5 | * Author: johnpurcell 6 | */ 7 | 8 | #ifndef BITMAP_H_ 9 | #define BITMAP_H_ 10 | 11 | #include 12 | #include 13 | #include 14 | using namespace std; 15 | 16 | namespace caveofprogramming { 17 | 18 | class Bitmap { 19 | private: 20 | int m_width{0}; 21 | int m_height{0}; 22 | unique_ptr m_pPixels{nullptr}; 23 | 24 | 25 | public: 26 | Bitmap(int width, int height); 27 | void setPixel(int x, int y, uint8_t red, uint8_t green, uint8_t blue); 28 | bool write(string filename); 29 | virtual ~Bitmap(); 30 | }; 31 | 32 | } /* namespace caveofprogramming */ 33 | 34 | #endif /* BITMAP_H_ */ 35 | -------------------------------------------------------------------------------- /ReorganisingMain/src/BitmapFileHeader.h: -------------------------------------------------------------------------------- 1 | /* 2 | * BitmapFileHeader.h 3 | * 4 | * Created on: Jun 21, 2015 5 | * Author: johnpurcell 6 | */ 7 | 8 | #ifndef BITMAPFILEHEADER_H_ 9 | #define BITMAPFILEHEADER_H_ 10 | 11 | #include 12 | 13 | using namespace std; 14 | 15 | namespace caveofprogramming { 16 | 17 | #pragma pack(push, 2) 18 | 19 | struct BitmapFileHeader { 20 | char header[2] { 'B', 'M' }; 21 | int32_t fileSize; 22 | int32_t reserved { 0 }; 23 | int32_t dataOffset; 24 | }; 25 | 26 | #pragma pack(pop) 27 | 28 | } 29 | 30 | #endif /* BITMAPFILEHEADER_H_ */ 31 | -------------------------------------------------------------------------------- /ReorganisingMain/src/BitmapInfoHeader.h: -------------------------------------------------------------------------------- 1 | #ifndef BITMAPINFOHEADER_H_ 2 | #define BITMAPINFOHEADER_H_ 3 | 4 | #include 5 | 6 | using namespace std; 7 | 8 | namespace caveofprogramming { 9 | 10 | #pragma pack(push, 2) 11 | 12 | struct BitmapInfoHeader { 13 | int32_t headerSize{40}; 14 | int32_t width; 15 | int32_t height; 16 | int16_t planes{1}; 17 | int16_t bitsPerPixel{24}; 18 | int32_t compression{0}; 19 | int32_t dataSize{0}; 20 | int32_t horizontalResolution{2400}; 21 | int32_t verticalResolution{2400}; 22 | int32_t colors{0}; 23 | int32_t importantColors{0}; 24 | }; 25 | 26 | #pragma pack(pop) 27 | 28 | } 29 | 30 | #endif 31 | -------------------------------------------------------------------------------- /ReorganisingMain/src/FractalCreator.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | * FractalCreator.cpp 3 | * 4 | * Created on: Sep 21, 2015 5 | * Author: johnpurcell 6 | */ 7 | 8 | #include "FractalCreator.h" 9 | 10 | namespace caveofprogramming { 11 | 12 | FractalCreator::FractalCreator(int width, int height) { 13 | // TODO Auto-generated constructor stub 14 | 15 | } 16 | 17 | FractalCreator::~FractalCreator() { 18 | } 19 | 20 | void FractalCreator::calculateIteration() { 21 | } 22 | 23 | void FractalCreator::drawFractal() { 24 | } 25 | 26 | void FractalCreator::addZoom(const Zoom& zoom) { 27 | } 28 | 29 | void FractalCreator::writeBitmap(string name) { 30 | } 31 | 32 | } /* namespace caveofprogramming */ 33 | -------------------------------------------------------------------------------- /ReorganisingMain/src/FractalCreator.h: -------------------------------------------------------------------------------- 1 | /* 2 | * FractalCreator.h 3 | * 4 | * Created on: Sep 21, 2015 5 | * Author: johnpurcell 6 | */ 7 | 8 | #ifndef FRACTALCREATOR_H_ 9 | #define FRACTALCREATOR_H_ 10 | 11 | #include 12 | #include "Zoom.h" 13 | 14 | using namespace std; 15 | 16 | namespace caveofprogramming { 17 | 18 | class FractalCreator { 19 | public: 20 | FractalCreator(int width, int height); 21 | virtual ~FractalCreator(); 22 | 23 | void calculateIteration(); 24 | void drawFractal(); 25 | void addZoom(const Zoom& zoom); 26 | void writeBitmap(string name); 27 | }; 28 | 29 | } /* namespace caveofprogramming */ 30 | 31 | #endif /* FRACTALCREATOR_H_ */ 32 | -------------------------------------------------------------------------------- /ReorganisingMain/src/Mandelbrot.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | * Mandelbrot.cpp 3 | * 4 | * Created on: Aug 21, 2015 5 | * Author: johnpurcell 6 | */ 7 | 8 | #include 9 | #include "Mandelbrot.h" 10 | 11 | using namespace std; 12 | 13 | namespace caveofprogramming { 14 | 15 | Mandelbrot::Mandelbrot() { 16 | // TODO Auto-generated constructor stub 17 | 18 | } 19 | 20 | Mandelbrot::~Mandelbrot() { 21 | // TODO Auto-generated destructor stub 22 | } 23 | 24 | int Mandelbrot::getIterations(double x, double y) { 25 | 26 | complex z = 0; 27 | complex c(x, y); 28 | 29 | int iterations = 0; 30 | 31 | while(iterations < MAX_ITERATIONS) { 32 | z = z*z + c; 33 | 34 | if(abs(z) > 2) { 35 | break; 36 | } 37 | 38 | iterations++; 39 | } 40 | 41 | return iterations; 42 | } 43 | 44 | } /* namespace caveofprogramming */ 45 | -------------------------------------------------------------------------------- /ReorganisingMain/src/Mandelbrot.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Mandelbrot.h 3 | * 4 | * Created on: Aug 21, 2015 5 | * Author: johnpurcell 6 | */ 7 | 8 | #ifndef MANDELBROT_H_ 9 | #define MANDELBROT_H_ 10 | 11 | namespace caveofprogramming { 12 | 13 | class Mandelbrot { 14 | public: 15 | static const int MAX_ITERATIONS = 1000; 16 | 17 | public: 18 | Mandelbrot(); 19 | virtual ~Mandelbrot(); 20 | 21 | static int getIterations(double x, double y); 22 | }; 23 | 24 | } /* namespace caveofprogramming */ 25 | 26 | #endif /* MANDELBROT_H_ */ 27 | -------------------------------------------------------------------------------- /ReorganisingMain/src/Zoom.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Zoom.h 3 | * 4 | * Created on: Sep 20, 2015 5 | * Author: johnpurcell 6 | */ 7 | 8 | #ifndef ZOOM_H_ 9 | #define ZOOM_H_ 10 | 11 | namespace caveofprogramming { 12 | 13 | struct Zoom { 14 | int x{0}; 15 | int y{0}; 16 | double scale{0.0}; 17 | 18 | Zoom(int x, int y, double scale) : x(x), y(y), scale(scale) {}; 19 | }; 20 | 21 | } /* namespace caveofprogramming */ 22 | 23 | #endif /* ZOOM_H_ */ 24 | -------------------------------------------------------------------------------- /ReorganisingMain/src/ZoomList.h: -------------------------------------------------------------------------------- 1 | /* 2 | * ZoomList.h 3 | * 4 | * Created on: Sep 20, 2015 5 | * Author: johnpurcell 6 | */ 7 | 8 | #ifndef ZOOMLIST_H_ 9 | #define ZOOMLIST_H_ 10 | 11 | #include 12 | #include 13 | #include "Zoom.h" 14 | 15 | using namespace std; 16 | 17 | namespace caveofprogramming { 18 | 19 | class ZoomList { 20 | private: 21 | double m_xCenter{0}; 22 | double m_yCenter{0}; 23 | double m_scale{1.0}; 24 | 25 | int m_width{0}; 26 | int m_height{0}; 27 | vector zooms; 28 | 29 | public: 30 | ZoomList(int width, int height); 31 | void add(const Zoom& zoom); 32 | pair doZoom(int x, int y); 33 | }; 34 | 35 | } /* namespace caveofprogramming */ 36 | 37 | #endif /* ZOOMLIST_H_ */ 38 | -------------------------------------------------------------------------------- /RingBuffer/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | set(CMAKE_ARCHIVE_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/lib) 2 | set(CMAKE_LIBRARY_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/lib) 3 | set(CMAKE_RUNTIME_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/bin) 4 | 5 | set (CMAKE_CXX_STANDARD 11) 6 | cmake_minimum_required(VERSION 3.0) 7 | 8 | get_filename_component(ProjectId ${CMAKE_CURRENT_SOURCE_DIR} NAME) 9 | string(REPLACE " " "_" ProjectId ${ProjectId}) 10 | 11 | project(${ProjectId}) 12 | 13 | file(GLOB project_sources src/*.cpp) 14 | file(GLOB project_headers src/*.h src/*.hpp) 15 | 16 | add_executable(${ProjectId} ${project_sources} ${project_headers}) 17 | -------------------------------------------------------------------------------- /RingBuffer/src/main.cpp: -------------------------------------------------------------------------------- 1 | //============================================================================ 2 | // Name : RingBuffer.cpp 3 | // Author : 4 | // Version : 5 | // Copyright : Your copyright notice 6 | // Description : Hello World in C++, Ansi-style 7 | //============================================================================ 8 | 9 | #include 10 | #include 11 | #include "ring.h" 12 | using namespace std; 13 | 14 | int main() { 15 | 16 | ring textring(3); 17 | 18 | textring.add("one"); 19 | textring.add("two"); 20 | textring.add("three"); 21 | textring.add("four"); 22 | 23 | for(int i=0; i 12 | #include 13 | #include 14 | 15 | using namespace std; 16 | 17 | namespace caveofprogramming { 18 | 19 | class Bitmap { 20 | private: 21 | int m_width{0}; 22 | int m_height{0}; 23 | unique_ptr m_pPixels{nullptr}; 24 | 25 | 26 | public: 27 | Bitmap(int width, int height); 28 | void setPixel(int x, int y, uint8_t red, uint8_t green, uint8_t blue); 29 | bool write(string filename); 30 | virtual ~Bitmap(); 31 | }; 32 | 33 | } /* namespace caveofprogramming */ 34 | 35 | #endif /* BITMAP_H_ */ 36 | -------------------------------------------------------------------------------- /Scaling/src/BitmapFileHeader.h: -------------------------------------------------------------------------------- 1 | /* 2 | * BitmapFileHeader.h 3 | * 4 | * Created on: Jun 21, 2015 5 | * Author: johnpurcell 6 | */ 7 | 8 | #ifndef BITMAPFILEHEADER_H_ 9 | #define BITMAPFILEHEADER_H_ 10 | 11 | #include 12 | 13 | using namespace std; 14 | 15 | namespace caveofprogramming { 16 | 17 | #pragma pack(push, 2) 18 | 19 | struct BitmapFileHeader { 20 | char header[2] { 'B', 'M' }; 21 | int32_t fileSize; 22 | int32_t reserved { 0 }; 23 | int32_t dataOffset; 24 | }; 25 | 26 | #pragma pack(pop) 27 | 28 | } 29 | 30 | #endif /* BITMAPFILEHEADER_H_ */ 31 | -------------------------------------------------------------------------------- /Scaling/src/BitmapInfoHeader.h: -------------------------------------------------------------------------------- 1 | #ifndef BITMAPINFOHEADER_H_ 2 | #define BITMAPINFOHEADER_H_ 3 | 4 | #include 5 | 6 | using namespace std; 7 | 8 | namespace caveofprogramming { 9 | 10 | #pragma pack(push, 2) 11 | 12 | struct BitmapInfoHeader { 13 | int32_t headerSize{40}; 14 | int32_t width; 15 | int32_t height; 16 | int16_t planes{1}; 17 | int16_t bitsPerPixel{24}; 18 | int32_t compression{0}; 19 | int32_t dataSize{0}; 20 | int32_t horizontalResolution{2400}; 21 | int32_t verticalResolution{2400}; 22 | int32_t colors{0}; 23 | int32_t importantColors{0}; 24 | }; 25 | 26 | #pragma pack(pop) 27 | 28 | } 29 | 30 | #endif 31 | -------------------------------------------------------------------------------- /SettingPixels/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | set(CMAKE_ARCHIVE_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/lib) 2 | set(CMAKE_LIBRARY_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/lib) 3 | set(CMAKE_RUNTIME_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/bin) 4 | 5 | set (CMAKE_CXX_STANDARD 11) 6 | cmake_minimum_required(VERSION 3.0) 7 | 8 | get_filename_component(ProjectId ${CMAKE_CURRENT_SOURCE_DIR} NAME) 9 | string(REPLACE " " "_" ProjectId ${ProjectId}) 10 | 11 | project(${ProjectId}) 12 | 13 | file(GLOB project_sources src/*.cpp) 14 | file(GLOB project_headers src/*.h src/*.hpp) 15 | 16 | add_executable(${ProjectId} ${project_sources} ${project_headers}) 17 | -------------------------------------------------------------------------------- /SettingPixels/src/Bitmap.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Bitmap.h 3 | * 4 | * Created on: Jul 2, 2015 5 | * Author: johnpurcell 6 | */ 7 | 8 | #ifndef BITMAP_H_ 9 | #define BITMAP_H_ 10 | 11 | #include 12 | #include 13 | #include 14 | 15 | using namespace std; 16 | 17 | namespace caveofprogramming { 18 | 19 | class Bitmap { 20 | private: 21 | int m_width{0}; 22 | int m_height{0}; 23 | unique_ptr m_pPixels{nullptr}; 24 | 25 | 26 | public: 27 | Bitmap(int width, int height); 28 | void setPixel(int x, int y, uint8_t red, uint8_t green, uint8_t blue); 29 | bool write(string filename); 30 | virtual ~Bitmap(); 31 | }; 32 | 33 | } /* namespace caveofprogramming */ 34 | 35 | #endif /* BITMAP_H_ */ 36 | -------------------------------------------------------------------------------- /SettingPixels/src/BitmapFileHeader.h: -------------------------------------------------------------------------------- 1 | /* 2 | * BitmapFileHeader.h 3 | * 4 | * Created on: Jun 21, 2015 5 | * Author: johnpurcell 6 | */ 7 | 8 | #ifndef BITMAPFILEHEADER_H_ 9 | #define BITMAPFILEHEADER_H_ 10 | 11 | #include 12 | 13 | using namespace std; 14 | 15 | namespace caveofprogramming { 16 | 17 | #pragma pack(push, 2) 18 | 19 | struct BitmapFileHeader { 20 | char header[2] { 'B', 'M' }; 21 | int32_t fileSize; 22 | int32_t reserved { 0 }; 23 | int32_t dataOffset; 24 | }; 25 | 26 | #pragma pack(pop) 27 | 28 | } 29 | 30 | #endif /* BITMAPFILEHEADER_H_ */ 31 | -------------------------------------------------------------------------------- /SettingPixels/src/BitmapInfoHeader.h: -------------------------------------------------------------------------------- 1 | #ifndef BITMAPINFOHEADER_H_ 2 | #define BITMAPINFOHEADER_H_ 3 | 4 | #include 5 | 6 | using namespace std; 7 | 8 | namespace caveofprogramming { 9 | 10 | #pragma pack(push, 2) 11 | 12 | struct BitmapInfoHeader { 13 | int32_t headerSize{40}; 14 | int32_t width; 15 | int32_t height; 16 | int16_t planes{1}; 17 | int16_t bitsPerPixel{24}; 18 | int32_t compression{0}; 19 | int32_t dataSize{0}; 20 | int32_t horizontalResolution{2400}; 21 | int32_t verticalResolution{2400}; 22 | int32_t colors{0}; 23 | int32_t importantColors{0}; 24 | }; 25 | 26 | #pragma pack(pop) 27 | 28 | } 29 | 30 | #endif 31 | -------------------------------------------------------------------------------- /SharedPointers/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | set(CMAKE_ARCHIVE_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/lib) 2 | set(CMAKE_LIBRARY_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/lib) 3 | set(CMAKE_RUNTIME_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/bin) 4 | 5 | set (CMAKE_CXX_STANDARD 11) 6 | cmake_minimum_required(VERSION 3.0) 7 | 8 | get_filename_component(ProjectId ${CMAKE_CURRENT_SOURCE_DIR} NAME) 9 | string(REPLACE " " "_" ProjectId ${ProjectId}) 10 | 11 | project(${ProjectId}) 12 | 13 | file(GLOB project_sources src/*.cpp) 14 | file(GLOB project_headers src/*.h src/*.hpp) 15 | 16 | add_executable(${ProjectId} ${project_sources} ${project_headers}) 17 | -------------------------------------------------------------------------------- /SortingVectorsDequeFriend/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | set(CMAKE_ARCHIVE_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/lib) 2 | set(CMAKE_LIBRARY_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/lib) 3 | set(CMAKE_RUNTIME_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/bin) 4 | 5 | set (CMAKE_CXX_STANDARD 11) 6 | cmake_minimum_required(VERSION 3.0) 7 | 8 | get_filename_component(ProjectId ${CMAKE_CURRENT_SOURCE_DIR} NAME) 9 | string(REPLACE " " "_" ProjectId ${ProjectId}) 10 | 11 | project(${ProjectId}) 12 | 13 | file(GLOB project_sources src/*.cpp) 14 | file(GLOB project_headers src/*.h src/*.hpp) 15 | 16 | add_executable(${ProjectId} ${project_sources} ${project_headers}) 17 | -------------------------------------------------------------------------------- /SpecifyingColorRanges/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | set(CMAKE_ARCHIVE_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/lib) 2 | set(CMAKE_LIBRARY_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/lib) 3 | set(CMAKE_RUNTIME_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/bin) 4 | 5 | set (CMAKE_CXX_STANDARD 11) 6 | cmake_minimum_required(VERSION 3.0) 7 | 8 | get_filename_component(ProjectId ${CMAKE_CURRENT_SOURCE_DIR} NAME) 9 | string(REPLACE " " "_" ProjectId ${ProjectId}) 10 | 11 | project(${ProjectId}) 12 | 13 | file(GLOB project_sources src/*.cpp) 14 | file(GLOB project_headers src/*.h src/*.hpp) 15 | 16 | add_executable(${ProjectId} ${project_sources} ${project_headers}) 17 | -------------------------------------------------------------------------------- /SpecifyingColorRanges/src/Bitmap.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Bitmap.h 3 | * 4 | * Created on: Jul 2, 2015 5 | * Author: johnpurcell 6 | */ 7 | 8 | #ifndef BITMAP_H_ 9 | #define BITMAP_H_ 10 | 11 | #include 12 | #include 13 | #include 14 | using namespace std; 15 | 16 | namespace caveofprogramming { 17 | 18 | class Bitmap { 19 | private: 20 | int m_width{0}; 21 | int m_height{0}; 22 | unique_ptr m_pPixels{nullptr}; 23 | 24 | 25 | public: 26 | Bitmap(int width, int height); 27 | void setPixel(int x, int y, uint8_t red, uint8_t green, uint8_t blue); 28 | bool write(string filename); 29 | virtual ~Bitmap(); 30 | }; 31 | 32 | } /* namespace caveofprogramming */ 33 | 34 | #endif /* BITMAP_H_ */ 35 | -------------------------------------------------------------------------------- /SpecifyingColorRanges/src/BitmapFileHeader.h: -------------------------------------------------------------------------------- 1 | /* 2 | * BitmapFileHeader.h 3 | * 4 | * Created on: Jun 21, 2015 5 | * Author: johnpurcell 6 | */ 7 | 8 | #ifndef BITMAPFILEHEADER_H_ 9 | #define BITMAPFILEHEADER_H_ 10 | 11 | #include 12 | 13 | using namespace std; 14 | 15 | namespace caveofprogramming { 16 | 17 | #pragma pack(push, 2) 18 | 19 | struct BitmapFileHeader { 20 | char header[2] { 'B', 'M' }; 21 | int32_t fileSize; 22 | int32_t reserved { 0 }; 23 | int32_t dataOffset; 24 | }; 25 | 26 | #pragma pack(pop) 27 | 28 | } 29 | 30 | #endif /* BITMAPFILEHEADER_H_ */ 31 | -------------------------------------------------------------------------------- /SpecifyingColorRanges/src/BitmapInfoHeader.h: -------------------------------------------------------------------------------- 1 | #ifndef BITMAPINFOHEADER_H_ 2 | #define BITMAPINFOHEADER_H_ 3 | 4 | #include 5 | 6 | using namespace std; 7 | 8 | namespace caveofprogramming { 9 | 10 | #pragma pack(push, 2) 11 | 12 | struct BitmapInfoHeader { 13 | int32_t headerSize{40}; 14 | int32_t width; 15 | int32_t height; 16 | int16_t planes{1}; 17 | int16_t bitsPerPixel{24}; 18 | int32_t compression{0}; 19 | int32_t dataSize{0}; 20 | int32_t horizontalResolution{2400}; 21 | int32_t verticalResolution{2400}; 22 | int32_t colors{0}; 23 | int32_t importantColors{0}; 24 | }; 25 | 26 | #pragma pack(pop) 27 | 28 | } 29 | 30 | #endif 31 | -------------------------------------------------------------------------------- /SpecifyingColorRanges/src/Mandelbrot.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Mandelbrot.h 3 | * 4 | * Created on: Aug 21, 2015 5 | * Author: johnpurcell 6 | */ 7 | 8 | #ifndef MANDELBROT_H_ 9 | #define MANDELBROT_H_ 10 | 11 | namespace caveofprogramming { 12 | 13 | class Mandelbrot { 14 | public: 15 | static const int MAX_ITERATIONS = 1000; 16 | 17 | public: 18 | Mandelbrot(); 19 | virtual ~Mandelbrot(); 20 | 21 | static int getIterations(double x, double y); 22 | }; 23 | 24 | } /* namespace caveofprogramming */ 25 | 26 | #endif /* MANDELBROT_H_ */ 27 | -------------------------------------------------------------------------------- /SpecifyingColorRanges/src/RGB.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | * RGB.cpp 3 | * 4 | * Created on: Sep 21, 2015 5 | * Author: johnpurcell 6 | */ 7 | 8 | #include "RGB.h" 9 | 10 | namespace caveofprogramming { 11 | 12 | RGB::RGB(double r, double g, double b): r(r), g(g), b(b) { 13 | // TODO Auto-generated constructor stub 14 | 15 | } 16 | 17 | RGB operator-(const RGB& first, const RGB& second) { 18 | return RGB(first.r - second.r, first.g - second.g, first.b - second.b); 19 | } 20 | 21 | } /* namespace caveofprogramming */ 22 | -------------------------------------------------------------------------------- /SpecifyingColorRanges/src/RGB.h: -------------------------------------------------------------------------------- 1 | /* 2 | * RGB.h 3 | * 4 | * Created on: Sep 21, 2015 5 | * Author: johnpurcell 6 | */ 7 | 8 | #ifndef RGB_H_ 9 | #define RGB_H_ 10 | 11 | namespace caveofprogramming { 12 | 13 | struct RGB { 14 | double r; 15 | double g; 16 | double b; 17 | 18 | RGB(double r, double g, double b); 19 | }; 20 | 21 | RGB operator-(const RGB& first, const RGB& second); 22 | 23 | } /* namespace caveofprogramming */ 24 | 25 | 26 | 27 | #endif /* RGB_H_ */ 28 | -------------------------------------------------------------------------------- /SpecifyingColorRanges/src/Zoom.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Zoom.h 3 | * 4 | * Created on: Sep 20, 2015 5 | * Author: johnpurcell 6 | */ 7 | 8 | #ifndef ZOOM_H_ 9 | #define ZOOM_H_ 10 | 11 | namespace caveofprogramming { 12 | 13 | struct Zoom { 14 | int x{0}; 15 | int y{0}; 16 | double scale{0.0}; 17 | 18 | Zoom(int x, int y, double scale) : x(x), y(y), scale(scale) {}; 19 | }; 20 | 21 | } /* namespace caveofprogramming */ 22 | 23 | #endif /* ZOOM_H_ */ 24 | -------------------------------------------------------------------------------- /SpecifyingColorRanges/src/ZoomList.h: -------------------------------------------------------------------------------- 1 | /* 2 | * ZoomList.h 3 | * 4 | * Created on: Sep 20, 2015 5 | * Author: johnpurcell 6 | */ 7 | 8 | #ifndef ZOOMLIST_H_ 9 | #define ZOOMLIST_H_ 10 | 11 | #include 12 | #include 13 | #include "Zoom.h" 14 | 15 | using namespace std; 16 | 17 | namespace caveofprogramming { 18 | 19 | class ZoomList { 20 | private: 21 | double m_xCenter{0}; 22 | double m_yCenter{0}; 23 | double m_scale{1.0}; 24 | 25 | int m_width{0}; 26 | int m_height{0}; 27 | vector zooms; 28 | 29 | public: 30 | ZoomList(int width, int height); 31 | void add(const Zoom& zoom); 32 | pair doZoom(int x, int y); 33 | }; 34 | 35 | } /* namespace caveofprogramming */ 36 | 37 | #endif /* ZOOMLIST_H_ */ 38 | -------------------------------------------------------------------------------- /StacksAndQueues/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | set(CMAKE_ARCHIVE_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/lib) 2 | set(CMAKE_LIBRARY_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/lib) 3 | set(CMAKE_RUNTIME_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/bin) 4 | 5 | set (CMAKE_CXX_STANDARD 11) 6 | cmake_minimum_required(VERSION 3.0) 7 | 8 | get_filename_component(ProjectId ${CMAKE_CURRENT_SOURCE_DIR} NAME) 9 | string(REPLACE " " "_" ProjectId ${ProjectId}) 10 | 11 | project(${ProjectId}) 12 | 13 | file(GLOB project_sources src/*.cpp) 14 | file(GLOB project_headers src/*.h src/*.hpp) 15 | 16 | add_executable(${ProjectId} ${project_sources} ${project_headers}) 17 | -------------------------------------------------------------------------------- /StandardExceptions/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | set(CMAKE_ARCHIVE_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/lib) 2 | set(CMAKE_LIBRARY_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/lib) 3 | set(CMAKE_RUNTIME_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/bin) 4 | 5 | set (CMAKE_CXX_STANDARD 11) 6 | cmake_minimum_required(VERSION 3.0) 7 | 8 | get_filename_component(ProjectId ${CMAKE_CURRENT_SOURCE_DIR} NAME) 9 | string(REPLACE " " "_" ProjectId ${ProjectId}) 10 | 11 | project(${ProjectId}) 12 | 13 | file(GLOB project_sources src/*.cpp) 14 | file(GLOB project_headers src/*.h src/*.hpp) 15 | 16 | add_executable(${ProjectId} ${project_sources} ${project_headers}) 17 | -------------------------------------------------------------------------------- /StandardExceptions/src/Standard Exceptions.cpp: -------------------------------------------------------------------------------- 1 | //============================================================================ 2 | // Name : Standard.cpp 3 | // Author : 4 | // Version : 5 | // Copyright : Your copyright notice 6 | // Description : Hello World in C++, Ansi-style 7 | //============================================================================ 8 | 9 | #include 10 | using namespace std; 11 | 12 | class CanGoWrong { 13 | public: 14 | CanGoWrong() { 15 | char *pMemory = new char[999]; 16 | delete[] pMemory; 17 | } 18 | }; 19 | 20 | int main() { 21 | 22 | try { 23 | CanGoWrong wrong; 24 | } 25 | catch(bad_alloc &e) { 26 | cout << "Caught exception: " << e.what() << endl; 27 | } 28 | 29 | cout << "Still running" << endl; 30 | 31 | return 0; 32 | } 33 | -------------------------------------------------------------------------------- /StaticCast/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | set(CMAKE_ARCHIVE_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/lib) 2 | set(CMAKE_LIBRARY_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/lib) 3 | set(CMAKE_RUNTIME_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/bin) 4 | 5 | set (CMAKE_CXX_STANDARD 11) 6 | cmake_minimum_required(VERSION 3.0) 7 | 8 | get_filename_component(ProjectId ${CMAKE_CURRENT_SOURCE_DIR} NAME) 9 | string(REPLACE " " "_" ProjectId ${ProjectId}) 10 | 11 | project(${ProjectId}) 12 | 13 | file(GLOB project_sources src/*.cpp) 14 | file(GLOB project_headers src/*.h src/*.hpp) 15 | 16 | add_executable(${ProjectId} ${project_sources} ${project_headers}) 17 | -------------------------------------------------------------------------------- /StlComplexDataTypes/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | set(CMAKE_ARCHIVE_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/lib) 2 | set(CMAKE_LIBRARY_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/lib) 3 | set(CMAKE_RUNTIME_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/bin) 4 | 5 | set (CMAKE_CXX_STANDARD 11) 6 | cmake_minimum_required(VERSION 3.0) 7 | 8 | get_filename_component(ProjectId ${CMAKE_CURRENT_SOURCE_DIR} NAME) 9 | string(REPLACE " " "_" ProjectId ${ProjectId}) 10 | 11 | project(${ProjectId}) 12 | 13 | file(GLOB project_sources src/*.cpp) 14 | file(GLOB project_headers src/*.h src/*.hpp) 15 | 16 | add_executable(${ProjectId} ${project_sources} ${project_headers}) 17 | -------------------------------------------------------------------------------- /StoringIterations/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | set(CMAKE_ARCHIVE_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/lib) 2 | set(CMAKE_LIBRARY_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/lib) 3 | set(CMAKE_RUNTIME_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/bin) 4 | 5 | set (CMAKE_CXX_STANDARD 11) 6 | cmake_minimum_required(VERSION 3.0) 7 | 8 | get_filename_component(ProjectId ${CMAKE_CURRENT_SOURCE_DIR} NAME) 9 | string(REPLACE " " "_" ProjectId ${ProjectId}) 10 | 11 | project(${ProjectId}) 12 | 13 | file(GLOB project_sources src/*.cpp) 14 | file(GLOB project_headers src/*.h src/*.hpp) 15 | 16 | add_executable(${ProjectId} ${project_sources} ${project_headers}) 17 | -------------------------------------------------------------------------------- /StoringIterations/src/Bitmap.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Bitmap.h 3 | * 4 | * Created on: Jul 2, 2015 5 | * Author: johnpurcell 6 | */ 7 | 8 | #ifndef BITMAP_H_ 9 | #define BITMAP_H_ 10 | 11 | #include 12 | #include 13 | #include 14 | using namespace std; 15 | 16 | namespace caveofprogramming { 17 | 18 | class Bitmap { 19 | private: 20 | int m_width{0}; 21 | int m_height{0}; 22 | unique_ptr m_pPixels{nullptr}; 23 | 24 | 25 | public: 26 | Bitmap(int width, int height); 27 | void setPixel(int x, int y, uint8_t red, uint8_t green, uint8_t blue); 28 | bool write(string filename); 29 | virtual ~Bitmap(); 30 | }; 31 | 32 | } /* namespace caveofprogramming */ 33 | 34 | #endif /* BITMAP_H_ */ 35 | -------------------------------------------------------------------------------- /StoringIterations/src/BitmapFileHeader.h: -------------------------------------------------------------------------------- 1 | /* 2 | * BitmapFileHeader.h 3 | * 4 | * Created on: Jun 21, 2015 5 | * Author: johnpurcell 6 | */ 7 | 8 | #ifndef BITMAPFILEHEADER_H_ 9 | #define BITMAPFILEHEADER_H_ 10 | 11 | #include 12 | 13 | using namespace std; 14 | 15 | namespace caveofprogramming { 16 | 17 | #pragma pack(push, 2) 18 | 19 | struct BitmapFileHeader { 20 | char header[2] { 'B', 'M' }; 21 | int32_t fileSize; 22 | int32_t reserved { 0 }; 23 | int32_t dataOffset; 24 | }; 25 | 26 | #pragma pack(pop) 27 | 28 | } 29 | 30 | #endif /* BITMAPFILEHEADER_H_ */ 31 | -------------------------------------------------------------------------------- /StoringIterations/src/BitmapInfoHeader.h: -------------------------------------------------------------------------------- 1 | #ifndef BITMAPINFOHEADER_H_ 2 | #define BITMAPINFOHEADER_H_ 3 | 4 | #include 5 | 6 | using namespace std; 7 | 8 | namespace caveofprogramming { 9 | 10 | #pragma pack(push, 2) 11 | 12 | struct BitmapInfoHeader { 13 | int32_t headerSize{40}; 14 | int32_t width; 15 | int32_t height; 16 | int16_t planes{1}; 17 | int16_t bitsPerPixel{24}; 18 | int32_t compression{0}; 19 | int32_t dataSize{0}; 20 | int32_t horizontalResolution{2400}; 21 | int32_t verticalResolution{2400}; 22 | int32_t colors{0}; 23 | int32_t importantColors{0}; 24 | }; 25 | 26 | #pragma pack(pop) 27 | 28 | } 29 | 30 | #endif 31 | -------------------------------------------------------------------------------- /StoringIterations/src/Mandelbrot.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | * Mandelbrot.cpp 3 | * 4 | * Created on: Aug 21, 2015 5 | * Author: johnpurcell 6 | */ 7 | 8 | #include 9 | #include "Mandelbrot.h" 10 | 11 | using namespace std; 12 | 13 | namespace caveofprogramming { 14 | 15 | Mandelbrot::Mandelbrot() { 16 | // TODO Auto-generated constructor stub 17 | 18 | } 19 | 20 | Mandelbrot::~Mandelbrot() { 21 | // TODO Auto-generated destructor stub 22 | } 23 | 24 | int Mandelbrot::getIterations(double x, double y) { 25 | 26 | complex z = 0; 27 | complex c(x, y); 28 | 29 | int iterations = 0; 30 | 31 | while(iterations < MAX_ITERATIONS) { 32 | z = z*z + c; 33 | 34 | if(abs(z) > 2) { 35 | break; 36 | } 37 | 38 | iterations++; 39 | } 40 | 41 | return iterations; 42 | } 43 | 44 | } /* namespace caveofprogramming */ 45 | -------------------------------------------------------------------------------- /StoringIterations/src/Mandelbrot.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Mandelbrot.h 3 | * 4 | * Created on: Aug 21, 2015 5 | * Author: johnpurcell 6 | */ 7 | 8 | #ifndef MANDELBROT_H_ 9 | #define MANDELBROT_H_ 10 | 11 | namespace caveofprogramming { 12 | 13 | class Mandelbrot { 14 | public: 15 | static const int MAX_ITERATIONS = 1000; 16 | 17 | public: 18 | Mandelbrot(); 19 | virtual ~Mandelbrot(); 20 | 21 | static int getIterations(double x, double y); 22 | }; 23 | 24 | } /* namespace caveofprogramming */ 25 | 26 | #endif /* MANDELBROT_H_ */ 27 | -------------------------------------------------------------------------------- /StructPadding/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | set(CMAKE_ARCHIVE_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/lib) 2 | set(CMAKE_LIBRARY_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/lib) 3 | set(CMAKE_RUNTIME_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/bin) 4 | 5 | set (CMAKE_CXX_STANDARD 11) 6 | cmake_minimum_required(VERSION 3.0) 7 | 8 | get_filename_component(ProjectId ${CMAKE_CURRENT_SOURCE_DIR} NAME) 9 | string(REPLACE " " "_" ProjectId ${ProjectId}) 10 | 11 | project(${ProjectId}) 12 | 13 | file(GLOB project_sources src/*.cpp) 14 | file(GLOB project_headers src/*.h src/*.hpp) 15 | 16 | add_executable(${ProjectId} ${project_sources} ${project_headers}) 17 | -------------------------------------------------------------------------------- /StructPadding/src/Binary Files.cpp: -------------------------------------------------------------------------------- 1 | //============================================================================ 2 | // Name : Binary.cpp 3 | // Author : 4 | // Version : 5 | // Copyright : Your copyright notice 6 | // Description : Hello World in C++, Ansi-style 7 | //============================================================================ 8 | 9 | #include 10 | #include 11 | using namespace std; 12 | 13 | #pragma pack(push, 1) 14 | 15 | struct Person { 16 | char name[50]; 17 | int age; 18 | double weight; 19 | }; 20 | 21 | #pragma pack(pop) 22 | 23 | int main() { 24 | 25 | cout << sizeof(Person) << endl; 26 | 27 | 28 | 29 | 30 | return 0; 31 | } 32 | -------------------------------------------------------------------------------- /TemplateClasses/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | set(CMAKE_ARCHIVE_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/lib) 2 | set(CMAKE_LIBRARY_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/lib) 3 | set(CMAKE_RUNTIME_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/bin) 4 | 5 | set (CMAKE_CXX_STANDARD 11) 6 | cmake_minimum_required(VERSION 3.0) 7 | 8 | get_filename_component(ProjectId ${CMAKE_CURRENT_SOURCE_DIR} NAME) 9 | string(REPLACE " " "_" ProjectId ${ProjectId}) 10 | 11 | project(${ProjectId}) 12 | 13 | file(GLOB project_sources src/*.cpp) 14 | file(GLOB project_headers src/*.h src/*.hpp) 15 | 16 | add_executable(${ProjectId} ${project_sources} ${project_headers}) 17 | -------------------------------------------------------------------------------- /TemplateFunctions1/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | set(CMAKE_ARCHIVE_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/lib) 2 | set(CMAKE_LIBRARY_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/lib) 3 | set(CMAKE_RUNTIME_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/bin) 4 | 5 | set (CMAKE_CXX_STANDARD 11) 6 | cmake_minimum_required(VERSION 3.0) 7 | 8 | get_filename_component(ProjectId ${CMAKE_CURRENT_SOURCE_DIR} NAME) 9 | string(REPLACE " " "_" ProjectId ${ProjectId}) 10 | 11 | project(${ProjectId}) 12 | 13 | file(GLOB project_sources src/*.cpp) 14 | file(GLOB project_headers src/*.h src/*.hpp) 15 | 16 | add_executable(${ProjectId} ${project_sources} ${project_headers}) 17 | -------------------------------------------------------------------------------- /TemplateFunctions1/src/Template Functions 1.cpp: -------------------------------------------------------------------------------- 1 | //============================================================================ 2 | // Name : Template.cpp 3 | // Author : 4 | // Version : 5 | // Copyright : Your copyright notice 6 | // Description : Hello World in C++, Ansi-style 7 | //============================================================================ 8 | 9 | #include 10 | #include 11 | using namespace std; 12 | 13 | template 14 | void print(T n) { 15 | cout << n << endl; 16 | } 17 | 18 | int main() { 19 | print("Hello"); 20 | print(5); 21 | 22 | print("Hi there"); 23 | 24 | return 0; 25 | } 26 | -------------------------------------------------------------------------------- /TemplateFunctionsandTypeInference/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | set(CMAKE_ARCHIVE_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/lib) 2 | set(CMAKE_LIBRARY_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/lib) 3 | set(CMAKE_RUNTIME_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/bin) 4 | 5 | set (CMAKE_CXX_STANDARD 11) 6 | cmake_minimum_required(VERSION 3.0) 7 | 8 | get_filename_component(ProjectId ${CMAKE_CURRENT_SOURCE_DIR} NAME) 9 | string(REPLACE " " "_" ProjectId ${ProjectId}) 10 | 11 | project(${ProjectId}) 12 | 13 | file(GLOB project_sources src/*.cpp) 14 | file(GLOB project_headers src/*.h src/*.hpp) 15 | 16 | add_executable(${ProjectId} ${project_sources} ${project_headers}) 17 | -------------------------------------------------------------------------------- /TheAutoKeyword/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | set(CMAKE_ARCHIVE_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/lib) 2 | set(CMAKE_LIBRARY_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/lib) 3 | set(CMAKE_RUNTIME_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/bin) 4 | 5 | set (CMAKE_CXX_STANDARD 11) 6 | cmake_minimum_required(VERSION 3.0) 7 | 8 | get_filename_component(ProjectId ${CMAKE_CURRENT_SOURCE_DIR} NAME) 9 | string(REPLACE " " "_" ProjectId ${ProjectId}) 10 | 11 | project(${ProjectId}) 12 | 13 | file(GLOB project_sources src/*.cpp) 14 | file(GLOB project_headers src/*.h src/*.hpp) 15 | 16 | add_executable(${ProjectId} ${project_sources} ${project_headers}) 17 | -------------------------------------------------------------------------------- /TheFractalAlgorithm/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | set(CMAKE_ARCHIVE_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/lib) 2 | set(CMAKE_LIBRARY_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/lib) 3 | set(CMAKE_RUNTIME_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/bin) 4 | 5 | set (CMAKE_CXX_STANDARD 11) 6 | cmake_minimum_required(VERSION 3.0) 7 | 8 | get_filename_component(ProjectId ${CMAKE_CURRENT_SOURCE_DIR} NAME) 9 | string(REPLACE " " "_" ProjectId ${ProjectId}) 10 | 11 | project(${ProjectId}) 12 | 13 | file(GLOB project_sources src/*.cpp) 14 | file(GLOB project_headers src/*.h src/*.hpp) 15 | 16 | add_executable(${ProjectId} ${project_sources} ${project_headers}) 17 | -------------------------------------------------------------------------------- /TheFractalAlgorithm/src/Bitmap.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Bitmap.h 3 | * 4 | * Created on: Jul 2, 2015 5 | * Author: johnpurcell 6 | */ 7 | 8 | #ifndef BITMAP_H_ 9 | #define BITMAP_H_ 10 | 11 | #include 12 | #include 13 | #include 14 | using namespace std; 15 | 16 | namespace caveofprogramming { 17 | 18 | class Bitmap { 19 | private: 20 | int m_width{0}; 21 | int m_height{0}; 22 | unique_ptr m_pPixels{nullptr}; 23 | 24 | 25 | public: 26 | Bitmap(int width, int height); 27 | void setPixel(int x, int y, uint8_t red, uint8_t green, uint8_t blue); 28 | bool write(string filename); 29 | virtual ~Bitmap(); 30 | }; 31 | 32 | } /* namespace caveofprogramming */ 33 | 34 | #endif /* BITMAP_H_ */ 35 | -------------------------------------------------------------------------------- /TheFractalAlgorithm/src/BitmapFileHeader.h: -------------------------------------------------------------------------------- 1 | /* 2 | * BitmapFileHeader.h 3 | * 4 | * Created on: Jun 21, 2015 5 | * Author: johnpurcell 6 | */ 7 | 8 | #ifndef BITMAPFILEHEADER_H_ 9 | #define BITMAPFILEHEADER_H_ 10 | 11 | #include 12 | 13 | using namespace std; 14 | 15 | namespace caveofprogramming { 16 | 17 | #pragma pack(push, 2) 18 | 19 | struct BitmapFileHeader { 20 | char header[2] { 'B', 'M' }; 21 | int32_t fileSize; 22 | int32_t reserved { 0 }; 23 | int32_t dataOffset; 24 | }; 25 | 26 | #pragma pack(pop) 27 | 28 | } 29 | 30 | #endif /* BITMAPFILEHEADER_H_ */ 31 | -------------------------------------------------------------------------------- /TheFractalAlgorithm/src/BitmapInfoHeader.h: -------------------------------------------------------------------------------- 1 | #ifndef BITMAPINFOHEADER_H_ 2 | #define BITMAPINFOHEADER_H_ 3 | 4 | #include 5 | 6 | using namespace std; 7 | 8 | namespace caveofprogramming { 9 | 10 | #pragma pack(push, 2) 11 | 12 | struct BitmapInfoHeader { 13 | int32_t headerSize{40}; 14 | int32_t width; 15 | int32_t height; 16 | int16_t planes{1}; 17 | int16_t bitsPerPixel{24}; 18 | int32_t compression{0}; 19 | int32_t dataSize{0}; 20 | int32_t horizontalResolution{2400}; 21 | int32_t verticalResolution{2400}; 22 | int32_t colors{0}; 23 | int32_t importantColors{0}; 24 | }; 25 | 26 | #pragma pack(pop) 27 | 28 | } 29 | 30 | #endif 31 | -------------------------------------------------------------------------------- /TheFractalAlgorithm/src/Mandelbrot.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | * Mandelbrot.cpp 3 | * 4 | * Created on: Aug 21, 2015 5 | * Author: johnpurcell 6 | */ 7 | 8 | #include "Mandelbrot.h" 9 | #include 10 | 11 | using namespace std; 12 | 13 | namespace caveofprogramming { 14 | 15 | Mandelbrot::Mandelbrot() { 16 | // TODO Auto-generated constructor stub 17 | 18 | } 19 | 20 | Mandelbrot::~Mandelbrot() { 21 | // TODO Auto-generated destructor stub 22 | } 23 | 24 | int Mandelbrot::getIterations(double x, double y) { 25 | 26 | complex z = 0; 27 | complex c(x, y); 28 | 29 | int iterations = 0; 30 | 31 | while(iterations < MAX_ITERATIONS) { 32 | z = z*z + c; 33 | 34 | if(abs(z) > 2) { 35 | break; 36 | } 37 | 38 | iterations++; 39 | } 40 | 41 | return iterations; 42 | } 43 | 44 | } /* namespace caveofprogramming */ 45 | -------------------------------------------------------------------------------- /TheFractalAlgorithm/src/Mandelbrot.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Mandelbrot.h 3 | * 4 | * Created on: Aug 21, 2015 5 | * Author: johnpurcell 6 | */ 7 | 8 | #ifndef MANDELBROT_H_ 9 | #define MANDELBROT_H_ 10 | 11 | namespace caveofprogramming { 12 | 13 | class Mandelbrot { 14 | public: 15 | static const int MAX_ITERATIONS = 1000; 16 | 17 | public: 18 | Mandelbrot(); 19 | virtual ~Mandelbrot(); 20 | 21 | static int getIterations(double x, double y); 22 | }; 23 | 24 | } /* namespace caveofprogramming */ 25 | 26 | #endif /* MANDELBROT_H_ */ 27 | -------------------------------------------------------------------------------- /TheZoomList/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | set(CMAKE_ARCHIVE_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/lib) 2 | set(CMAKE_LIBRARY_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/lib) 3 | set(CMAKE_RUNTIME_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/bin) 4 | 5 | set (CMAKE_CXX_STANDARD 11) 6 | cmake_minimum_required(VERSION 3.0) 7 | 8 | get_filename_component(ProjectId ${CMAKE_CURRENT_SOURCE_DIR} NAME) 9 | string(REPLACE " " "_" ProjectId ${ProjectId}) 10 | 11 | project(${ProjectId}) 12 | 13 | file(GLOB project_sources src/*.cpp) 14 | file(GLOB project_headers src/*.h src/*.hpp) 15 | 16 | add_executable(${ProjectId} ${project_sources} ${project_headers}) 17 | -------------------------------------------------------------------------------- /TheZoomList/src/Bitmap.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Bitmap.h 3 | * 4 | * Created on: Jul 2, 2015 5 | * Author: johnpurcell 6 | */ 7 | 8 | #ifndef BITMAP_H_ 9 | #define BITMAP_H_ 10 | 11 | #include 12 | #include 13 | #include 14 | using namespace std; 15 | 16 | namespace caveofprogramming { 17 | 18 | class Bitmap { 19 | private: 20 | int m_width{0}; 21 | int m_height{0}; 22 | unique_ptr m_pPixels{nullptr}; 23 | 24 | 25 | public: 26 | Bitmap(int width, int height); 27 | void setPixel(int x, int y, uint8_t red, uint8_t green, uint8_t blue); 28 | bool write(string filename); 29 | virtual ~Bitmap(); 30 | }; 31 | 32 | } /* namespace caveofprogramming */ 33 | 34 | #endif /* BITMAP_H_ */ 35 | -------------------------------------------------------------------------------- /TheZoomList/src/BitmapFileHeader.h: -------------------------------------------------------------------------------- 1 | /* 2 | * BitmapFileHeader.h 3 | * 4 | * Created on: Jun 21, 2015 5 | * Author: johnpurcell 6 | */ 7 | 8 | #ifndef BITMAPFILEHEADER_H_ 9 | #define BITMAPFILEHEADER_H_ 10 | 11 | #include 12 | 13 | using namespace std; 14 | 15 | namespace caveofprogramming { 16 | 17 | #pragma pack(push, 2) 18 | 19 | struct BitmapFileHeader { 20 | char header[2] { 'B', 'M' }; 21 | int32_t fileSize; 22 | int32_t reserved { 0 }; 23 | int32_t dataOffset; 24 | }; 25 | 26 | #pragma pack(pop) 27 | 28 | } 29 | 30 | #endif /* BITMAPFILEHEADER_H_ */ 31 | -------------------------------------------------------------------------------- /TheZoomList/src/BitmapInfoHeader.h: -------------------------------------------------------------------------------- 1 | #ifndef BITMAPINFOHEADER_H_ 2 | #define BITMAPINFOHEADER_H_ 3 | 4 | #include 5 | 6 | using namespace std; 7 | 8 | namespace caveofprogramming { 9 | 10 | #pragma pack(push, 2) 11 | 12 | struct BitmapInfoHeader { 13 | int32_t headerSize{40}; 14 | int32_t width; 15 | int32_t height; 16 | int16_t planes{1}; 17 | int16_t bitsPerPixel{24}; 18 | int32_t compression{0}; 19 | int32_t dataSize{0}; 20 | int32_t horizontalResolution{2400}; 21 | int32_t verticalResolution{2400}; 22 | int32_t colors{0}; 23 | int32_t importantColors{0}; 24 | }; 25 | 26 | #pragma pack(pop) 27 | 28 | } 29 | 30 | #endif 31 | -------------------------------------------------------------------------------- /TheZoomList/src/Mandelbrot.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | * Mandelbrot.cpp 3 | * 4 | * Created on: Aug 21, 2015 5 | * Author: johnpurcell 6 | */ 7 | 8 | #include 9 | #include "Mandelbrot.h" 10 | 11 | using namespace std; 12 | 13 | namespace caveofprogramming { 14 | 15 | Mandelbrot::Mandelbrot() { 16 | // TODO Auto-generated constructor stub 17 | 18 | } 19 | 20 | Mandelbrot::~Mandelbrot() { 21 | // TODO Auto-generated destructor stub 22 | } 23 | 24 | int Mandelbrot::getIterations(double x, double y) { 25 | 26 | complex z = 0; 27 | complex c(x, y); 28 | 29 | int iterations = 0; 30 | 31 | while(iterations < MAX_ITERATIONS) { 32 | z = z*z + c; 33 | 34 | if(abs(z) > 2) { 35 | break; 36 | } 37 | 38 | iterations++; 39 | } 40 | 41 | return iterations; 42 | } 43 | 44 | } /* namespace caveofprogramming */ 45 | -------------------------------------------------------------------------------- /TheZoomList/src/Mandelbrot.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Mandelbrot.h 3 | * 4 | * Created on: Aug 21, 2015 5 | * Author: johnpurcell 6 | */ 7 | 8 | #ifndef MANDELBROT_H_ 9 | #define MANDELBROT_H_ 10 | 11 | namespace caveofprogramming { 12 | 13 | class Mandelbrot { 14 | public: 15 | static const int MAX_ITERATIONS = 1000; 16 | 17 | public: 18 | Mandelbrot(); 19 | virtual ~Mandelbrot(); 20 | 21 | static int getIterations(double x, double y); 22 | }; 23 | 24 | } /* namespace caveofprogramming */ 25 | 26 | #endif /* MANDELBROT_H_ */ 27 | -------------------------------------------------------------------------------- /TheZoomList/src/Zoom.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Zoom.h 3 | * 4 | * Created on: Sep 20, 2015 5 | * Author: johnpurcell 6 | */ 7 | 8 | #ifndef ZOOM_H_ 9 | #define ZOOM_H_ 10 | 11 | namespace caveofprogramming { 12 | 13 | struct Zoom { 14 | int x{0}; 15 | int y{0}; 16 | double scale{0.0}; 17 | 18 | Zoom(int x, int y, double scale) : x(x), y(y), scale(scale) {}; 19 | }; 20 | 21 | } /* namespace caveofprogramming */ 22 | 23 | #endif /* ZOOM_H_ */ 24 | -------------------------------------------------------------------------------- /TheZoomList/src/ZoomList.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | * ZoomList.cpp 3 | * 4 | * Created on: Sep 20, 2015 5 | * Author: johnpurcell 6 | */ 7 | 8 | #include "ZoomList.h" 9 | 10 | namespace caveofprogramming { 11 | 12 | ZoomList::ZoomList(int width, int height): m_width(width), m_height(height) { 13 | // TODO Auto-generated constructor stub 14 | 15 | } 16 | 17 | void ZoomList::add(const Zoom& zoom) { 18 | zooms.push_back(zoom); 19 | } 20 | 21 | pair ZoomList::doZoom(int x, int y) { 22 | return pair(0, 0); 23 | } 24 | 25 | } /* namespace caveofprogramming */ 26 | -------------------------------------------------------------------------------- /TheZoomList/src/ZoomList.h: -------------------------------------------------------------------------------- 1 | /* 2 | * ZoomList.h 3 | * 4 | * Created on: Sep 20, 2015 5 | * Author: johnpurcell 6 | */ 7 | 8 | #ifndef ZOOMLIST_H_ 9 | #define ZOOMLIST_H_ 10 | 11 | #include 12 | #include 13 | #include "Zoom.h" 14 | 15 | using namespace std; 16 | 17 | namespace caveofprogramming { 18 | 19 | class ZoomList { 20 | private: 21 | int m_width{0}; 22 | int m_height{0}; 23 | vector zooms; 24 | 25 | public: 26 | ZoomList(int width, int height); 27 | void add(const Zoom& zoom); 28 | pair doZoom(int x, int y); 29 | }; 30 | 31 | } /* namespace caveofprogramming */ 32 | 33 | #endif /* ZOOMLIST_H_ */ 34 | -------------------------------------------------------------------------------- /TwoDimensionalVectors/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | set(CMAKE_ARCHIVE_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/lib) 2 | set(CMAKE_LIBRARY_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/lib) 3 | set(CMAKE_RUNTIME_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/bin) 4 | 5 | set (CMAKE_CXX_STANDARD 11) 6 | cmake_minimum_required(VERSION 3.0) 7 | 8 | get_filename_component(ProjectId ${CMAKE_CURRENT_SOURCE_DIR} NAME) 9 | string(REPLACE " " "_" ProjectId ${ProjectId}) 10 | 11 | project(${ProjectId}) 12 | 13 | file(GLOB project_sources src/*.cpp) 14 | file(GLOB project_headers src/*.h src/*.hpp) 15 | 16 | add_executable(${ProjectId} ${project_sources} ${project_headers}) 17 | -------------------------------------------------------------------------------- /TwoDimensionalVectors/src/main.cpp: -------------------------------------------------------------------------------- 1 | //============================================================================ 2 | // Name : 3 | // Author : John Purcell 4 | // Version : 5 | // Copyright : Your copyright notice 6 | // Description : Hello World in C++, Ansi-style 7 | //============================================================================ 8 | 9 | #include 10 | #include 11 | 12 | using namespace std; 13 | 14 | int main() { 15 | vector< vector > grid(3, vector(4, 7)); 16 | 17 | grid[1].push_back(8); 18 | 19 | for(int row=0; row < grid.size(); row++) { 20 | for(int col=0; col < grid[row].size(); col++) { 21 | cout << grid[row][col] << flush; 22 | } 23 | 24 | cout << endl; 25 | } 26 | 27 | return 0; 28 | } 29 | -------------------------------------------------------------------------------- /UsingFunctionPointersAnExample/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | set(CMAKE_ARCHIVE_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/lib) 2 | set(CMAKE_LIBRARY_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/lib) 3 | set(CMAKE_RUNTIME_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/bin) 4 | 5 | set (CMAKE_CXX_STANDARD 11) 6 | cmake_minimum_required(VERSION 3.0) 7 | 8 | get_filename_component(ProjectId ${CMAKE_CURRENT_SOURCE_DIR} NAME) 9 | string(REPLACE " " "_" ProjectId ${ProjectId}) 10 | 11 | project(${ProjectId}) 12 | 13 | file(GLOB project_sources src/*.cpp) 14 | file(GLOB project_headers src/*.h src/*.hpp) 15 | 16 | add_executable(${ProjectId} ${project_sources} ${project_headers}) 17 | -------------------------------------------------------------------------------- /UsingtheHistogram/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | set(CMAKE_ARCHIVE_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/lib) 2 | set(CMAKE_LIBRARY_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/lib) 3 | set(CMAKE_RUNTIME_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/bin) 4 | 5 | set (CMAKE_CXX_STANDARD 11) 6 | cmake_minimum_required(VERSION 3.0) 7 | 8 | get_filename_component(ProjectId ${CMAKE_CURRENT_SOURCE_DIR} NAME) 9 | string(REPLACE " " "_" ProjectId ${ProjectId}) 10 | 11 | project(${ProjectId}) 12 | 13 | file(GLOB project_sources src/*.cpp) 14 | file(GLOB project_headers src/*.h src/*.hpp) 15 | 16 | add_executable(${ProjectId} ${project_sources} ${project_headers}) 17 | -------------------------------------------------------------------------------- /UsingtheHistogram/src/Bitmap.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Bitmap.h 3 | * 4 | * Created on: Jul 2, 2015 5 | * Author: johnpurcell 6 | */ 7 | 8 | #ifndef BITMAP_H_ 9 | #define BITMAP_H_ 10 | 11 | #include 12 | #include 13 | #include 14 | using namespace std; 15 | 16 | namespace caveofprogramming { 17 | 18 | class Bitmap { 19 | private: 20 | int m_width{0}; 21 | int m_height{0}; 22 | unique_ptr m_pPixels{nullptr}; 23 | 24 | 25 | public: 26 | Bitmap(int width, int height); 27 | void setPixel(int x, int y, uint8_t red, uint8_t green, uint8_t blue); 28 | bool write(string filename); 29 | virtual ~Bitmap(); 30 | }; 31 | 32 | } /* namespace caveofprogramming */ 33 | 34 | #endif /* BITMAP_H_ */ 35 | -------------------------------------------------------------------------------- /UsingtheHistogram/src/BitmapFileHeader.h: -------------------------------------------------------------------------------- 1 | /* 2 | * BitmapFileHeader.h 3 | * 4 | * Created on: Jun 21, 2015 5 | * Author: johnpurcell 6 | */ 7 | 8 | #ifndef BITMAPFILEHEADER_H_ 9 | #define BITMAPFILEHEADER_H_ 10 | 11 | #include 12 | 13 | using namespace std; 14 | 15 | namespace caveofprogramming { 16 | 17 | #pragma pack(push, 2) 18 | 19 | struct BitmapFileHeader { 20 | char header[2] { 'B', 'M' }; 21 | int32_t fileSize; 22 | int32_t reserved { 0 }; 23 | int32_t dataOffset; 24 | }; 25 | 26 | #pragma pack(pop) 27 | 28 | } 29 | 30 | #endif /* BITMAPFILEHEADER_H_ */ 31 | -------------------------------------------------------------------------------- /UsingtheHistogram/src/BitmapInfoHeader.h: -------------------------------------------------------------------------------- 1 | #ifndef BITMAPINFOHEADER_H_ 2 | #define BITMAPINFOHEADER_H_ 3 | 4 | #include 5 | 6 | using namespace std; 7 | 8 | namespace caveofprogramming { 9 | 10 | #pragma pack(push, 2) 11 | 12 | struct BitmapInfoHeader { 13 | int32_t headerSize{40}; 14 | int32_t width; 15 | int32_t height; 16 | int16_t planes{1}; 17 | int16_t bitsPerPixel{24}; 18 | int32_t compression{0}; 19 | int32_t dataSize{0}; 20 | int32_t horizontalResolution{2400}; 21 | int32_t verticalResolution{2400}; 22 | int32_t colors{0}; 23 | int32_t importantColors{0}; 24 | }; 25 | 26 | #pragma pack(pop) 27 | 28 | } 29 | 30 | #endif 31 | -------------------------------------------------------------------------------- /UsingtheHistogram/src/Mandelbrot.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | * Mandelbrot.cpp 3 | * 4 | * Created on: Aug 21, 2015 5 | * Author: johnpurcell 6 | */ 7 | 8 | #include 9 | #include "Mandelbrot.h" 10 | 11 | using namespace std; 12 | 13 | namespace caveofprogramming { 14 | 15 | Mandelbrot::Mandelbrot() { 16 | // TODO Auto-generated constructor stub 17 | 18 | } 19 | 20 | Mandelbrot::~Mandelbrot() { 21 | // TODO Auto-generated destructor stub 22 | } 23 | 24 | int Mandelbrot::getIterations(double x, double y) { 25 | 26 | complex z = 0; 27 | complex c(x, y); 28 | 29 | int iterations = 0; 30 | 31 | while(iterations < MAX_ITERATIONS) { 32 | z = z*z + c; 33 | 34 | if(abs(z) > 2) { 35 | break; 36 | } 37 | 38 | iterations++; 39 | } 40 | 41 | return iterations; 42 | } 43 | 44 | } /* namespace caveofprogramming */ 45 | -------------------------------------------------------------------------------- /UsingtheHistogram/src/Mandelbrot.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Mandelbrot.h 3 | * 4 | * Created on: Aug 21, 2015 5 | * Author: johnpurcell 6 | */ 7 | 8 | #ifndef MANDELBROT_H_ 9 | #define MANDELBROT_H_ 10 | 11 | namespace caveofprogramming { 12 | 13 | class Mandelbrot { 14 | public: 15 | static const int MAX_ITERATIONS = 1000; 16 | 17 | public: 18 | Mandelbrot(); 19 | virtual ~Mandelbrot(); 20 | 21 | static int getIterations(double x, double y); 22 | }; 23 | 24 | } /* namespace caveofprogramming */ 25 | 26 | #endif /* MANDELBROT_H_ */ 27 | -------------------------------------------------------------------------------- /UsingtheRGBClass/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | set(CMAKE_ARCHIVE_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/lib) 2 | set(CMAKE_LIBRARY_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/lib) 3 | set(CMAKE_RUNTIME_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/bin) 4 | 5 | set (CMAKE_CXX_STANDARD 11) 6 | cmake_minimum_required(VERSION 3.0) 7 | 8 | get_filename_component(ProjectId ${CMAKE_CURRENT_SOURCE_DIR} NAME) 9 | string(REPLACE " " "_" ProjectId ${ProjectId}) 10 | 11 | project(${ProjectId}) 12 | 13 | file(GLOB project_sources src/*.cpp) 14 | file(GLOB project_headers src/*.h src/*.hpp) 15 | 16 | add_executable(${ProjectId} ${project_sources} ${project_headers}) 17 | -------------------------------------------------------------------------------- /UsingtheRGBClass/src/Bitmap.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Bitmap.h 3 | * 4 | * Created on: Jul 2, 2015 5 | * Author: johnpurcell 6 | */ 7 | 8 | #ifndef BITMAP_H_ 9 | #define BITMAP_H_ 10 | 11 | #include 12 | #include 13 | #include 14 | using namespace std; 15 | 16 | namespace caveofprogramming { 17 | 18 | class Bitmap { 19 | private: 20 | int m_width{0}; 21 | int m_height{0}; 22 | unique_ptr m_pPixels{nullptr}; 23 | 24 | 25 | public: 26 | Bitmap(int width, int height); 27 | void setPixel(int x, int y, uint8_t red, uint8_t green, uint8_t blue); 28 | bool write(string filename); 29 | virtual ~Bitmap(); 30 | }; 31 | 32 | } /* namespace caveofprogramming */ 33 | 34 | #endif /* BITMAP_H_ */ 35 | -------------------------------------------------------------------------------- /UsingtheRGBClass/src/BitmapFileHeader.h: -------------------------------------------------------------------------------- 1 | /* 2 | * BitmapFileHeader.h 3 | * 4 | * Created on: Jun 21, 2015 5 | * Author: johnpurcell 6 | */ 7 | 8 | #ifndef BITMAPFILEHEADER_H_ 9 | #define BITMAPFILEHEADER_H_ 10 | 11 | #include 12 | 13 | using namespace std; 14 | 15 | namespace caveofprogramming { 16 | 17 | #pragma pack(push, 2) 18 | 19 | struct BitmapFileHeader { 20 | char header[2] { 'B', 'M' }; 21 | int32_t fileSize; 22 | int32_t reserved { 0 }; 23 | int32_t dataOffset; 24 | }; 25 | 26 | #pragma pack(pop) 27 | 28 | } 29 | 30 | #endif /* BITMAPFILEHEADER_H_ */ 31 | -------------------------------------------------------------------------------- /UsingtheRGBClass/src/BitmapInfoHeader.h: -------------------------------------------------------------------------------- 1 | #ifndef BITMAPINFOHEADER_H_ 2 | #define BITMAPINFOHEADER_H_ 3 | 4 | #include 5 | 6 | using namespace std; 7 | 8 | namespace caveofprogramming { 9 | 10 | #pragma pack(push, 2) 11 | 12 | struct BitmapInfoHeader { 13 | int32_t headerSize{40}; 14 | int32_t width; 15 | int32_t height; 16 | int16_t planes{1}; 17 | int16_t bitsPerPixel{24}; 18 | int32_t compression{0}; 19 | int32_t dataSize{0}; 20 | int32_t horizontalResolution{2400}; 21 | int32_t verticalResolution{2400}; 22 | int32_t colors{0}; 23 | int32_t importantColors{0}; 24 | }; 25 | 26 | #pragma pack(pop) 27 | 28 | } 29 | 30 | #endif 31 | -------------------------------------------------------------------------------- /UsingtheRGBClass/src/Mandelbrot.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Mandelbrot.h 3 | * 4 | * Created on: Aug 21, 2015 5 | * Author: johnpurcell 6 | */ 7 | 8 | #ifndef MANDELBROT_H_ 9 | #define MANDELBROT_H_ 10 | 11 | namespace caveofprogramming { 12 | 13 | class Mandelbrot { 14 | public: 15 | static const int MAX_ITERATIONS = 1000; 16 | 17 | public: 18 | Mandelbrot(); 19 | virtual ~Mandelbrot(); 20 | 21 | static int getIterations(double x, double y); 22 | }; 23 | 24 | } /* namespace caveofprogramming */ 25 | 26 | #endif /* MANDELBROT_H_ */ 27 | -------------------------------------------------------------------------------- /UsingtheRGBClass/src/RGB.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | * RGB.cpp 3 | * 4 | * Created on: Sep 21, 2015 5 | * Author: johnpurcell 6 | */ 7 | 8 | #include "RGB.h" 9 | 10 | namespace caveofprogramming { 11 | 12 | RGB::RGB(double r, double g, double b): r(r), g(g), b(b) { 13 | // TODO Auto-generated constructor stub 14 | 15 | } 16 | 17 | RGB operator-(const RGB& first, const RGB& second) { 18 | return RGB(first.r - second.r, first.g - second.g, first.b - second.b); 19 | } 20 | 21 | } /* namespace caveofprogramming */ 22 | -------------------------------------------------------------------------------- /UsingtheRGBClass/src/RGB.h: -------------------------------------------------------------------------------- 1 | /* 2 | * RGB.h 3 | * 4 | * Created on: Sep 21, 2015 5 | * Author: johnpurcell 6 | */ 7 | 8 | #ifndef RGB_H_ 9 | #define RGB_H_ 10 | 11 | namespace caveofprogramming { 12 | 13 | struct RGB { 14 | double r; 15 | double g; 16 | double b; 17 | 18 | RGB(double r, double g, double b); 19 | }; 20 | 21 | RGB operator-(const RGB& first, const RGB& second); 22 | 23 | } /* namespace caveofprogramming */ 24 | 25 | 26 | 27 | #endif /* RGB_H_ */ 28 | -------------------------------------------------------------------------------- /UsingtheRGBClass/src/Zoom.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Zoom.h 3 | * 4 | * Created on: Sep 20, 2015 5 | * Author: johnpurcell 6 | */ 7 | 8 | #ifndef ZOOM_H_ 9 | #define ZOOM_H_ 10 | 11 | namespace caveofprogramming { 12 | 13 | struct Zoom { 14 | int x{0}; 15 | int y{0}; 16 | double scale{0.0}; 17 | 18 | Zoom(int x, int y, double scale) : x(x), y(y), scale(scale) {}; 19 | }; 20 | 21 | } /* namespace caveofprogramming */ 22 | 23 | #endif /* ZOOM_H_ */ 24 | -------------------------------------------------------------------------------- /UsingtheRGBClass/src/ZoomList.h: -------------------------------------------------------------------------------- 1 | /* 2 | * ZoomList.h 3 | * 4 | * Created on: Sep 20, 2015 5 | * Author: johnpurcell 6 | */ 7 | 8 | #ifndef ZOOMLIST_H_ 9 | #define ZOOMLIST_H_ 10 | 11 | #include 12 | #include 13 | #include "Zoom.h" 14 | 15 | using namespace std; 16 | 17 | namespace caveofprogramming { 18 | 19 | class ZoomList { 20 | private: 21 | double m_xCenter{0}; 22 | double m_yCenter{0}; 23 | double m_scale{1.0}; 24 | 25 | int m_width{0}; 26 | int m_height{0}; 27 | vector zooms; 28 | 29 | public: 30 | ZoomList(int width, int height); 31 | void add(const Zoom& zoom); 32 | pair doZoom(int x, int y); 33 | }; 34 | 35 | } /* namespace caveofprogramming */ 36 | 37 | #endif /* ZOOMLIST_H_ */ 38 | -------------------------------------------------------------------------------- /UsingtheRGBClass/src/main.cpp: -------------------------------------------------------------------------------- 1 | //============================================================================ 2 | // Name : Fractal.cpp 3 | // Author : 4 | // Version : 5 | // Copyright : Your copyright notice 6 | // Description : Hello World in C++, Ansi-style 7 | //============================================================================ 8 | 9 | #include 10 | 11 | #include "FractalCreator.h" 12 | #include "Zoom.h" 13 | 14 | using namespace caveofprogramming; 15 | 16 | int main() { 17 | 18 | FractalCreator fractalCreator(800, 600); 19 | 20 | fractalCreator.addZoom(Zoom(295, 202, 0.1)); 21 | fractalCreator.addZoom(Zoom(312, 304, 0.1)); 22 | fractalCreator.run("test.bmp"); 23 | 24 | std::cout << "Finished." << std::endl; 25 | return 0; 26 | } 27 | -------------------------------------------------------------------------------- /ValidatingtheHistogram/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | set(CMAKE_ARCHIVE_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/lib) 2 | set(CMAKE_LIBRARY_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/lib) 3 | set(CMAKE_RUNTIME_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/bin) 4 | 5 | set (CMAKE_CXX_STANDARD 11) 6 | cmake_minimum_required(VERSION 3.0) 7 | 8 | get_filename_component(ProjectId ${CMAKE_CURRENT_SOURCE_DIR} NAME) 9 | string(REPLACE " " "_" ProjectId ${ProjectId}) 10 | 11 | project(${ProjectId}) 12 | 13 | file(GLOB project_sources src/*.cpp) 14 | file(GLOB project_headers src/*.h src/*.hpp) 15 | 16 | add_executable(${ProjectId} ${project_sources} ${project_headers}) 17 | -------------------------------------------------------------------------------- /ValidatingtheHistogram/src/Bitmap.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Bitmap.h 3 | * 4 | * Created on: Jul 2, 2015 5 | * Author: johnpurcell 6 | */ 7 | 8 | #ifndef BITMAP_H_ 9 | #define BITMAP_H_ 10 | 11 | #include 12 | #include 13 | #include 14 | using namespace std; 15 | 16 | namespace caveofprogramming { 17 | 18 | class Bitmap { 19 | private: 20 | int m_width{0}; 21 | int m_height{0}; 22 | unique_ptr m_pPixels{nullptr}; 23 | 24 | 25 | public: 26 | Bitmap(int width, int height); 27 | void setPixel(int x, int y, uint8_t red, uint8_t green, uint8_t blue); 28 | bool write(string filename); 29 | virtual ~Bitmap(); 30 | }; 31 | 32 | } /* namespace caveofprogramming */ 33 | 34 | #endif /* BITMAP_H_ */ 35 | -------------------------------------------------------------------------------- /ValidatingtheHistogram/src/BitmapFileHeader.h: -------------------------------------------------------------------------------- 1 | /* 2 | * BitmapFileHeader.h 3 | * 4 | * Created on: Jun 21, 2015 5 | * Author: johnpurcell 6 | */ 7 | 8 | #ifndef BITMAPFILEHEADER_H_ 9 | #define BITMAPFILEHEADER_H_ 10 | 11 | #include 12 | 13 | using namespace std; 14 | 15 | namespace caveofprogramming { 16 | 17 | #pragma pack(push, 2) 18 | 19 | struct BitmapFileHeader { 20 | char header[2] { 'B', 'M' }; 21 | int32_t fileSize; 22 | int32_t reserved { 0 }; 23 | int32_t dataOffset; 24 | }; 25 | 26 | #pragma pack(pop) 27 | 28 | } 29 | 30 | #endif /* BITMAPFILEHEADER_H_ */ 31 | -------------------------------------------------------------------------------- /ValidatingtheHistogram/src/BitmapInfoHeader.h: -------------------------------------------------------------------------------- 1 | #ifndef BITMAPINFOHEADER_H_ 2 | #define BITMAPINFOHEADER_H_ 3 | 4 | #include 5 | 6 | using namespace std; 7 | 8 | namespace caveofprogramming { 9 | 10 | #pragma pack(push, 2) 11 | 12 | struct BitmapInfoHeader { 13 | int32_t headerSize{40}; 14 | int32_t width; 15 | int32_t height; 16 | int16_t planes{1}; 17 | int16_t bitsPerPixel{24}; 18 | int32_t compression{0}; 19 | int32_t dataSize{0}; 20 | int32_t horizontalResolution{2400}; 21 | int32_t verticalResolution{2400}; 22 | int32_t colors{0}; 23 | int32_t importantColors{0}; 24 | }; 25 | 26 | #pragma pack(pop) 27 | 28 | } 29 | 30 | #endif 31 | -------------------------------------------------------------------------------- /ValidatingtheHistogram/src/Mandelbrot.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Mandelbrot.h 3 | * 4 | * Created on: Aug 21, 2015 5 | * Author: johnpurcell 6 | */ 7 | 8 | #ifndef MANDELBROT_H_ 9 | #define MANDELBROT_H_ 10 | 11 | namespace caveofprogramming { 12 | 13 | class Mandelbrot { 14 | public: 15 | static const int MAX_ITERATIONS = 1000; 16 | 17 | public: 18 | Mandelbrot(); 19 | virtual ~Mandelbrot(); 20 | 21 | static int getIterations(double x, double y); 22 | }; 23 | 24 | } /* namespace caveofprogramming */ 25 | 26 | #endif /* MANDELBROT_H_ */ 27 | -------------------------------------------------------------------------------- /Vectors/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | set(CMAKE_ARCHIVE_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/lib) 2 | set(CMAKE_LIBRARY_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/lib) 3 | set(CMAKE_RUNTIME_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/bin) 4 | 5 | set (CMAKE_CXX_STANDARD 11) 6 | cmake_minimum_required(VERSION 3.0) 7 | 8 | get_filename_component(ProjectId ${CMAKE_CURRENT_SOURCE_DIR} NAME) 9 | string(REPLACE " " "_" ProjectId ${ProjectId}) 10 | 11 | project(${ProjectId}) 12 | 13 | file(GLOB project_sources src/*.cpp) 14 | file(GLOB project_headers src/*.h src/*.hpp) 15 | 16 | add_executable(${ProjectId} ${project_sources} ${project_headers}) 17 | -------------------------------------------------------------------------------- /VectorsAndMemory/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | set(CMAKE_ARCHIVE_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/lib) 2 | set(CMAKE_LIBRARY_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/lib) 3 | set(CMAKE_RUNTIME_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/bin) 4 | 5 | set (CMAKE_CXX_STANDARD 11) 6 | cmake_minimum_required(VERSION 3.0) 7 | 8 | get_filename_component(ProjectId ${CMAKE_CURRENT_SOURCE_DIR} NAME) 9 | string(REPLACE " " "_" ProjectId ${ProjectId}) 10 | 11 | project(${ProjectId}) 12 | 13 | file(GLOB project_sources src/*.cpp) 14 | file(GLOB project_headers src/*.h src/*.hpp) 15 | 16 | add_executable(${ProjectId} ${project_sources} ${project_headers}) 17 | -------------------------------------------------------------------------------- /WritingABitmap/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | set(CMAKE_ARCHIVE_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/lib) 2 | set(CMAKE_LIBRARY_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/lib) 3 | set(CMAKE_RUNTIME_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/bin) 4 | 5 | set (CMAKE_CXX_STANDARD 11) 6 | cmake_minimum_required(VERSION 3.0) 7 | 8 | get_filename_component(ProjectId ${CMAKE_CURRENT_SOURCE_DIR} NAME) 9 | string(REPLACE " " "_" ProjectId ${ProjectId}) 10 | 11 | project(${ProjectId}) 12 | 13 | file(GLOB project_sources src/*.cpp) 14 | file(GLOB project_headers src/*.h src/*.hpp) 15 | 16 | add_executable(${ProjectId} ${project_sources} ${project_headers}) 17 | -------------------------------------------------------------------------------- /WritingABitmap/src/Bitmap.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Bitmap.h 3 | * 4 | * Created on: Jul 2, 2015 5 | * Author: johnpurcell 6 | */ 7 | 8 | #ifndef BITMAP_H_ 9 | #define BITMAP_H_ 10 | 11 | #include 12 | #include 13 | #include 14 | 15 | using namespace std; 16 | 17 | namespace caveofprogramming { 18 | 19 | class Bitmap { 20 | private: 21 | int m_width{0}; 22 | int m_height{0}; 23 | unique_ptr m_pPixels{nullptr}; 24 | 25 | 26 | public: 27 | Bitmap(int width, int height); 28 | void setPixel(int x, int y, uint8_t red, uint8_t green, uint8_t blue); 29 | bool write(string filename); 30 | virtual ~Bitmap(); 31 | }; 32 | 33 | } /* namespace caveofprogramming */ 34 | 35 | #endif /* BITMAP_H_ */ 36 | -------------------------------------------------------------------------------- /WritingABitmap/src/BitmapFileHeader.h: -------------------------------------------------------------------------------- 1 | /* 2 | * BitmapFileHeader.h 3 | * 4 | * Created on: Jun 21, 2015 5 | * Author: johnpurcell 6 | */ 7 | 8 | #ifndef BITMAPFILEHEADER_H_ 9 | #define BITMAPFILEHEADER_H_ 10 | 11 | #include 12 | 13 | using namespace std; 14 | 15 | namespace caveofprogramming { 16 | 17 | #pragma pack(push, 2) 18 | 19 | struct BitmapFileHeader { 20 | char header[2] { 'B', 'M' }; 21 | int32_t fileSize; 22 | int32_t reserved { 0 }; 23 | int32_t dataOffset; 24 | }; 25 | 26 | #pragma pack(pop) 27 | 28 | } 29 | 30 | #endif /* BITMAPFILEHEADER_H_ */ 31 | -------------------------------------------------------------------------------- /WritingABitmap/src/BitmapInfoHeader.h: -------------------------------------------------------------------------------- 1 | #ifndef BITMAPINFOHEADER_H_ 2 | #define BITMAPINFOHEADER_H_ 3 | 4 | #include 5 | 6 | using namespace std; 7 | 8 | namespace caveofprogramming { 9 | 10 | #pragma pack(push, 2) 11 | 12 | struct BitmapInfoHeader { 13 | int32_t headerSize{40}; 14 | int32_t width; 15 | int32_t height; 16 | int16_t planes{1}; 17 | int16_t bitsPerPixel{24}; 18 | int32_t compression{0}; 19 | int32_t dataSize{0}; 20 | int32_t horizontalResolution{2400}; 21 | int32_t verticalResolution{2400}; 22 | int32_t colors{0}; 23 | int32_t importantColors{0}; 24 | }; 25 | 26 | #pragma pack(pop) 27 | 28 | } 29 | 30 | #endif 31 | -------------------------------------------------------------------------------- /WritingABitmap/src/main.cpp: -------------------------------------------------------------------------------- 1 | //============================================================================ 2 | // Name : Fractal.cpp 3 | // Author : 4 | // Version : 5 | // Copyright : Your copyright notice 6 | // Description : Hello World in C++, Ansi-style 7 | //============================================================================ 8 | 9 | #include 10 | #include "Bitmap.h" 11 | 12 | using namespace std; 13 | using namespace caveofprogramming; 14 | 15 | int main() { 16 | 17 | Bitmap bitmap(800, 600); 18 | 19 | bitmap.write("test.bmp"); 20 | 21 | cout << "Finished." << endl; 22 | return 0; 23 | } 24 | -------------------------------------------------------------------------------- /WritingTextFiles/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | set(CMAKE_ARCHIVE_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/lib) 2 | set(CMAKE_LIBRARY_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/lib) 3 | set(CMAKE_RUNTIME_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/bin) 4 | 5 | set (CMAKE_CXX_STANDARD 11) 6 | cmake_minimum_required(VERSION 3.0) 7 | 8 | get_filename_component(ProjectId ${CMAKE_CURRENT_SOURCE_DIR} NAME) 9 | string(REPLACE " " "_" ProjectId ${ProjectId}) 10 | 11 | project(${ProjectId}) 12 | 13 | file(GLOB project_sources src/*.cpp) 14 | file(GLOB project_headers src/*.h src/*.hpp) 15 | 16 | add_executable(${ProjectId} ${project_sources} ${project_headers}) 17 | -------------------------------------------------------------------------------- /WritingTextFiles/text.txt: -------------------------------------------------------------------------------- 1 | Hello there 2 | 123 3 | -------------------------------------------------------------------------------- /ZoomingIn/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | set(CMAKE_ARCHIVE_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/lib) 2 | set(CMAKE_LIBRARY_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/lib) 3 | set(CMAKE_RUNTIME_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/bin) 4 | 5 | set (CMAKE_CXX_STANDARD 11) 6 | cmake_minimum_required(VERSION 3.0) 7 | 8 | get_filename_component(ProjectId ${CMAKE_CURRENT_SOURCE_DIR} NAME) 9 | string(REPLACE " " "_" ProjectId ${ProjectId}) 10 | 11 | project(${ProjectId}) 12 | 13 | file(GLOB project_sources src/*.cpp) 14 | file(GLOB project_headers src/*.h src/*.hpp) 15 | 16 | add_executable(${ProjectId} ${project_sources} ${project_headers}) 17 | -------------------------------------------------------------------------------- /ZoomingIn/src/Bitmap.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Bitmap.h 3 | * 4 | * Created on: Jul 2, 2015 5 | * Author: johnpurcell 6 | */ 7 | 8 | #ifndef BITMAP_H_ 9 | #define BITMAP_H_ 10 | 11 | #include 12 | #include 13 | #include 14 | using namespace std; 15 | 16 | namespace caveofprogramming { 17 | 18 | class Bitmap { 19 | private: 20 | int m_width{0}; 21 | int m_height{0}; 22 | unique_ptr m_pPixels{nullptr}; 23 | 24 | 25 | public: 26 | Bitmap(int width, int height); 27 | void setPixel(int x, int y, uint8_t red, uint8_t green, uint8_t blue); 28 | bool write(string filename); 29 | virtual ~Bitmap(); 30 | }; 31 | 32 | } /* namespace caveofprogramming */ 33 | 34 | #endif /* BITMAP_H_ */ 35 | -------------------------------------------------------------------------------- /ZoomingIn/src/BitmapFileHeader.h: -------------------------------------------------------------------------------- 1 | /* 2 | * BitmapFileHeader.h 3 | * 4 | * Created on: Jun 21, 2015 5 | * Author: johnpurcell 6 | */ 7 | 8 | #ifndef BITMAPFILEHEADER_H_ 9 | #define BITMAPFILEHEADER_H_ 10 | 11 | #include 12 | 13 | using namespace std; 14 | 15 | namespace caveofprogramming { 16 | 17 | #pragma pack(push, 2) 18 | 19 | struct BitmapFileHeader { 20 | char header[2] { 'B', 'M' }; 21 | int32_t fileSize; 22 | int32_t reserved { 0 }; 23 | int32_t dataOffset; 24 | }; 25 | 26 | #pragma pack(pop) 27 | 28 | } 29 | 30 | #endif /* BITMAPFILEHEADER_H_ */ 31 | -------------------------------------------------------------------------------- /ZoomingIn/src/BitmapInfoHeader.h: -------------------------------------------------------------------------------- 1 | #ifndef BITMAPINFOHEADER_H_ 2 | #define BITMAPINFOHEADER_H_ 3 | 4 | #include 5 | 6 | using namespace std; 7 | 8 | namespace caveofprogramming { 9 | 10 | #pragma pack(push, 2) 11 | 12 | struct BitmapInfoHeader { 13 | int32_t headerSize{40}; 14 | int32_t width; 15 | int32_t height; 16 | int16_t planes{1}; 17 | int16_t bitsPerPixel{24}; 18 | int32_t compression{0}; 19 | int32_t dataSize{0}; 20 | int32_t horizontalResolution{2400}; 21 | int32_t verticalResolution{2400}; 22 | int32_t colors{0}; 23 | int32_t importantColors{0}; 24 | }; 25 | 26 | #pragma pack(pop) 27 | 28 | } 29 | 30 | #endif 31 | -------------------------------------------------------------------------------- /ZoomingIn/src/Mandelbrot.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | * Mandelbrot.cpp 3 | * 4 | * Created on: Aug 21, 2015 5 | * Author: johnpurcell 6 | */ 7 | 8 | #include 9 | #include "Mandelbrot.h" 10 | 11 | using namespace std; 12 | 13 | namespace caveofprogramming { 14 | 15 | Mandelbrot::Mandelbrot() { 16 | // TODO Auto-generated constructor stub 17 | 18 | } 19 | 20 | Mandelbrot::~Mandelbrot() { 21 | // TODO Auto-generated destructor stub 22 | } 23 | 24 | int Mandelbrot::getIterations(double x, double y) { 25 | 26 | complex z = 0; 27 | complex c(x, y); 28 | 29 | int iterations = 0; 30 | 31 | while(iterations < MAX_ITERATIONS) { 32 | z = z*z + c; 33 | 34 | if(abs(z) > 2) { 35 | break; 36 | } 37 | 38 | iterations++; 39 | } 40 | 41 | return iterations; 42 | } 43 | 44 | } /* namespace caveofprogramming */ 45 | -------------------------------------------------------------------------------- /ZoomingIn/src/Mandelbrot.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Mandelbrot.h 3 | * 4 | * Created on: Aug 21, 2015 5 | * Author: johnpurcell 6 | */ 7 | 8 | #ifndef MANDELBROT_H_ 9 | #define MANDELBROT_H_ 10 | 11 | namespace caveofprogramming { 12 | 13 | class Mandelbrot { 14 | public: 15 | static const int MAX_ITERATIONS = 1000; 16 | 17 | public: 18 | Mandelbrot(); 19 | virtual ~Mandelbrot(); 20 | 21 | static int getIterations(double x, double y); 22 | }; 23 | 24 | } /* namespace caveofprogramming */ 25 | 26 | #endif /* MANDELBROT_H_ */ 27 | -------------------------------------------------------------------------------- /ZoomingIn/src/Zoom.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Zoom.h 3 | * 4 | * Created on: Sep 20, 2015 5 | * Author: johnpurcell 6 | */ 7 | 8 | #ifndef ZOOM_H_ 9 | #define ZOOM_H_ 10 | 11 | namespace caveofprogramming { 12 | 13 | struct Zoom { 14 | int x{0}; 15 | int y{0}; 16 | double scale{0.0}; 17 | 18 | Zoom(int x, int y, double scale) : x(x), y(y), scale(scale) {}; 19 | }; 20 | 21 | } /* namespace caveofprogramming */ 22 | 23 | #endif /* ZOOM_H_ */ 24 | -------------------------------------------------------------------------------- /ZoomingIn/src/ZoomList.h: -------------------------------------------------------------------------------- 1 | /* 2 | * ZoomList.h 3 | * 4 | * Created on: Sep 20, 2015 5 | * Author: johnpurcell 6 | */ 7 | 8 | #ifndef ZOOMLIST_H_ 9 | #define ZOOMLIST_H_ 10 | 11 | #include 12 | #include 13 | #include "Zoom.h" 14 | 15 | using namespace std; 16 | 17 | namespace caveofprogramming { 18 | 19 | class ZoomList { 20 | private: 21 | double m_xCenter{0}; 22 | double m_yCenter{0}; 23 | double m_scale{1.0}; 24 | 25 | int m_width{0}; 26 | int m_height{0}; 27 | vector zooms; 28 | 29 | public: 30 | ZoomList(int width, int height); 31 | void add(const Zoom& zoom); 32 | pair doZoom(int x, int y); 33 | }; 34 | 35 | } /* namespace caveofprogramming */ 36 | 37 | #endif /* ZOOMLIST_H_ */ 38 | -------------------------------------------------------------------------------- /lValuesandrValues/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | set(CMAKE_ARCHIVE_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/lib) 2 | set(CMAKE_LIBRARY_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/lib) 3 | set(CMAKE_RUNTIME_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/bin) 4 | 5 | set (CMAKE_CXX_STANDARD 11) 6 | cmake_minimum_required(VERSION 3.0) 7 | 8 | get_filename_component(ProjectId ${CMAKE_CURRENT_SOURCE_DIR} NAME) 9 | string(REPLACE " " "_" ProjectId ${ProjectId}) 10 | 11 | project(${ProjectId}) 12 | 13 | file(GLOB project_sources src/*.cpp) 14 | file(GLOB project_headers src/*.h src/*.hpp) 15 | 16 | add_executable(${ProjectId} ${project_sources} ${project_headers}) 17 | --------------------------------------------------------------------------------