├── .gitignore
├── 3rdparty
├── easylogging++
│ └── easylogging++.h
├── flatbuffers
│ ├── flatbuffers.h
│ ├── idl.h
│ └── util.h
├── gtest-1.7.0
│ ├── CHANGES
│ ├── CMakeLists.txt
│ ├── CONTRIBUTORS
│ ├── LICENSE
│ ├── Makefile.am
│ ├── Makefile.in
│ ├── README
│ ├── aclocal.m4
│ ├── build-aux
│ │ ├── config.guess
│ │ ├── config.h.in
│ │ ├── config.sub
│ │ ├── depcomp
│ │ ├── install-sh
│ │ ├── ltmain.sh
│ │ └── missing
│ ├── cmake
│ │ └── internal_utils.cmake
│ ├── codegear
│ │ ├── gtest.cbproj
│ │ ├── gtest.groupproj
│ │ ├── gtest_all.cc
│ │ ├── gtest_link.cc
│ │ ├── gtest_main.cbproj
│ │ └── gtest_unittest.cbproj
│ ├── configure
│ ├── configure.ac
│ ├── fused-src
│ │ └── gtest
│ │ │ ├── gtest-all.cc
│ │ │ ├── gtest.h
│ │ │ └── gtest_main.cc
│ ├── include
│ │ └── gtest
│ │ │ ├── gtest-death-test.h
│ │ │ ├── gtest-message.h
│ │ │ ├── gtest-param-test.h
│ │ │ ├── gtest-param-test.h.pump
│ │ │ ├── gtest-printers.h
│ │ │ ├── gtest-spi.h
│ │ │ ├── gtest-test-part.h
│ │ │ ├── gtest-typed-test.h
│ │ │ ├── gtest.h
│ │ │ ├── gtest_pred_impl.h
│ │ │ ├── gtest_prod.h
│ │ │ └── internal
│ │ │ ├── gtest-death-test-internal.h
│ │ │ ├── gtest-filepath.h
│ │ │ ├── gtest-internal.h
│ │ │ ├── gtest-linked_ptr.h
│ │ │ ├── gtest-param-util-generated.h
│ │ │ ├── gtest-param-util-generated.h.pump
│ │ │ ├── gtest-param-util.h
│ │ │ ├── gtest-port.h
│ │ │ ├── gtest-string.h
│ │ │ ├── gtest-tuple.h
│ │ │ ├── gtest-tuple.h.pump
│ │ │ ├── gtest-type-util.h
│ │ │ └── gtest-type-util.h.pump
│ ├── m4
│ │ ├── acx_pthread.m4
│ │ ├── gtest.m4
│ │ ├── libtool.m4
│ │ ├── ltoptions.m4
│ │ ├── ltsugar.m4
│ │ ├── ltversion.m4
│ │ └── lt~obsolete.m4
│ ├── make
│ │ └── Makefile
│ ├── msvc
│ │ ├── gtest-md.sln
│ │ ├── gtest-md.vcproj
│ │ ├── gtest.sln
│ │ ├── gtest.vcproj
│ │ ├── gtest_main-md.vcproj
│ │ ├── gtest_main.vcproj
│ │ ├── gtest_prod_test-md.vcproj
│ │ ├── gtest_prod_test.vcproj
│ │ ├── gtest_unittest-md.vcproj
│ │ └── gtest_unittest.vcproj
│ ├── samples
│ │ ├── prime_tables.h
│ │ ├── sample1.cc
│ │ ├── sample1.h
│ │ ├── sample10_unittest.cc
│ │ ├── sample1_unittest.cc
│ │ ├── sample2.cc
│ │ ├── sample2.h
│ │ ├── sample2_unittest.cc
│ │ ├── sample3-inl.h
│ │ ├── sample3_unittest.cc
│ │ ├── sample4.cc
│ │ ├── sample4.h
│ │ ├── sample4_unittest.cc
│ │ ├── sample5_unittest.cc
│ │ ├── sample6_unittest.cc
│ │ ├── sample7_unittest.cc
│ │ ├── sample8_unittest.cc
│ │ └── sample9_unittest.cc
│ ├── scripts
│ │ ├── fuse_gtest_files.py
│ │ ├── gen_gtest_pred_impl.py
│ │ ├── gtest-config.in
│ │ ├── pump.py
│ │ └── test
│ │ │ └── Makefile
│ ├── src
│ │ ├── gtest-all.cc
│ │ ├── gtest-death-test.cc
│ │ ├── gtest-filepath.cc
│ │ ├── gtest-internal-inl.h
│ │ ├── gtest-port.cc
│ │ ├── gtest-printers.cc
│ │ ├── gtest-test-part.cc
│ │ ├── gtest-typed-test.cc
│ │ ├── gtest.cc
│ │ └── gtest_main.cc
│ ├── test
│ │ ├── gtest-death-test_ex_test.cc
│ │ ├── gtest-death-test_test.cc
│ │ ├── gtest-filepath_test.cc
│ │ ├── gtest-linked_ptr_test.cc
│ │ ├── gtest-listener_test.cc
│ │ ├── gtest-message_test.cc
│ │ ├── gtest-options_test.cc
│ │ ├── gtest-param-test2_test.cc
│ │ ├── gtest-param-test_test.cc
│ │ ├── gtest-param-test_test.h
│ │ ├── gtest-port_test.cc
│ │ ├── gtest-printers_test.cc
│ │ ├── gtest-test-part_test.cc
│ │ ├── gtest-tuple_test.cc
│ │ ├── gtest-typed-test2_test.cc
│ │ ├── gtest-typed-test_test.cc
│ │ ├── gtest-typed-test_test.h
│ │ ├── gtest-unittest-api_test.cc
│ │ ├── gtest_all_test.cc
│ │ ├── gtest_break_on_failure_unittest.py
│ │ ├── gtest_break_on_failure_unittest_.cc
│ │ ├── gtest_catch_exceptions_test.py
│ │ ├── gtest_catch_exceptions_test_.cc
│ │ ├── gtest_color_test.py
│ │ ├── gtest_color_test_.cc
│ │ ├── gtest_env_var_test.py
│ │ ├── gtest_env_var_test_.cc
│ │ ├── gtest_environment_test.cc
│ │ ├── gtest_filter_unittest.py
│ │ ├── gtest_filter_unittest_.cc
│ │ ├── gtest_help_test.py
│ │ ├── gtest_help_test_.cc
│ │ ├── gtest_list_tests_unittest.py
│ │ ├── gtest_list_tests_unittest_.cc
│ │ ├── gtest_main_unittest.cc
│ │ ├── gtest_no_test_unittest.cc
│ │ ├── gtest_output_test.py
│ │ ├── gtest_output_test_.cc
│ │ ├── gtest_output_test_golden_lin.txt
│ │ ├── gtest_pred_impl_unittest.cc
│ │ ├── gtest_premature_exit_test.cc
│ │ ├── gtest_prod_test.cc
│ │ ├── gtest_repeat_test.cc
│ │ ├── gtest_shuffle_test.py
│ │ ├── gtest_shuffle_test_.cc
│ │ ├── gtest_sole_header_test.cc
│ │ ├── gtest_stress_test.cc
│ │ ├── gtest_test_utils.py
│ │ ├── gtest_throw_on_failure_ex_test.cc
│ │ ├── gtest_throw_on_failure_test.py
│ │ ├── gtest_throw_on_failure_test_.cc
│ │ ├── gtest_uninitialized_test.py
│ │ ├── gtest_uninitialized_test_.cc
│ │ ├── gtest_unittest.cc
│ │ ├── gtest_xml_outfile1_test_.cc
│ │ ├── gtest_xml_outfile2_test_.cc
│ │ ├── gtest_xml_outfiles_test.py
│ │ ├── gtest_xml_output_unittest.py
│ │ ├── gtest_xml_output_unittest_.cc
│ │ ├── gtest_xml_test_utils.py
│ │ ├── production.cc
│ │ └── production.h
│ └── xcode
│ │ ├── Config
│ │ ├── DebugProject.xcconfig
│ │ ├── FrameworkTarget.xcconfig
│ │ ├── General.xcconfig
│ │ ├── ReleaseProject.xcconfig
│ │ ├── StaticLibraryTarget.xcconfig
│ │ └── TestTarget.xcconfig
│ │ ├── Resources
│ │ └── Info.plist
│ │ ├── Samples
│ │ └── FrameworkSample
│ │ │ ├── Info.plist
│ │ │ ├── WidgetFramework.xcodeproj
│ │ │ └── project.pbxproj
│ │ │ ├── runtests.sh
│ │ │ ├── widget.cc
│ │ │ ├── widget.h
│ │ │ └── widget_test.cc
│ │ ├── Scripts
│ │ ├── runtests.sh
│ │ └── versiongenerate.py
│ │ └── gtest.xcodeproj
│ │ └── project.pbxproj
├── lib
│ ├── gtest.lib
│ └── gtestd.lib
└── xml
│ ├── Markup.cpp
│ ├── Markup.h
│ └── pugixml
│ ├── pugiconfig.hpp
│ ├── pugixml.cpp
│ └── pugixml.hpp
├── CppLanguagePrograms.sln
├── DesignPatternOf23Kinds.sln
├── DesignPatternOf23Kinds
├── AbstractFactory
│ ├── AbstractFactory.cpp
│ ├── AbstractFactory.h
│ ├── AbstractFactory.vcxproj
│ ├── AbstractFactory.vcxproj.filters
│ ├── Product.cpp
│ ├── Product.h
│ └── testAbstractFactory.cpp
├── Adapter
│ ├── Adapter.vcxproj
│ ├── Adapter.vcxproj.filters
│ ├── AdapterOfClass.h
│ ├── AdapterOfObject.h
│ └── testAdapter.cpp
├── Bridge
│ ├── Abstraction.h
│ ├── AbstractionImp.h
│ ├── Bridge.vcxproj
│ ├── Bridge.vcxproj.filters
│ └── testBridge.cpp
├── Builder
│ ├── Builder.h
│ ├── Builder.vcxproj
│ ├── Builder.vcxproj.filters
│ ├── Director.h
│ ├── Product.h
│ └── testBuilder.cpp
├── ChainOfResponsibility
│ ├── ChainOfResponsibility.vcxproj
│ ├── ChainOfResponsibility.vcxproj.filters
│ ├── Handle.h
│ └── testChainOfResponsibility.cpp
├── Command
│ ├── Command.h
│ ├── Command.vcxproj
│ ├── Command.vcxproj.filters
│ ├── Invoker.h
│ ├── Reciever.h
│ └── testCommand.cpp
├── Composite
│ ├── Component.h
│ ├── Composite.h
│ ├── Composite.vcxproj
│ ├── Composite.vcxproj.filters
│ ├── Leaf.h
│ └── testComposite.cpp
├── Decorator
│ ├── Decorator.h
│ ├── Decorator.vcxproj
│ ├── Decorator.vcxproj.filters
│ └── testDecorator.cpp
├── DesignPatternOf23Kinds
│ ├── DesignPatternOf23Kinds.vcxproj
│ ├── DesignPatternOf23Kinds.vcxproj.filters
│ └── main.cpp
├── Facade
│ ├── Facade.h
│ ├── Facade.vcxproj
│ ├── Facade.vcxproj.filters
│ └── testFacade.cpp
├── FactoryMethod
│ ├── Factory.h
│ ├── FactoryMethod.vcxproj
│ ├── FactoryMethod.vcxproj.filters
│ ├── Product.h
│ └── testFactoryMethod.cpp
├── Flyweight
│ ├── Flyweight.h
│ ├── Flyweight.vcxproj
│ ├── Flyweight.vcxproj.filters
│ ├── FlyweightFactory.h
│ └── testFlyweight.cpp
├── Interpreter
│ ├── Context.h
│ ├── Interpret.cpp
│ ├── Interpret.h
│ ├── Interpreter.cpp
│ ├── Interpreter.vcxproj
│ └── Interpreter.vcxproj.filters
├── Iterator
│ ├── Aggregate.cpp
│ ├── Aggregate.h
│ ├── Iterator.cpp
│ ├── Iterator.h
│ ├── Iterator.vcxproj
│ ├── Iterator.vcxproj.filters
│ └── testIterator.cpp
├── Mediator
│ ├── Colleage.cpp
│ ├── Colleage.h
│ ├── Mediator.cpp
│ ├── Mediator.h
│ ├── Mediator.vcxproj
│ ├── Mediator.vcxproj.filters
│ └── testMediator.cpp
├── Memento
│ ├── Memento.cpp
│ ├── Memento.h
│ ├── Memento.vcxproj
│ ├── Memento.vcxproj.filters
│ └── testMemento.cpp
├── Observer
│ ├── Observer.cpp
│ ├── Observer.h
│ ├── Observer.vcxproj
│ ├── Observer.vcxproj.filters
│ ├── Subject.cpp
│ ├── Subject.h
│ └── testObserver.cpp
├── Prototype
│ ├── Prototype.h
│ ├── Prototype.vcxproj
│ ├── Prototype.vcxproj.filters
│ └── testPrototype.cpp
├── Proxy
│ ├── Proxy.h
│ ├── Proxy.vcxproj
│ ├── Proxy.vcxproj.filters
│ └── testProxy.cpp
├── Singleton
│ ├── Singleton.h
│ ├── Singleton.vcxproj
│ ├── Singleton.vcxproj.filters
│ └── testSingleton.cpp
├── State
│ ├── Context.cpp
│ ├── Context.h
│ ├── State.cpp
│ ├── State.h
│ ├── State.vcxproj
│ ├── State.vcxproj.filters
│ └── testState.cpp
├── Strategy
│ ├── Context.h
│ ├── Strategy.h
│ ├── Strategy.vcxproj
│ ├── Strategy.vcxproj.filters
│ └── testStrategy.cpp
├── Template
│ ├── Template.h
│ ├── Template.vcxproj
│ ├── Template.vcxproj.filters
│ └── testTemplate.cpp
└── Visitor
│ ├── Element.cpp
│ ├── Element.h
│ ├── Visitor.h
│ ├── Visitor.vcxproj
│ ├── Visitor.vcxproj.filters
│ └── testVisitor.cpp
├── LICENSE
├── README.md
├── STL
├── dequeDemo
│ ├── dequeDemo.cpp
│ ├── dequeDemo.vcxproj
│ └── dequeDemo.vcxproj.filters
├── find和find_if
│ ├── find和find_if.cpp
│ ├── find和find_if.vcxproj
│ └── find和find_if.vcxproj.filters
├── for_each
│ ├── for_each.cpp
│ ├── for_each.vcxproj
│ └── for_each.vcxproj.filters
├── heapDemo
│ ├── heapDemo.cpp
│ ├── heapDemo.vcxproj
│ └── heapDemo.vcxproj.filters
├── intrusive_list
│ ├── intrusive_list.h
│ ├── intrusive_list.vcxproj
│ ├── intrusive_list.vcxproj.filters
│ └── intrusive_list_test.cpp
├── listDemo
│ ├── listDemo.cpp
│ ├── listDemo.vcxproj
│ └── listDemo.vcxproj.filters
├── mapDemo
│ ├── mapDemo.cpp
│ ├── mapDemo.vcxproj
│ └── mapDemo.vcxproj.filters
├── multimapDemo
│ ├── multimapDemo.cpp
│ ├── multimapDemo.vcxproj
│ └── multimapDemo.vcxproj.filters
├── multisetDemo
│ ├── multisetDemo.cpp
│ ├── multisetDemo.vcxproj
│ └── multisetDemo.vcxproj.filters
├── queueDemo
│ ├── queueDemo.cpp
│ ├── queueDemo.vcxproj
│ └── queueDemo.vcxproj.filters
├── setDemo
│ ├── setDemo.cpp
│ ├── setDemo.vcxproj
│ └── setDemo.vcxproj.filters
├── stackDemo
│ ├── stackDemo.cpp
│ ├── stackDemo.vcxproj
│ └── stackDemo.vcxproj.filters
├── string分割
│ ├── string分割.cpp
│ ├── string分割.vcxproj
│ └── string分割.vcxproj.filters
├── vectorDemo
│ ├── vectorDemo.cpp
│ ├── vectorDemo.vcxproj
│ └── vectorDemo.vcxproj.filters
├── vector_list
│ ├── test_vector_list.cpp
│ ├── vector_list.vcxproj
│ └── vector_list.vcxproj.filters
└── vector和map
│ ├── vector和map.cpp
│ ├── vector和map.vcxproj
│ └── vector和map.vcxproj.filters
├── Tools.sln
├── clear_vs.bat
├── include
├── Define.h
├── OsDefine.h
├── base
│ ├── AsyncLogger.cpp
│ ├── AsyncLogger.h
│ ├── Bitset.h
│ ├── ByteArray.cpp
│ ├── ByteArray.h
│ ├── Closure.h
│ ├── Daemonize.cpp
│ ├── Daemonize.h
│ ├── Date.cpp
│ ├── Date.h
│ ├── DateTimeUtil.cpp
│ ├── DateTimeUtil.h
│ ├── Demangle.cpp
│ ├── Demangle.h
│ ├── Exception.cpp
│ ├── Exception.h
│ ├── File.cpp
│ ├── File.h
│ ├── FileUtil.cpp
│ ├── FileUtil.h
│ ├── GBKtoUTF8.cpp
│ ├── GBKtoUTF8.h
│ ├── HighPrecisionTime.h
│ ├── Histogram.cpp
│ ├── IntrusiveList.h
│ ├── LogFile.cpp
│ ├── LogFile.h
│ ├── Logger.cpp
│ ├── Logger.h
│ ├── Makefile.am
│ ├── MasterWorkerProcess.cpp
│ ├── MasterWorkerProcess.h
│ ├── MathUtil.h
│ ├── NonCopy.h
│ ├── ObjectPool.h
│ ├── Process.cpp
│ ├── Process.h
│ ├── ProcessTimeCounter.h
│ ├── ProcessUtil.cpp
│ ├── ProcessUtil.h
│ ├── ScopeExitGuard.h
│ ├── Singleton.h
│ ├── SmartAssert.h
│ ├── StlUtil.h
│ ├── StopWatch.h
│ ├── StringPiece.cpp
│ ├── StringPiece.h
│ ├── StringUtil.cpp
│ ├── StringUtil.h
│ ├── Timestamp.cpp
│ ├── Timestamp.h
│ ├── histogram.h
│ └── tests
│ │ ├── AsyncLogger_test.cpp
│ │ ├── Daemon_test.cpp
│ │ ├── Demangle_test.cpp
│ │ ├── Exception_Demangle_test.cpp
│ │ ├── Exception_test.cpp
│ │ ├── Logger_test.cpp
│ │ ├── Makefile.am
│ │ ├── MasterWorkerProcess_test.cpp
│ │ ├── ObjectPool_test.cpp
│ │ ├── ProcessUtil_test.cpp
│ │ ├── Process_test.cpp
│ │ ├── ScopeExitGuard_test.cpp
│ │ ├── SmartAssert_test.cpp
│ │ ├── StlUtil_test.cpp
│ │ ├── StringUtil_test.cpp
│ │ └── Timestamp_test.cpp
├── meta
│ └── meta_util.hpp
├── net
│ ├── ActiveSocket.cpp
│ ├── ActiveSocket.h
│ ├── ByteBuffer.cpp
│ ├── ByteBuffer.h
│ ├── CallBacks.h
│ ├── Channel.cpp
│ ├── Channel.h
│ ├── DomainResolver.cpp
│ ├── DomainResolver.h
│ ├── EventLoop.cpp
│ ├── EventLoop.h
│ ├── EventLoopThreadPool.cpp
│ ├── EventLoopThreadPool.h
│ ├── Eventfd.cpp
│ ├── Eventfd.h
│ ├── InetAddress.cpp
│ ├── InetAddress.h
│ ├── Makefile.am
│ ├── NetUtil.cpp
│ ├── NetUtil.h
│ ├── PassiveSocket.cpp
│ ├── PassiveSocket.h
│ ├── PipePairFactory.h
│ ├── SignalHandler.cpp
│ ├── SignalHandler.h
│ ├── Signalfd.cpp
│ ├── Signalfd.h
│ ├── Socket.cpp
│ ├── Socket.h
│ ├── SocketUtil.cpp
│ ├── SocketUtil.h
│ ├── TcpAcceptor.cpp
│ ├── TcpAcceptor.h
│ ├── TcpClient.cpp
│ ├── TcpClient.h
│ ├── TcpConnection.cpp
│ ├── TcpConnection.h
│ ├── TcpConnector.cpp
│ ├── TcpConnector.h
│ ├── TcpServer.cpp
│ ├── TcpServer.h
│ ├── Timer.cpp
│ ├── Timer.h
│ ├── TimerQueue.cpp
│ ├── TimerQueue.h
│ ├── Timerfd.cpp
│ ├── Timerfd.h
│ ├── http
│ │ ├── HttpContext.cpp
│ │ ├── HttpContext.h
│ │ ├── HttpKeyValue.cpp
│ │ ├── HttpKeyValue.h
│ │ ├── HttpProtocol.h
│ │ ├── HttpRequest.cpp
│ │ ├── HttpRequest.h
│ │ ├── HttpResponse.cpp
│ │ ├── HttpResponse.h
│ │ ├── HttpServer.cpp
│ │ └── HttpServer.h
│ ├── poller
│ │ ├── EpollPoller.cpp
│ │ ├── EpollPoller.h
│ │ ├── PollPoller.cpp
│ │ ├── PollPoller.h
│ │ ├── Poller.cpp
│ │ ├── Poller.h
│ │ ├── SelectPoller.cpp
│ │ └── SelectPoller.h
│ └── tests
│ │ ├── DomainResolver_test.cpp
│ │ ├── EventLoopThreadPool_test.cpp
│ │ ├── EventLoop_test.cpp
│ │ ├── Eventfd_test.cpp
│ │ ├── HttpRequestParser_test.cpp
│ │ ├── InetAddress_test.cpp
│ │ ├── Makefile.am
│ │ ├── NetBuffer_test.cpp
│ │ ├── Signalfd_test.cpp
│ │ ├── Socket_test.cpp
│ │ ├── TcpAcceptor_test.cpp
│ │ ├── TcpClient_test.cpp
│ │ ├── Timer_test.cpp
│ │ └── Timerfd_test.cpp
├── smart_ptr
│ ├── enable_shared_from_this.h
│ ├── shared_ptr.h
│ ├── smart_ptr.h
│ ├── unique_ptr.h
│ └── weak_ptr.h
├── stl
│ ├── SkipList.h
│ ├── any.h
│ ├── array.h
│ ├── iterator.h
│ ├── range.h
│ └── tests
│ │ ├── any_test.cpp
│ │ ├── array_test.cpp
│ │ ├── iterator_test.cpp
│ │ └── range_test.cpp
├── thread
│ ├── Atomic.h
│ ├── BlockingQueue.h
│ ├── BlockingQueueWorker.h
│ ├── BoundedBlockingQueue.h
│ ├── Condition.h
│ ├── CountDownLatch.h
│ ├── FastMutex.h
│ ├── Makefile.am
│ ├── Mutex.h
│ ├── RWMutex.h
│ ├── Semaphore.h
│ ├── Thread.cpp
│ ├── Thread.h
│ ├── ThreadGroup.cpp
│ ├── ThreadGroup.h
│ ├── ThreadLocal.h
│ ├── ThreadPool.cpp
│ ├── ThreadPool.h
│ └── tests
│ │ ├── Atomic_test.cpp
│ │ ├── BlockingQueueWorker_test.cpp
│ │ ├── BlockingQueue_test.cpp
│ │ ├── CountDownLatch_test.cpp
│ │ ├── Makefile.am
│ │ ├── Mutex_test.cpp
│ │ ├── ThreadGroup_test.cpp
│ │ ├── ThreadId_test.cpp
│ │ ├── ThreadLocal_test.cpp
│ │ └── Thread_test.cpp
└── utility
│ ├── Base64.cpp
│ ├── Base64.h
│ ├── CRC32.cpp
│ ├── CRC32.h
│ ├── Hex2String.h
│ ├── Md5.cpp
│ ├── Md5.h
│ ├── SHA1.cpp
│ ├── SHA1.h
│ ├── StringHash.cpp
│ ├── StringHash.h
│ ├── UUID.h
│ ├── WildCard.cpp
│ ├── WildCard.h
│ ├── aes.c
│ ├── aes.h
│ ├── city.cc
│ ├── city.h
│ ├── citycrc.h
│ ├── jenkins_hash.c
│ ├── jenkins_hash.h
│ ├── murmur3_hash.c
│ └── murmur3_hash.h
├── test_3rdparty
├── Google_FlatBuffers_Test
│ ├── Google_FlatBuffers_Test.vcxproj
│ ├── Google_FlatBuffers_Test.vcxproj.GhostDoc.xml
│ ├── Google_FlatBuffers_Test.vcxproj.filters
│ ├── gfb
│ │ ├── flatc.exe
│ │ ├── person_infos.fbs
│ │ ├── readme.txt
│ │ ├── t.fbs
│ │ └── t_generated.h
│ ├── main.cpp
│ ├── monster_generated.h
│ └── person_infos_generated.h
├── test_easylogging++
│ ├── test_easylogging++.cpp
│ ├── test_easylogging++.vcxproj
│ └── test_easylogging++.vcxproj.filters
└── test_gtest
│ ├── test_gtest.cpp
│ ├── test_gtest.vcxproj
│ └── test_gtest.vcxproj.filters
├── test_net
├── InetAddressTest
│ ├── InetAddressTest.cpp
│ ├── InetAddressTest.vcxproj
│ └── InetAddressTest.vcxproj.filters
├── NetUtilTest
│ ├── NetUtilTest.cpp
│ ├── NetUtilTest.vcxproj
│ └── NetUtilTest.vcxproj.filters
└── Test_Timer
│ ├── Test_Timer.vcxproj
│ ├── Test_Timer.vcxproj.filters
│ ├── Timer.cpp
│ ├── Timer.h
│ ├── TimerQueue.cpp
│ ├── TimerQueue.h
│ └── Timer_Test.cpp
├── test_some
├── do-while(0)
│ ├── do-while(0).cpp
│ ├── do-while(0).vcxproj
│ └── do-while(0).vcxproj.filters
├── strlen_sizeof
│ ├── strlen_sizeof.cpp
│ ├── strlen_sizeof.vcxproj
│ └── strlen_sizeof.vcxproj.filters
├── time
│ ├── test_time.cpp
│ ├── time.vcxproj
│ └── time.vcxproj.filters
├── 函数对象Demo
│ ├── 函数对象Demo.cpp
│ ├── 函数对象Demo.vcxproj
│ └── 函数对象Demo.vcxproj.filters
├── 名字重整(NameMangling)
│ ├── Demangle.cpp
│ ├── Demangle.h
│ ├── c++_name_mangling.cpp
│ ├── 名字重整(NameMangling).vcxproj
│ └── 名字重整(NameMangling).vcxproj.filters
├── 指针常量和常量指针
│ ├── 指针常量和常量指针.cpp
│ ├── 指针常量和常量指针.vcxproj
│ └── 指针常量和常量指针.vcxproj.filters
├── 静态多态和动态多态
│ ├── static_dynamic_polymorphic.cpp
│ ├── 静态多态和动态多态.vcxproj
│ └── 静态多态和动态多态.vcxproj.filters
└── 静态绑定和动态绑定
│ ├── static_dynamic_binding.cpp
│ ├── 静态绑定和动态绑定.vcxproj
│ └── 静态绑定和动态绑定.vcxproj.filters
├── test_thread
├── Test_Atomic
│ ├── Test_Atomic.vcxproj
│ └── Test_Atomic.vcxproj.filters
├── Test_BlockingQueue
│ ├── Test_BlockingQueue.cpp
│ ├── Test_BlockingQueue.vcxproj
│ └── Test_BlockingQueue.vcxproj.filters
├── Test_CountDownLatch
│ ├── Test_CountDownLatch.cpp
│ ├── Test_CountDownLatch.vcxproj
│ └── Test_CountDownLatch.vcxproj.filters
└── Test_Thread
│ ├── Test_Thread.cpp
│ ├── Test_Thread.vcxproj
│ ├── Test_Thread.vcxproj.filters
│ └── TinyThread++-1.1-src.zip
├── test_tmp-meta
└── test_tmp_meta
│ ├── test_tmp_meta.cpp
│ ├── test_tmp_meta.vcxproj
│ └── test_tmp_meta.vcxproj.filters
├── tools
├── Base64Encode
│ ├── Base64Encode.vcxproj
│ ├── Base64Encode.vcxproj.filters
│ └── Test_Base64Encode.cpp
├── BitTwiddlingHacks
│ ├── BitTwiddlingHacks.cpp
│ ├── BitTwiddlingHacks.vcxproj
│ └── BitTwiddlingHacks.vcxproj.filters
├── Bitset
│ ├── Bitset.vcxproj
│ ├── Bitset.vcxproj.filters
│ └── Bitset_test.cpp
├── ByteArrayTest
│ ├── ByteArrayTest.cpp
│ ├── ByteArrayTest.vcxproj
│ └── ByteArrayTest.vcxproj.filters
├── ByteBufferTest
│ ├── ByteBufferTest.cpp
│ ├── ByteBufferTest.vcxproj
│ └── ByteBufferTest.vcxproj.filters
├── CStopWatch
│ ├── CStopWatch.vcxproj
│ ├── CStopWatch.vcxproj.filters
│ └── test_stopwatch.cpp
├── DateTimeTest
│ ├── DateTimeTest.vcxproj
│ ├── DateTimeTest.vcxproj.filters
│ └── DateTimeUtilTest.cpp
├── GBKtoUTF8
│ ├── GBKtoUTF8.inl
│ ├── GBKtoUTF8.vcxproj
│ ├── GBKtoUTF8.vcxproj.filters
│ ├── gbk.txt
│ ├── main.cpp
│ └── utf8.txt
├── Histogram_test
│ ├── Histogram_test.cpp
│ ├── Histogram_test.vcxproj
│ └── Histogram_test.vcxproj.filters
├── HttpRestClient_Test
│ ├── HttpRestClient.cpp
│ ├── HttpRestClient.h
│ ├── HttpRestClient_Test.cpp
│ ├── HttpRestClient_Test.vcxproj
│ ├── HttpRestClient_Test.vcxproj.filters
│ └── curl_win32
│ │ ├── curl
│ │ ├── curl.h
│ │ ├── curlbuild.h
│ │ ├── curlrules.h
│ │ ├── curlver.h
│ │ ├── easy.h
│ │ ├── mprintf.h
│ │ ├── multi.h
│ │ ├── stdcheaders.h
│ │ └── typecheck-gcc.h
│ │ └── lib
│ │ ├── libcurl.dll
│ │ ├── libcurl.lib
│ │ ├── libcurld.dll
│ │ └── libcurld_imp.lib
├── LruCacheTest
│ ├── LruCache.h
│ ├── LruCache.vcxproj
│ ├── LruCache.vcxproj.filters
│ └── LruCacheTest.cpp
├── ObjectPool
│ ├── ObjectPool.vcxproj
│ └── ObjectPool.vcxproj.filters
├── Profiling
│ ├── Profiler.cpp
│ ├── Profiler.h
│ ├── ProfilerTest.cpp
│ ├── Profiling.vcxproj
│ └── Profiling.vcxproj.filters
├── SHA1_Test
│ ├── SHA1_Test.vcxproj
│ ├── SHA1_Test.vcxproj.filters
│ └── SHA1_test.cpp
├── ScopeExitGuard
│ ├── ScopeExitGuard.vcxproj
│ ├── ScopeExitGuard.vcxproj.filters
│ └── test_ScopeExitGuard.cpp
├── SkipList_test
│ ├── SkipList_test.cpp
│ ├── SkipList_test.vcxproj
│ └── SkipList_test.vcxproj.filters
├── SmartAssertTest
│ ├── SmartAssertTest.cpp
│ ├── SmartAssertTest.vcxproj
│ └── SmartAssertTest.vcxproj.filters
├── StringPiece_test
│ ├── StringPiece_test.cpp
│ ├── StringPiece_test.vcxproj
│ └── StringPiece_test.vcxproj.filters
├── TimeStampTest
│ ├── TimeStampTest.cpp
│ ├── TimeStampTest.vcxproj
│ └── TimeStampTest.vcxproj.filters
├── ZLog_Test
│ ├── ZLog_Test.cpp
│ ├── ZLog_Test.vcxproj
│ └── ZLog_Test.vcxproj.filters
├── mystl
│ ├── any_test
│ │ ├── any_test.vcxproj
│ │ └── any_test.vcxproj.filters
│ └── array_test
│ │ ├── array_test.vcxproj
│ │ └── array_test.vcxproj.filters
├── performance_counter
│ ├── performance_counter.vcxproj
│ ├── performance_counter.vcxproj.filters
│ └── performance_counter_test.cpp
├── pugixml_test
│ ├── 1.xml
│ ├── 2.xml
│ ├── grammar.xml
│ ├── pugixml_test.cpp
│ ├── pugixml_test.vcxproj
│ ├── pugixml_test.vcxproj.filters
│ └── server.xml
├── str_func
│ ├── str_func.cpp
│ ├── str_func.vcxproj
│ └── str_func.vcxproj.filters
├── str_hash
│ ├── str_hash.vcxproj
│ ├── str_hash.vcxproj.filters
│ └── str_hash_test.cpp
├── test_UInt128
│ ├── int128.cpp
│ ├── int128.h
│ ├── test_UInt128.cpp
│ ├── test_UInt128.vcxproj
│ └── test_UInt128.vcxproj.filters
├── test_intrusive_list
│ ├── test_intrusive_list.cpp
│ ├── test_intrusive_list.vcxproj
│ └── test_intrusive_list.vcxproj.filters
├── test_smart_pointers
│ ├── test_smart_pointers.cpp
│ ├── test_smart_pointers.vcxproj
│ └── test_smart_pointers.vcxproj.filters
├── 字符串模糊匹配(fnmatch)
│ ├── 字符串模糊匹配(fnmatch).cpp
│ ├── 字符串模糊匹配(fnmatch).vcxproj
│ └── 字符串模糊匹配(fnmatch).vcxproj.filters
└── 求两个文件的差异
│ ├── A_B_main.cpp
│ ├── less.txt
│ ├── more.txt
│ ├── 求两个文件的差异.vcxproj
│ └── 求两个文件的差异.vcxproj.filters
└── utility
└── ipc
├── Semphore
├── Semaphore.cpp
├── Semaphore.h
├── Semaphore_test.cpp
└── makefile
├── ShareMemory
├── ShareMemory.cpp
├── ShareMemory.h
├── ShareMemory_Test.cpp
└── makefile
├── msgqueue_recv.cpp
├── msgqueue_send.cpp
├── namedpipe_read_test.cpp
├── namedpipe_write_test.cpp
├── pipe_test.cpp
└── sem_test.cpp
/.gitignore:
--------------------------------------------------------------------------------
1 | #ignore specificity dirs
2 | Debug
3 | bin
4 | log
5 | Release
6 |
7 | # Compiled Object files
8 | *.slo
9 | *.lo
10 | *.o
11 |
12 | # VisualStudio temp files
13 | *.obj
14 | *.user
15 | *.sdf
16 | *.suo
17 | *.ipch
18 | *.tlog
19 | *.pdb
20 | *.error
21 | *.ilk
22 | *.res
23 | *cache
24 | *.manifest
25 | *.log
26 | *.lastbuildstate
27 | *.idb
28 |
29 | # Compiled Dynamic libraries
30 | *.so
31 | *.dylib
32 |
33 |
34 | # Compiled Static libraries
35 | *.lai
36 | *.la
37 | *.a
38 |
39 |
40 | # Executables
41 | *.out
42 | *.app
43 |
--------------------------------------------------------------------------------
/3rdparty/gtest-1.7.0/m4/ltversion.m4:
--------------------------------------------------------------------------------
1 | # ltversion.m4 -- version numbers -*- Autoconf -*-
2 | #
3 | # Copyright (C) 2004 Free Software Foundation, Inc.
4 | # Written by Scott James Remnant, 2004
5 | #
6 | # This file is free software; the Free Software Foundation gives
7 | # unlimited permission to copy and/or distribute it, with or without
8 | # modifications, as long as this notice is preserved.
9 |
10 | # @configure_input@
11 |
12 | # serial 3337 ltversion.m4
13 | # This file is part of GNU Libtool
14 |
15 | m4_define([LT_PACKAGE_VERSION], [2.4.2])
16 | m4_define([LT_PACKAGE_REVISION], [1.3337])
17 |
18 | AC_DEFUN([LTVERSION_VERSION],
19 | [macro_version='2.4.2'
20 | macro_revision='1.3337'
21 | _LT_DECL(, macro_version, 0, [Which release of libtool.m4 was used?])
22 | _LT_DECL(, macro_revision, 0)
23 | ])
24 |
--------------------------------------------------------------------------------
/3rdparty/gtest-1.7.0/xcode/Config/DebugProject.xcconfig:
--------------------------------------------------------------------------------
1 | //
2 | // DebugProject.xcconfig
3 | //
4 | // These are Debug Configuration project settings for the gtest framework and
5 | // examples. It is set in the "Based On:" dropdown in the "Project" info
6 | // dialog.
7 | // This file is based on the Xcode Configuration files in:
8 | // http://code.google.com/p/google-toolbox-for-mac/
9 | //
10 |
11 | #include "General.xcconfig"
12 |
13 | // No optimization
14 | GCC_OPTIMIZATION_LEVEL = 0
15 |
16 | // Deployment postprocessing is what triggers Xcode to strip, turn it off
17 | DEPLOYMENT_POSTPROCESSING = NO
18 |
19 | // Dead code stripping off
20 | DEAD_CODE_STRIPPING = NO
21 |
22 | // Debug symbols should be on obviously
23 | GCC_GENERATE_DEBUGGING_SYMBOLS = YES
24 |
25 | // Define the DEBUG macro in all debug builds
26 | OTHER_CFLAGS = $(OTHER_CFLAGS) -DDEBUG=1
27 |
28 | // These are turned off to avoid STL incompatibilities with client code
29 | // // Turns on special C++ STL checks to "encourage" good STL use
30 | // GCC_PREPROCESSOR_DEFINITIONS = $(GCC_PREPROCESSOR_DEFINITIONS) _GLIBCXX_DEBUG_PEDANTIC _GLIBCXX_DEBUG _GLIBCPP_CONCEPT_CHECKS
31 |
--------------------------------------------------------------------------------
/3rdparty/gtest-1.7.0/xcode/Config/FrameworkTarget.xcconfig:
--------------------------------------------------------------------------------
1 | //
2 | // FrameworkTarget.xcconfig
3 | //
4 | // These are Framework target settings for the gtest framework and examples. It
5 | // is set in the "Based On:" dropdown in the "Target" info dialog.
6 | // This file is based on the Xcode Configuration files in:
7 | // http://code.google.com/p/google-toolbox-for-mac/
8 | //
9 |
10 | // Dynamic libs need to be position independent
11 | GCC_DYNAMIC_NO_PIC = NO
12 |
13 | // Dynamic libs should not have their external symbols stripped.
14 | STRIP_STYLE = non-global
15 |
16 | // Let the user install by specifying the $DSTROOT with xcodebuild
17 | SKIP_INSTALL = NO
18 |
--------------------------------------------------------------------------------
/3rdparty/gtest-1.7.0/xcode/Config/General.xcconfig:
--------------------------------------------------------------------------------
1 | //
2 | // General.xcconfig
3 | //
4 | // These are General configuration settings for the gtest framework and
5 | // examples.
6 | // This file is based on the Xcode Configuration files in:
7 | // http://code.google.com/p/google-toolbox-for-mac/
8 | //
9 |
10 | // Build for PPC and Intel, 32- and 64-bit
11 | ARCHS = i386 x86_64 ppc ppc64
12 |
13 | // Zerolink prevents link warnings so turn it off
14 | ZERO_LINK = NO
15 |
16 | // Prebinding considered unhelpful in 10.3 and later
17 | PREBINDING = NO
18 |
19 | // Strictest warning policy
20 | WARNING_CFLAGS = -Wall -Werror -Wendif-labels -Wnewline-eof -Wno-sign-compare -Wshadow
21 |
22 | // Work around Xcode bugs by using external strip. See:
23 | // http://lists.apple.com/archives/Xcode-users/2006/Feb/msg00050.html
24 | SEPARATE_STRIP = YES
25 |
26 | // Force C99 dialect
27 | GCC_C_LANGUAGE_STANDARD = c99
28 |
29 | // not sure why apple defaults this on, but it's pretty risky
30 | ALWAYS_SEARCH_USER_PATHS = NO
31 |
32 | // Turn on position dependent code for most cases (overridden where appropriate)
33 | GCC_DYNAMIC_NO_PIC = YES
34 |
35 | // Default SDK and minimum OS version is 10.4
36 | SDKROOT = $(DEVELOPER_SDK_DIR)/MacOSX10.4u.sdk
37 | MACOSX_DEPLOYMENT_TARGET = 10.4
38 | GCC_VERSION = 4.0
39 |
40 | // VERSIONING BUILD SETTINGS (used in Info.plist)
41 | GTEST_VERSIONINFO_ABOUT = © 2008 Google Inc.
42 |
--------------------------------------------------------------------------------
/3rdparty/gtest-1.7.0/xcode/Config/ReleaseProject.xcconfig:
--------------------------------------------------------------------------------
1 | //
2 | // ReleaseProject.xcconfig
3 | //
4 | // These are Release Configuration project settings for the gtest framework
5 | // and examples. It is set in the "Based On:" dropdown in the "Project" info
6 | // dialog.
7 | // This file is based on the Xcode Configuration files in:
8 | // http://code.google.com/p/google-toolbox-for-mac/
9 | //
10 |
11 | #include "General.xcconfig"
12 |
13 | // subconfig/Release.xcconfig
14 |
15 | // Optimize for space and size (Apple recommendation)
16 | GCC_OPTIMIZATION_LEVEL = s
17 |
18 | // Deploment postprocessing is what triggers Xcode to strip
19 | DEPLOYMENT_POSTPROCESSING = YES
20 |
21 | // No symbols
22 | GCC_GENERATE_DEBUGGING_SYMBOLS = NO
23 |
24 | // Dead code strip does not affect ObjC code but can help for C
25 | DEAD_CODE_STRIPPING = YES
26 |
27 | // NDEBUG is used by things like assert.h, so define it for general compat.
28 | // ASSERT going away in release tends to create unused vars.
29 | OTHER_CFLAGS = $(OTHER_CFLAGS) -DNDEBUG=1 -Wno-unused-variable
30 |
31 | // When we strip we want to strip all symbols in release, but save externals.
32 | STRIP_STYLE = all
33 |
--------------------------------------------------------------------------------
/3rdparty/gtest-1.7.0/xcode/Config/StaticLibraryTarget.xcconfig:
--------------------------------------------------------------------------------
1 | //
2 | // StaticLibraryTarget.xcconfig
3 | //
4 | // These are static library target settings for libgtest.a. It
5 | // is set in the "Based On:" dropdown in the "Target" info dialog.
6 | // This file is based on the Xcode Configuration files in:
7 | // http://code.google.com/p/google-toolbox-for-mac/
8 | //
9 |
10 | // Static libs can be included in bundles so make them position independent
11 | GCC_DYNAMIC_NO_PIC = NO
12 |
13 | // Static libs should not have their internal globals or external symbols
14 | // stripped.
15 | STRIP_STYLE = debugging
16 |
17 | // Let the user install by specifying the $DSTROOT with xcodebuild
18 | SKIP_INSTALL = NO
19 |
--------------------------------------------------------------------------------
/3rdparty/gtest-1.7.0/xcode/Config/TestTarget.xcconfig:
--------------------------------------------------------------------------------
1 | //
2 | // TestTarget.xcconfig
3 | //
4 | // These are Test target settings for the gtest framework and examples. It
5 | // is set in the "Based On:" dropdown in the "Target" info dialog.
6 |
7 | PRODUCT_NAME = $(TARGET_NAME)
8 | HEADER_SEARCH_PATHS = ../include
9 |
--------------------------------------------------------------------------------
/3rdparty/gtest-1.7.0/xcode/Resources/Info.plist:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 | CFBundleDevelopmentRegion
6 | English
7 | CFBundleExecutable
8 | ${EXECUTABLE_NAME}
9 | CFBundleIconFile
10 |
11 | CFBundleIdentifier
12 | com.google.${PRODUCT_NAME}
13 | CFBundleInfoDictionaryVersion
14 | 6.0
15 | CFBundlePackageType
16 | FMWK
17 | CFBundleSignature
18 | ????
19 | CFBundleVersion
20 | GTEST_VERSIONINFO_LONG
21 | CFBundleShortVersionString
22 | GTEST_VERSIONINFO_SHORT
23 | CFBundleGetInfoString
24 | ${PRODUCT_NAME} GTEST_VERSIONINFO_LONG, ${GTEST_VERSIONINFO_ABOUT}
25 | NSHumanReadableCopyright
26 | ${GTEST_VERSIONINFO_ABOUT}
27 | CSResourcesFileMapped
28 |
29 |
30 |
31 |
--------------------------------------------------------------------------------
/3rdparty/gtest-1.7.0/xcode/Samples/FrameworkSample/Info.plist:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 | CFBundleDevelopmentRegion
6 | English
7 | CFBundleExecutable
8 | ${EXECUTABLE_NAME}
9 | CFBundleIconFile
10 |
11 | CFBundleIdentifier
12 | com.google.gtest.${PRODUCT_NAME:identifier}
13 | CFBundleInfoDictionaryVersion
14 | 6.0
15 | CFBundleName
16 | ${PRODUCT_NAME}
17 | CFBundlePackageType
18 | FMWK
19 | CFBundleShortVersionString
20 | 1.0
21 | CFBundleSignature
22 | ????
23 | CFBundleVersion
24 | 1.0
25 | CSResourcesFileMapped
26 |
27 |
28 |
29 |
--------------------------------------------------------------------------------
/3rdparty/lib/gtest.lib:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/lizhenghn123/CppLanguagePrograms/add5848861197a53feabba480e43fd8bb8f074fb/3rdparty/lib/gtest.lib
--------------------------------------------------------------------------------
/3rdparty/lib/gtestd.lib:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/lizhenghn123/CppLanguagePrograms/add5848861197a53feabba480e43fd8bb8f074fb/3rdparty/lib/gtestd.lib
--------------------------------------------------------------------------------
/DesignPatternOf23Kinds/AbstractFactory/AbstractFactory.cpp:
--------------------------------------------------------------------------------
1 | //AbstractFactory.cpp
2 | #include "AbstractFactory.h"
3 | #include "Product.h"
4 | #include
5 | using namespace std;
6 | AbstractFactory::AbstractFactory()
7 | {
8 | }
9 | AbstractFactory::~AbstractFactory()
10 | {
11 | }
12 | ConcreteFactory1::ConcreteFactory1()
13 | {
14 | }
15 | ConcreteFactory1::~ConcreteFactory1()
16 | {
17 | }
18 | AbstractProductA *ConcreteFactory1::CreateProductA()
19 | {
20 | return new ProductA1();
21 | }
22 | AbstractProductB *ConcreteFactory1::CreateProductB()
23 | {
24 | return new ProductB1();
25 | }
26 | ConcreteFactory2::ConcreteFactory2()
27 | {
28 | }
29 | ConcreteFactory2::~ConcreteFactory2()
30 | {
31 | }
32 | AbstractProductA *ConcreteFactory2::CreateProductA()
33 | {
34 | return new ProductA2();
35 | }
36 | AbstractProductB *ConcreteFactory2::CreateProductB()
37 | {
38 | return new ProductB2();
39 | }
--------------------------------------------------------------------------------
/DesignPatternOf23Kinds/AbstractFactory/AbstractFactory.h:
--------------------------------------------------------------------------------
1 | //AbstractFactory.h
2 | #ifndef _ABSTRACTFACTORY_H_
3 | #define _ABSTRACTFACTORY_H_
4 | class AbstractProductA;
5 | class AbstractProductB;
6 | class AbstractFactory
7 | {
8 | public:
9 | virtual ~AbstractFactory();
10 | virtual AbstractProductA *CreateProductA() = 0;
11 | virtual AbstractProductB *CreateProductB() = 0;
12 | protected:
13 | AbstractFactory();
14 | private:
15 | };
16 |
17 | class ConcreteFactory1: public AbstractFactory
18 | {
19 | public:
20 | ConcreteFactory1();
21 | ~ConcreteFactory1();
22 | AbstractProductA *CreateProductA();
23 | AbstractProductB *CreateProductB();
24 | protected:
25 | private:
26 | };
27 | class ConcreteFactory2: public AbstractFactory
28 | {
29 | public:
30 | ConcreteFactory2();
31 | ~ConcreteFactory2();
32 | AbstractProductA *CreateProductA();
33 | AbstractProductB *CreateProductB();
34 | protected:
35 | private:
36 | };
37 | #endif //~_ABSTRACTFACTORY_H_
38 |
--------------------------------------------------------------------------------
/DesignPatternOf23Kinds/AbstractFactory/Product.cpp:
--------------------------------------------------------------------------------
1 | //Product.cpp
2 | #include "Product.h"
3 | #include
4 | using namespace std;
5 | AbstractProductA::AbstractProductA()
6 | {
7 | }
8 | AbstractProductA::~AbstractProductA()
9 | {
10 | }
11 | AbstractProductB::AbstractProductB()
12 | {
13 | }
14 | AbstractProductB::~AbstractProductB()
15 | {
16 | }
17 | ProductA1::ProductA1()
18 | {
19 | cout << "ProductA1..." << endl;
20 | }
21 | ProductA1::~ProductA1()
22 | {
23 | }
24 | ProductA2::ProductA2()
25 | {
26 | cout << "ProductA2..." << endl;
27 | }
28 | ProductA2::~ProductA2()
29 | {
30 | }
31 | ProductB1::ProductB1()
32 | {
33 | cout << "ProductB1..." << endl;
34 | }
35 | ProductB1::~ProductB1()
36 | {
37 | }
38 | ProductB2::ProductB2()
39 | {
40 | cout << "ProductB2..." << endl;
41 | }
42 | ProductB2::~ProductB2()
43 | {
44 | }
--------------------------------------------------------------------------------
/DesignPatternOf23Kinds/AbstractFactory/Product.h:
--------------------------------------------------------------------------------
1 | //Product.h
2 | #ifndef _PRODUCT_H_
3 | #define _PRODUCT_H_
4 | class AbstractProductA
5 | {
6 | public:
7 | virtual ~AbstractProductA();
8 | protected:
9 | AbstractProductA();
10 | private:
11 | };
12 |
13 | class AbstractProductB
14 | {
15 | public:
16 | virtual ~AbstractProductB();
17 | protected:
18 | AbstractProductB();
19 | private:
20 | };
21 |
22 | class ProductA1: public AbstractProductA
23 | {
24 | public:
25 | ProductA1();
26 | ~ProductA1();
27 | protected:
28 | private:
29 | };
30 | class ProductA2: public AbstractProductA
31 | {
32 | public:
33 | ProductA2();
34 | ~ProductA2();
35 | protected:
36 | private:
37 | };
38 |
39 |
40 | class ProductB1: public AbstractProductB
41 | {
42 | public:
43 | ProductB1();
44 | ~ProductB1();
45 | protected:
46 | private:
47 | };
48 | class ProductB2: public AbstractProductB
49 | {
50 | public:
51 | ProductB2();
52 | ~ProductB2();
53 | protected:
54 | private:
55 | };
56 | #endif //~_PRODUCT_H_
--------------------------------------------------------------------------------
/DesignPatternOf23Kinds/AbstractFactory/testAbstractFactory.cpp:
--------------------------------------------------------------------------------
1 | #include "AbstractFactory.h"
2 | #include
3 | using namespace std;
4 |
5 |
6 | int main(int argc, char *argv[])
7 | {
8 | AbstractFactory *cf1 = new ConcreteFactory1();
9 | cf1->CreateProductA();
10 | cf1->CreateProductB();
11 | AbstractFactory *cf2 = new ConcreteFactory2();
12 | cf2->CreateProductA();
13 | cf2->CreateProductB();
14 |
15 | system("pause");
16 | return 0;
17 | }
--------------------------------------------------------------------------------
/DesignPatternOf23Kinds/Adapter/AdapterOfClass.h:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/lizhenghn123/CppLanguagePrograms/add5848861197a53feabba480e43fd8bb8f074fb/DesignPatternOf23Kinds/Adapter/AdapterOfClass.h
--------------------------------------------------------------------------------
/DesignPatternOf23Kinds/Adapter/AdapterOfObject.h:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/lizhenghn123/CppLanguagePrograms/add5848861197a53feabba480e43fd8bb8f074fb/DesignPatternOf23Kinds/Adapter/AdapterOfObject.h
--------------------------------------------------------------------------------
/DesignPatternOf23Kinds/Adapter/testAdapter.cpp:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/lizhenghn123/CppLanguagePrograms/add5848861197a53feabba480e43fd8bb8f074fb/DesignPatternOf23Kinds/Adapter/testAdapter.cpp
--------------------------------------------------------------------------------
/DesignPatternOf23Kinds/Bridge/Abstraction.h:
--------------------------------------------------------------------------------
1 | //Abstraction.h
2 | #ifndef _ABSTRACTION_H_
3 | #define _ABSTRACTION_H_
4 |
5 | #include "AbstractionImp.h"
6 | #include
7 | using namespace std;
8 |
9 | class AbstractionImp;
10 |
11 | class Abstraction
12 | {
13 | public:
14 | virtual ~Abstraction() {}
15 | virtual void Operation() = 0;
16 | protected:
17 | Abstraction() {}
18 | private:
19 | };
20 |
21 | class RefinedAbstraction: public Abstraction
22 | {
23 | public:
24 | RefinedAbstraction(AbstractionImp *imp)
25 | {
26 | _imp = imp;
27 | }
28 | ~RefinedAbstraction() {}
29 | void Operation()
30 | {
31 | _imp->Operation();
32 | }
33 | protected:
34 | private:
35 | AbstractionImp *_imp;
36 | };
37 | #endif //~_ABSTRACTION_H_
--------------------------------------------------------------------------------
/DesignPatternOf23Kinds/Bridge/AbstractionImp.h:
--------------------------------------------------------------------------------
1 | //AbstractionImp.h
2 | #ifndef _ABSTRACTIONIMP_H_
3 | #define _ABSTRACTIONIMP_H_
4 |
5 | #include
6 | using namespace std;
7 |
8 |
9 | class AbstractionImp
10 | {
11 | public:
12 | virtual ~AbstractionImp() {}
13 | virtual void Operation() = 0
14 | {
15 | cout << "AbstractionImp....imp..." << endl;
16 | }
17 | protected:
18 | AbstractionImp() {}
19 | private:
20 | };
21 |
22 | class ConcreteAbstractionImpA: public AbstractionImp
23 | {
24 | public:
25 | ConcreteAbstractionImpA() {}
26 | ~ConcreteAbstractionImpA() {}
27 | virtual void Operation()
28 | {
29 | cout << "ConcreteAbstractionImpA...." << endl;
30 | }
31 | protected:
32 |
33 | private:
34 | };
35 |
36 | class ConcreteAbstractionImpB: public AbstractionImp
37 | {
38 | public:
39 | ConcreteAbstractionImpB() {}
40 | ~ConcreteAbstractionImpB() {}
41 | virtual void Operation()
42 | {
43 | cout << "ConcreteAbstractionImpB...." << endl;
44 | }
45 | protected:
46 |
47 | private:
48 | };
49 |
50 |
51 | #endif //~_ABSTRACTIONIMP_H_
52 |
--------------------------------------------------------------------------------
/DesignPatternOf23Kinds/Bridge/Bridge.vcxproj.filters:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
--------------------------------------------------------------------------------
/DesignPatternOf23Kinds/Bridge/testBridge.cpp:
--------------------------------------------------------------------------------
1 | #include "Abstraction.h"
2 | #include "AbstractionImp.h"
3 | #include
4 | using namespace std;
5 | int main(int argc, char *argv[])
6 | {
7 | AbstractionImp *impA = new ConcreteAbstractionImpA();
8 | Abstraction *absa = new RefinedAbstraction(impA);
9 | absa->Operation();
10 |
11 | AbstractionImp *impB = new ConcreteAbstractionImpB();
12 | Abstraction *absb = new RefinedAbstraction(impB);
13 | absb->Operation();
14 |
15 | system("pause");
16 | return 0;
17 | }
--------------------------------------------------------------------------------
/DesignPatternOf23Kinds/Builder/Builder.h:
--------------------------------------------------------------------------------
1 | //Builder.h
2 | #ifndef _BUILDER_H_
3 | #define _BUILDER_H_
4 |
5 | #include "Product.h"
6 | #include
7 | #include
8 | using namespace std;
9 |
10 | class Product;
11 |
12 |
13 | class Builder
14 | {
15 | public:
16 | virtual ~Builder() {}
17 | virtual void BuildPartA(const string &buildPara) = 0;
18 | virtual void BuildPartB(const string &buildPara) = 0;
19 | virtual void BuildPartC(const string &buildPara) = 0;
20 | virtual Product *GetProduct() = 0;
21 | protected:
22 | Builder() {}
23 | private:
24 | };
25 |
26 |
27 | class ConcreteBuilder: public Builder
28 | {
29 | public:
30 | ConcreteBuilder() {}
31 | ~ConcreteBuilder() {}
32 | void BuildPartA(const string &buildPara)
33 | {
34 | cout << "Step1:Build PartA..." << buildPara << endl;
35 | }
36 | void BuildPartB(const string &buildPara)
37 | {
38 | cout << "Step1:Build PartB..." << buildPara << endl;
39 | }
40 | void BuildPartC(const string &buildPara)
41 | {
42 | cout << "Step1:Build PartC..." << buildPara << endl;
43 | }
44 | Product *GetProduct()
45 | {
46 | BuildPartA("pre-defined");
47 | BuildPartB("pre-defined");
48 | BuildPartC("pre-defined");
49 | return new Product();
50 | }
51 |
52 | };
53 | #endif //~_BUILDER_H_
--------------------------------------------------------------------------------
/DesignPatternOf23Kinds/Builder/Builder.vcxproj.filters:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
--------------------------------------------------------------------------------
/DesignPatternOf23Kinds/Builder/Director.h:
--------------------------------------------------------------------------------
1 | //Director.h
2 | #ifndef _DIRECTOR_H_
3 | #define _DIRECTOR_H_
4 |
5 | #include "Builder.h"
6 | class Builder;
7 |
8 |
9 | class Director
10 | {
11 | public:
12 | Director(Builder *bld)
13 | {
14 | _bld = bld ;
15 | }
16 | ~Director() {}
17 | void Construct()
18 | {
19 | _bld->BuildPartA("user-defined");
20 | _bld->BuildPartB("user-defined");
21 | _bld->BuildPartC("user-defined");
22 | }
23 | protected:
24 | private:
25 | Builder *_bld;
26 | };
27 |
28 |
29 | #endif //~_DIRECTOR_H_
30 |
31 |
--------------------------------------------------------------------------------
/DesignPatternOf23Kinds/Builder/Product.h:
--------------------------------------------------------------------------------
1 | #ifndef _PRODUCT_H_
2 | #define _PRODUCT_H_
3 |
4 | #include
5 | using namespace std;
6 |
7 | class Product
8 | {
9 | public:
10 | Product()
11 | {
12 | ProducePart();
13 | cout << "return a product" << endl;
14 | }
15 | ~Product() {}
16 | void ProducePart()
17 | {
18 | cout << "build part of product.." << endl;
19 | }
20 |
21 | };
22 |
23 |
24 | class ProductPart
25 | {
26 | public:
27 | ProductPart() {}
28 | ~ProductPart() {}
29 | ProductPart *BuildPart()
30 | {
31 | return new ProductPart;
32 | }
33 | };
34 |
35 |
36 | #endif //~_PRODUCT_H_
--------------------------------------------------------------------------------
/DesignPatternOf23Kinds/Builder/testBuilder.cpp:
--------------------------------------------------------------------------------
1 | #include "Builder.h"
2 | #include "Product.h"
3 | #include "Director.h"
4 | #include
5 | using namespace std;
6 |
7 |
8 | int main(int argc, char *argv[])
9 | {
10 | Director *d = new Director(new ConcreteBuilder());
11 | d->Construct();
12 |
13 | /*ConcreteBuilder p ;
14 | p.GetProduct();*/
15 |
16 | system("pause");
17 | return 0;
18 | }
--------------------------------------------------------------------------------
/DesignPatternOf23Kinds/ChainOfResponsibility/ChainOfResponsibility.vcxproj.filters:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
--------------------------------------------------------------------------------
/DesignPatternOf23Kinds/ChainOfResponsibility/Handle.h:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/lizhenghn123/CppLanguagePrograms/add5848861197a53feabba480e43fd8bb8f074fb/DesignPatternOf23Kinds/ChainOfResponsibility/Handle.h
--------------------------------------------------------------------------------
/DesignPatternOf23Kinds/ChainOfResponsibility/testChainOfResponsibility.cpp:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/lizhenghn123/CppLanguagePrograms/add5848861197a53feabba480e43fd8bb8f074fb/DesignPatternOf23Kinds/ChainOfResponsibility/testChainOfResponsibility.cpp
--------------------------------------------------------------------------------
/DesignPatternOf23Kinds/Command/Command.h:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/lizhenghn123/CppLanguagePrograms/add5848861197a53feabba480e43fd8bb8f074fb/DesignPatternOf23Kinds/Command/Command.h
--------------------------------------------------------------------------------
/DesignPatternOf23Kinds/Command/Command.vcxproj.filters:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
--------------------------------------------------------------------------------
/DesignPatternOf23Kinds/Command/Invoker.h:
--------------------------------------------------------------------------------
1 | //Invoker.h
2 | #ifndef _INVOKER_H_
3 | #define _INVOKER_H_
4 | #include "Invoker.h"
5 | #include "Command.h"
6 | #include
7 |
8 | class Command;
9 |
10 |
11 | class Invoker
12 | {
13 | public:
14 | Invoker(Command *cmd)
15 | {
16 | this->_cmd = cmd;
17 | }
18 | ~Invoker()
19 | {
20 | delete _cmd;
21 | }
22 | void Invoke()
23 | {
24 | _cmd->Execute();
25 | }
26 | protected:
27 | private:
28 | Command *_cmd;
29 | };
30 | #endif //~_INVOKER_H_
31 |
--------------------------------------------------------------------------------
/DesignPatternOf23Kinds/Command/Reciever.h:
--------------------------------------------------------------------------------
1 | //Reciever.h
2 | #ifndef _RECIEVER_H_
3 | #define _RECIEVER_H_
4 | #include
5 |
6 | class RecieverA
7 | {
8 | public:
9 | RecieverA() { }
10 | ~RecieverA() { }
11 | void Action()
12 | {
13 | std::cout << "RecieverA action......." << std::endl;
14 | }
15 | protected:
16 | private:
17 | };
18 |
19 | class RecieverB
20 | {
21 | public:
22 | RecieverB() { }
23 | ~RecieverB() { }
24 | void Action()
25 | {
26 | std::cout << "RecieverB action......." << std::endl;
27 | }
28 | protected:
29 | private:
30 | };
31 |
32 |
33 | class SimpleReciever
34 | {
35 | public:
36 | SimpleReciever() { }
37 | ~SimpleReciever() { }
38 | void Action()
39 | {
40 | std::cout << "SimpleReciever action......." << std::endl;
41 | }
42 | protected:
43 | private:
44 | };
45 |
46 |
47 | #endif //~_RECIEVER_H_
--------------------------------------------------------------------------------
/DesignPatternOf23Kinds/Command/testCommand.cpp:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/lizhenghn123/CppLanguagePrograms/add5848861197a53feabba480e43fd8bb8f074fb/DesignPatternOf23Kinds/Command/testCommand.cpp
--------------------------------------------------------------------------------
/DesignPatternOf23Kinds/Composite/Component.h:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/lizhenghn123/CppLanguagePrograms/add5848861197a53feabba480e43fd8bb8f074fb/DesignPatternOf23Kinds/Composite/Component.h
--------------------------------------------------------------------------------
/DesignPatternOf23Kinds/Composite/Composite.h:
--------------------------------------------------------------------------------
1 | //Composite.h
2 | #ifndef _COMPOSITE_H_
3 | #define _COMPOSITE_H_
4 | #include "Component.h"
5 | #include
6 | using namespace std;
7 |
8 | class Composite: public Component
9 | {
10 | public:
11 | Composite() { }
12 | ~Composite() { }
13 | public:
14 | void Operation()
15 | {
16 | vector::iterator comIter = comVec.begin();
17 | for (; comIter != comVec.end(); comIter++)
18 | {
19 | (*comIter)->Operation();
20 | }
21 | }
22 | void Add(Component *com)
23 | {
24 | comVec.push_back(com);
25 | }
26 | void Remove(Component *com)
27 | {
28 | //comVec.erase(&com);
29 | for (vector::iterator p = comVec.begin(); p != comVec.end(); p++)
30 | {
31 | if(*p == com)
32 | comVec.erase(p);
33 | }
34 | }
35 | Component *GetChild(int index)
36 | {
37 | return comVec[index];
38 | }
39 | protected:
40 | private:
41 | vector comVec;
42 | };
43 | #endif //~_COMPOSITE_H_
44 |
--------------------------------------------------------------------------------
/DesignPatternOf23Kinds/Composite/Composite.vcxproj.filters:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
--------------------------------------------------------------------------------
/DesignPatternOf23Kinds/Composite/Leaf.h:
--------------------------------------------------------------------------------
1 | //Leaf.h
2 | #ifndef _LEAF_H_
3 | #define _LEAF_H_
4 | #include "Component.h"
5 | #include
6 | using namespace std;
7 |
8 |
9 | class Leaf: public Component
10 | {
11 | public:
12 | Leaf() { }
13 | ~Leaf() { }
14 | void Operation()
15 | {
16 | cout << "Leaf operation....." << endl;
17 | }
18 | };
19 | #endif //~_LEAF_H_
--------------------------------------------------------------------------------
/DesignPatternOf23Kinds/Composite/testComposite.cpp:
--------------------------------------------------------------------------------
1 | #include "Component.h"
2 | #include "Composite.h"
3 | #include "Leaf.h"
4 | #include
5 | using namespace std;
6 |
7 |
8 | int main(int argc, char *argv[])
9 | {
10 | Leaf *l = new Leaf();
11 | l->Operation();
12 | Composite *com = new Composite();
13 | com->Add(l);
14 | com->Operation();
15 | Component *ll = com->GetChild(0);
16 | ll->Operation();
17 |
18 | system("pause");
19 | return 0;
20 | }
21 |
--------------------------------------------------------------------------------
/DesignPatternOf23Kinds/Decorator/Decorator.h:
--------------------------------------------------------------------------------
1 | #ifndef _DECORATOR_H_
2 | #define _DECORATOR_H_
3 | #include
4 |
5 |
6 | class Component
7 | {
8 | public:
9 | virtual ~Component() { }
10 | virtual void Operation() { }
11 | protected:
12 | Component() { }
13 | private:
14 | };
15 |
16 | class ConcreteComponent: public Component
17 | {
18 | public:
19 | ConcreteComponent() { }
20 | ~ConcreteComponent() { }
21 | void Operation()
22 | {
23 | std::cout << "ConcreteComponent operation..." << std::endl;
24 | }
25 | };
26 | class Decorator: public Component
27 | {
28 | public:
29 | Decorator(Component *com)
30 | {
31 | this->_com = com;
32 | }
33 | virtual ~Decorator()
34 | {
35 | delete _com;
36 | }
37 | void Operation() { }
38 | protected:
39 | Component *_com;
40 | private:
41 | };
42 |
43 |
44 | class ConcreteDecorator: public Decorator
45 | {
46 | public:
47 | ConcreteDecorator(Component *com): Decorator(com)
48 | {
49 |
50 | }
51 | ~ConcreteDecorator() { }
52 | void Operation()
53 | {
54 | _com->Operation();
55 | this->AddedBehavior();
56 | }
57 | void AddedBehavior()
58 | {
59 | std::cout << "ConcreteDecorator::AddedBehacior...." << std::endl;
60 | }
61 |
62 | };
63 |
64 |
65 | #endif //~_DECORATOR_H_
66 |
67 |
--------------------------------------------------------------------------------
/DesignPatternOf23Kinds/Decorator/Decorator.vcxproj.filters:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
--------------------------------------------------------------------------------
/DesignPatternOf23Kinds/Decorator/testDecorator.cpp:
--------------------------------------------------------------------------------
1 | #include "Decorator.h"
2 | #include
3 | using namespace std;
4 |
5 |
6 | int main(int argc, char *argv[])
7 | {
8 | Component *com = new ConcreteComponent();
9 | Decorator *dec = new ConcreteDecorator(com);
10 | dec->Operation();
11 | delete dec;
12 |
13 | system("pause");
14 | return 0;
15 | }
--------------------------------------------------------------------------------
/DesignPatternOf23Kinds/DesignPatternOf23Kinds/DesignPatternOf23Kinds.vcxproj.filters:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 | {4FC737F1-C7A5-4376-A066-2A32D752A2FF}
6 | cpp;c;cc;cxx;def;odl;idl;hpj;bat;asm;asmx
7 |
8 |
9 | {93995380-89BD-4b04-88EB-625FBE52EBFB}
10 | h;hpp;hxx;hm;inl;inc;xsd
11 |
12 |
13 | {67DA6AB6-F800-4c08-8B7A-83BB121AAD01}
14 | rc;ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe;resx;tiff;tif;png;wav;mfcribbon-ms
15 |
16 |
17 |
18 |
19 | Source Files
20 |
21 |
22 |
--------------------------------------------------------------------------------
/DesignPatternOf23Kinds/DesignPatternOf23Kinds/main.cpp:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/lizhenghn123/CppLanguagePrograms/add5848861197a53feabba480e43fd8bb8f074fb/DesignPatternOf23Kinds/DesignPatternOf23Kinds/main.cpp
--------------------------------------------------------------------------------
/DesignPatternOf23Kinds/Facade/Facade.h:
--------------------------------------------------------------------------------
1 | /************************************************************************/
2 | /*Fa?ade 模式在高层提供了一个统一的接口,解耦了系统。设计模式中还有另一种模式
3 | Mediator 也和 Fa?ade 有类似的地方。但是 Mediator 主要目的是对象间的访问的解耦*/
4 | /************************************************************************/
5 | //Facade.h
6 | #ifndef _FACADE_H_
7 | #define _FACADE_H_
8 | #include
9 | using namespace std;
10 |
11 |
12 | class Subsystem1
13 | {
14 | public:
15 | Subsystem1() { }
16 | ~Subsystem1() { }
17 | void Operation()
18 | {
19 | cout << "Subsystem1 operation.." << endl;
20 | }
21 | };
22 |
23 | class Subsystem2
24 | {
25 | public:
26 | Subsystem2() { }
27 | ~Subsystem2() { }
28 | void Operation()
29 | {
30 | cout << "Subsystem2 operation.." << endl;
31 | }
32 | };
33 |
34 | class Facade
35 | {
36 | public:
37 | Facade()
38 | {
39 | this->_subs1 = new Subsystem1();
40 | this->_subs2 = new Subsystem2();
41 | }
42 | ~Facade()
43 | {
44 | delete _subs1;
45 | delete _subs2;
46 | }
47 | void OperationWrapper()
48 | {
49 | this->_subs1->Operation();
50 |
51 | this->_subs2->Operation();
52 | }
53 | private:
54 | Subsystem1 *_subs1;
55 | Subsystem2 *_subs2;
56 | };
57 |
58 | #endif //~_FACADE_H_
--------------------------------------------------------------------------------
/DesignPatternOf23Kinds/Facade/Facade.vcxproj.filters:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
--------------------------------------------------------------------------------
/DesignPatternOf23Kinds/Facade/testFacade.cpp:
--------------------------------------------------------------------------------
1 | #include "Facade.h"
2 |
3 | #include
4 | using namespace std;
5 |
6 | int main(int argc, char *argv[])
7 | {
8 | Facade *f = new Facade();
9 | f->OperationWrapper();
10 |
11 | system("pause");
12 | return 0;
13 | }
--------------------------------------------------------------------------------
/DesignPatternOf23Kinds/FactoryMethod/Factory.h:
--------------------------------------------------------------------------------
1 | //Factory.h
2 | #ifndef _FACTORY_H_
3 | #define _FACTORY_H_
4 |
5 | #include "Factory.h"
6 | #include "Product.h"
7 | #include
8 | using namespace std;
9 |
10 |
11 | class Product;
12 |
13 | class Factory
14 | {
15 | public:
16 | virtual ~Factory() = 0 { } ;
17 | virtual Product *CreateProduct() = 0;
18 | protected:
19 | Factory() { };
20 | };
21 |
22 |
23 | class ConcreteFactory: public Factory
24 | {
25 | public:
26 | ConcreteFactory()
27 | {
28 | cout << "ConcreteFactory....." << endl;
29 | }
30 | ~ConcreteFactory() { }
31 | Product *CreateProduct()
32 | {
33 | return new ConcreteProduct();
34 | }
35 | };
36 | #endif //_FACTORY_H_
37 |
38 |
39 |
--------------------------------------------------------------------------------
/DesignPatternOf23Kinds/FactoryMethod/FactoryMethod.vcxproj.filters:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
--------------------------------------------------------------------------------
/DesignPatternOf23Kinds/FactoryMethod/Product.h:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/lizhenghn123/CppLanguagePrograms/add5848861197a53feabba480e43fd8bb8f074fb/DesignPatternOf23Kinds/FactoryMethod/Product.h
--------------------------------------------------------------------------------
/DesignPatternOf23Kinds/FactoryMethod/testFactoryMethod.cpp:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/lizhenghn123/CppLanguagePrograms/add5848861197a53feabba480e43fd8bb8f074fb/DesignPatternOf23Kinds/FactoryMethod/testFactoryMethod.cpp
--------------------------------------------------------------------------------
/DesignPatternOf23Kinds/Flyweight/Flyweight.h:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/lizhenghn123/CppLanguagePrograms/add5848861197a53feabba480e43fd8bb8f074fb/DesignPatternOf23Kinds/Flyweight/Flyweight.h
--------------------------------------------------------------------------------
/DesignPatternOf23Kinds/Flyweight/Flyweight.vcxproj.filters:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
--------------------------------------------------------------------------------
/DesignPatternOf23Kinds/Flyweight/FlyweightFactory.h:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/lizhenghn123/CppLanguagePrograms/add5848861197a53feabba480e43fd8bb8f074fb/DesignPatternOf23Kinds/Flyweight/FlyweightFactory.h
--------------------------------------------------------------------------------
/DesignPatternOf23Kinds/Flyweight/testFlyweight.cpp:
--------------------------------------------------------------------------------
1 | #include "Flyweight.h"
2 | #include "FlyweightFactory.h"
3 | #include
4 | using namespace std;
5 |
6 | int main(int argc, char *argv[])
7 | {
8 | FlyweightFactory *fc = new FlyweightFactory();
9 | Flyweight *fw1 = fc->GetFlyweight("hello");
10 |
11 | Flyweight *fw2 = fc->GetFlyweight("world!");
12 | Flyweight *fw3 = fc->GetFlyweight("hello");
13 |
14 | fw1->Operation("1111");
15 | fw2->Operation("2222");
16 |
17 | system("pause");
18 | return 0;
19 | }
20 |
--------------------------------------------------------------------------------
/DesignPatternOf23Kinds/Interpreter/Context.h:
--------------------------------------------------------------------------------
1 | //Context.h
2 | #ifndef _CONTEXT_H_
3 | #define _CONTEXT_H_
4 |
5 |
6 | class Context
7 | {
8 | public:
9 | Context() { }
10 | ~Context() { }
11 |
12 | };
13 |
14 |
15 | #endif //~_CONTEXT_H_
16 |
--------------------------------------------------------------------------------
/DesignPatternOf23Kinds/Interpreter/Interpret.cpp:
--------------------------------------------------------------------------------
1 | #include "Interpret.h"
2 | #include
3 | using namespace std;
4 |
5 |
6 | AbstractExpression::AbstractExpression() { }
7 | AbstractExpression::~AbstractExpression() { }
8 | void AbstractExpression::Interpret(const Context &c) { }
9 |
10 |
11 |
12 | TerminalExpression::TerminalExpression(const string &statement)
13 | {
14 | this->_statement = statement;
15 | }
16 | TerminalExpression::~TerminalExpression() { }
17 | void TerminalExpression::Interpret(const Context &c)
18 | {
19 | cout << this->_statement << " TerminalExpression" << endl;
20 | }
21 |
22 |
23 |
24 | NonterminalExpression::NonterminalExpression(AbstractExpression *expression, int times)
25 | {
26 | this->_expression = expression;
27 | this->_times = times;
28 | }
29 | NonterminalExpression::~NonterminalExpression() { }
30 | void NonterminalExpression::Interpret(const Context &c)
31 | {
32 | for (int i = 0; i < _times ; i++)
33 | {
34 | this->_expression->Interpret(c);
35 | }
36 | }
37 |
--------------------------------------------------------------------------------
/DesignPatternOf23Kinds/Interpreter/Interpret.h:
--------------------------------------------------------------------------------
1 | //Interpret.h
2 | #ifndef _INTERPRET_H_
3 | #define _INTERPRET_H_
4 | #include "Context.h"
5 | #include
6 | using namespace std;
7 |
8 |
9 | class AbstractExpression
10 | {
11 | public:
12 | virtual ~AbstractExpression();
13 | virtual void Interpret(const Context &c);
14 | protected:
15 | AbstractExpression();
16 | private:
17 | };
18 |
19 |
20 | class TerminalExpression: public AbstractExpression
21 | {
22 | public:
23 | TerminalExpression(const string &statement);
24 | ~ TerminalExpression();
25 | void Interpret(const Context &c);
26 | protected:
27 | private:
28 | string _statement;
29 | };
30 |
31 |
32 | class NonterminalExpression: public AbstractExpression
33 | {
34 | public:
35 | NonterminalExpression(AbstractExpression *expression, int times);
36 | ~ NonterminalExpression();
37 | void Interpret(const Context &c);
38 | protected:
39 | private:
40 | AbstractExpression *_expression;
41 | int _times;
42 | };
43 |
44 |
45 | #endif //~_INTERPRET_H_
46 |
--------------------------------------------------------------------------------
/DesignPatternOf23Kinds/Interpreter/Interpreter.cpp:
--------------------------------------------------------------------------------
1 | #include "Context.h"
2 | #include "Interpret.h"
3 | #include
4 | using namespace std;
5 |
6 | int main(int argc, char *argv[])
7 | {
8 | Context *c = new Context();
9 | AbstractExpression *te = new TerminalExpression("hello");
10 | AbstractExpression *nte = new NonterminalExpression(te, 2);
11 | nte->Interpret(*c);
12 |
13 | system("pause");
14 | return 0;
15 | }
--------------------------------------------------------------------------------
/DesignPatternOf23Kinds/Interpreter/Interpreter.vcxproj.filters:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
--------------------------------------------------------------------------------
/DesignPatternOf23Kinds/Iterator/Aggregate.cpp:
--------------------------------------------------------------------------------
1 | //Aggregate.cpp
2 | #include "Aggregate.h"
3 | #include "Iterator.h"
4 | #include
5 | using namespace std;
6 | Aggregate::Aggregate() {}
7 | Aggregate::~Aggregate() { }
8 |
9 |
10 | ConcreteAggregate::ConcreteAggregate()
11 | {
12 | for (int i = 0; i < SIZE; i++)
13 | _objs[i] = i;
14 | }
15 | ConcreteAggregate::~ConcreteAggregate() { }
16 | Iterator *ConcreteAggregate::CreateIterator()
17 | {
18 | return new ConcreteIterator(this);
19 | }
20 | Object ConcreteAggregate::GetItem(int idx)
21 | {
22 | if (idx < this->GetSize())
23 | return _objs[idx];
24 | else
25 | return -1;
26 | }
27 | int ConcreteAggregate::GetSize()
28 | {
29 | return SIZE;
30 | }
--------------------------------------------------------------------------------
/DesignPatternOf23Kinds/Iterator/Aggregate.h:
--------------------------------------------------------------------------------
1 | //Aggregate.h
2 | #ifndef _AGGREGATE_H_
3 | #define _AGGREGATE_H_
4 |
5 | class Iterator;
6 | typedef int Object;
7 | class Interator;
8 |
9 |
10 | class Aggregate
11 | {
12 | public:
13 | virtual ~Aggregate();
14 | virtual Iterator *CreateIterator() = 0;
15 | virtual Object GetItem(int idx) = 0;
16 | virtual int GetSize() = 0;
17 | protected:
18 | Aggregate();
19 | private:
20 | };
21 |
22 | class ConcreteAggregate: public Aggregate
23 | {
24 | public:
25 | enum {SIZE = 3};
26 | ConcreteAggregate();
27 | ~ConcreteAggregate();
28 | Iterator *CreateIterator();
29 | Object GetItem(int idx);
30 | int GetSize();
31 | protected:
32 | private:
33 | Object _objs[SIZE];
34 | };
35 | #endif //~_AGGREGATE_H_
--------------------------------------------------------------------------------
/DesignPatternOf23Kinds/Iterator/Iterator.cpp:
--------------------------------------------------------------------------------
1 | //Iterator.cpp
2 | #include "Iterator.h"
3 | #include "Aggregate.h"
4 | #include
5 | using namespace std;
6 |
7 |
8 | Iterator::Iterator() { }
9 | Iterator::~Iterator() { }
10 |
11 |
12 | ConcreteIterator::ConcreteIterator(Aggregate *ag , int idx)
13 | {
14 | this->_ag = ag;
15 | this->_idx = idx;
16 | }
17 | ConcreteIterator::~ConcreteIterator() { }
18 | Object ConcreteIterator::CurrentItem()
19 | {
20 | return _ag->GetItem(_idx);
21 | }
22 | void ConcreteIterator::First()
23 | {
24 | _idx = 0;
25 | }
26 | void ConcreteIterator::Next()
27 | {
28 | if (_idx < _ag->GetSize())
29 | _idx++;
30 | }
31 | bool ConcreteIterator::IsDone()
32 | {
33 | return (_idx == _ag->GetSize());
34 | }
--------------------------------------------------------------------------------
/DesignPatternOf23Kinds/Iterator/Iterator.h:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/lizhenghn123/CppLanguagePrograms/add5848861197a53feabba480e43fd8bb8f074fb/DesignPatternOf23Kinds/Iterator/Iterator.h
--------------------------------------------------------------------------------
/DesignPatternOf23Kinds/Iterator/Iterator.vcxproj.filters:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
--------------------------------------------------------------------------------
/DesignPatternOf23Kinds/Iterator/testIterator.cpp:
--------------------------------------------------------------------------------
1 | //main.cpp
2 | #include "Iterator.h"
3 | #include "Aggregate.h"
4 | #include
5 | using namespace std;
6 | int main(int argc, char *argv[])
7 | {
8 | Aggregate *ag = new ConcreteAggregate();
9 | Iterator *it = new ConcreteIterator(ag);
10 | for (; !(it->IsDone()) ; it->Next())
11 | {
12 | cout << it->CurrentItem() << endl;
13 | }
14 |
15 | system("pause");
16 | return 0;
17 | }
--------------------------------------------------------------------------------
/DesignPatternOf23Kinds/Mediator/Colleage.cpp:
--------------------------------------------------------------------------------
1 | #include "Mediator.h"
2 | #include "Colleage.h"
3 | #include
4 | using namespace std;
5 |
6 | Colleage::Colleage()
7 | {
8 | //_sdt = " ";
9 | }
10 | Colleage::Colleage(Mediator *mdt)
11 | {
12 | this->_mdt = mdt;
13 | //_sdt = " ";
14 | }
15 | Colleage::~Colleage()
16 | {
17 | }
18 |
19 |
20 | ConcreteColleageA::ConcreteColleageA() { }
21 | ConcreteColleageA::~ConcreteColleageA() { }
22 |
23 | ConcreteColleageA::ConcreteColleageA(Mediator *mdt): Colleage(mdt)
24 | {
25 | }
26 | string ConcreteColleageA::GetState()
27 | {
28 | return _sdt;
29 | }
30 | void ConcreteColleageA::SetState(const string &sdt)
31 | {
32 | _sdt = sdt;
33 | }
34 | void ConcreteColleageA::Aciton()
35 | {
36 | _mdt->DoActionFromAtoB();
37 | cout << "State of ConcreteColleageB:" << " " << this->GetState() << endl;
38 | }
39 |
40 |
41 | ConcreteColleageB::ConcreteColleageB() { }
42 | ConcreteColleageB::~ConcreteColleageB() { }
43 |
44 | ConcreteColleageB::ConcreteColleageB(Mediator *mdt): Colleage(mdt)
45 | {
46 | }
47 | void ConcreteColleageB::Aciton()
48 | {
49 | _mdt->DoActionFromBtoA();
50 | cout << "State of ConcreteColleageA:" << " " << this->GetState() << endl;
51 | }
52 | string ConcreteColleageB::GetState()
53 | {
54 | return _sdt;
55 | }
56 | void ConcreteColleageB::SetState(const string &sdt)
57 | {
58 | _sdt = sdt;
59 | }
60 |
--------------------------------------------------------------------------------
/DesignPatternOf23Kinds/Mediator/Colleage.h:
--------------------------------------------------------------------------------
1 | #ifndef _COLLEAGE_H_
2 | #define _COLLEAGE_H_
3 | #include
4 | using namespace std;
5 | class Mediator;
6 |
7 | class Colleage
8 | {
9 | public:
10 | virtual ~Colleage();
11 | virtual void Aciton() = 0;
12 | virtual void SetState(const string &sdt) = 0;
13 | virtual string GetState() = 0;
14 | protected:
15 | Colleage();
16 | Colleage(Mediator *mdt);
17 | Mediator *_mdt;
18 | private:
19 | };
20 |
21 | class ConcreteColleageA: public Colleage
22 | {
23 | public:
24 | ConcreteColleageA();
25 | ConcreteColleageA(Mediator *mdt);
26 | ~ConcreteColleageA();
27 | void Aciton();
28 | void SetState(const string &sdt);
29 | string GetState();
30 | protected:
31 | private:
32 | string _sdt;
33 | };
34 |
35 | class ConcreteColleageB: public Colleage
36 | {
37 | public:
38 | ConcreteColleageB();
39 | ConcreteColleageB(Mediator *mdt);
40 | ~ConcreteColleageB();
41 | void Aciton();
42 | void SetState(const string &sdt);
43 | string GetState();
44 | protected:
45 | private:
46 | string _sdt;
47 | };
48 | #endif //~_COLLEAGE_H_
49 |
--------------------------------------------------------------------------------
/DesignPatternOf23Kinds/Mediator/Mediator.cpp:
--------------------------------------------------------------------------------
1 | #include "Mediator.h"
2 | #include "Colleage.h"
3 |
4 |
5 | Mediator::Mediator() { }
6 | Mediator::~Mediator() { }
7 |
8 | ConcreteMediator::ConcreteMediator() { }
9 | ConcreteMediator::~ConcreteMediator() { }
10 | ConcreteMediator::ConcreteMediator(Colleage *clgA, Colleage *clgB)
11 | {
12 | this->_clgA = clgA;
13 | this->_clgB = clgB;
14 | }
15 | void ConcreteMediator::SetConcreteColleageA(Colleage *clgA)
16 | {
17 | this->_clgA = clgA;
18 | }
19 | void ConcreteMediator::SetConcreteColleageB(Colleage *clgB)
20 | {
21 | this->_clgB = clgB;
22 | }
23 | Colleage *ConcreteMediator::GetConcreteColleageA()
24 | {
25 | return _clgA;
26 | }
27 | Colleage *ConcreteMediator::GetConcreteColleageB()
28 | {
29 | return _clgB;
30 | }
31 |
32 | void ConcreteMediator::IntroColleage(Colleage *clgA, Colleage *clgB)
33 | {
34 | this->_clgA = clgA;
35 | this->_clgB = clgB;
36 | }
37 |
38 | void ConcreteMediator::DoActionFromAtoB()
39 | {
40 | _clgB->SetState(_clgA->GetState());
41 | }
42 | void ConcreteMediator::DoActionFromBtoA()
43 | {
44 | _clgA->SetState(_clgB->GetState());
45 | }
--------------------------------------------------------------------------------
/DesignPatternOf23Kinds/Mediator/Mediator.h:
--------------------------------------------------------------------------------
1 | //Mediator.h
2 | #ifndef _MEDIATOR_H_
3 | #define _MEDIATOR_H_
4 | class Colleage;
5 |
6 | class Mediator
7 | {
8 | public:
9 | virtual ~Mediator();
10 | virtual void DoActionFromAtoB() = 0;
11 | virtual void DoActionFromBtoA() = 0;
12 | protected:
13 | Mediator();
14 | private:
15 | };
16 |
17 |
18 | class ConcreteMediator: public Mediator
19 | {
20 | public:
21 | ConcreteMediator();
22 | ConcreteMediator(Colleage *clgA, Colleage *clgB);
23 | ~ConcreteMediator();
24 | void SetConcreteColleageA(Colleage *clgA);
25 | void SetConcreteColleageB(Colleage *clgB);
26 | Colleage *GetConcreteColleageA();
27 | Colleage *GetConcreteColleageB();
28 | void IntroColleage(Colleage *clgA, Colleage *clgB);
29 | void DoActionFromAtoB();
30 | void DoActionFromBtoA();
31 | protected:
32 | private:
33 | Colleage *_clgA;
34 | Colleage *_clgB;
35 | };
36 |
37 |
38 | #endif //~_MEDIATOR_H_
--------------------------------------------------------------------------------
/DesignPatternOf23Kinds/Mediator/Mediator.vcxproj.filters:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
--------------------------------------------------------------------------------
/DesignPatternOf23Kinds/Mediator/testMediator.cpp:
--------------------------------------------------------------------------------
1 | #include "Mediator.h"
2 | #include "Colleage.h"
3 | #include
4 | using namespace std;
5 |
6 |
7 | int main(int argc, char *argv[])
8 | {
9 | ConcreteMediator *m = new ConcreteMediator();
10 | ConcreteColleageA *c1 = new ConcreteColleageA(m);
11 | ConcreteColleageB *c2 = new ConcreteColleageB(m);
12 | m->IntroColleage(c1, c2);
13 |
14 | c1->SetState("Aold");
15 | c2->SetState("Bold");
16 | c1->Aciton();
17 | c2->Aciton();
18 | cout << endl;
19 |
20 | c1->SetState("Anew");
21 | c1->Aciton();
22 | c2->Aciton();
23 | cout << endl;
24 |
25 | c2->SetState("BBold");
26 | c2->Aciton();
27 | c1->Aciton();
28 |
29 | system("pause");
30 | return 0;
31 | }
--------------------------------------------------------------------------------
/DesignPatternOf23Kinds/Memento/Memento.cpp:
--------------------------------------------------------------------------------
1 | #include "Memento.h"
2 | #include
3 | using namespace std;
4 | typedef string State;
5 |
6 |
7 | Originator::Originator()
8 | {
9 | _sdt = "";
10 | _mt = 0;
11 | }
12 | Originator::Originator(const State &sdt)
13 | {
14 | _sdt = sdt;
15 | _mt = 0;
16 | }
17 | Originator::~Originator()
18 | {
19 | }
20 | Memento *Originator::CreateMemento()
21 | {
22 | return new Memento(_sdt);
23 | }
24 | State Originator::GetState()
25 | {
26 | return _sdt;
27 | }
28 | void Originator::SetState(const State &sdt)
29 | {
30 | _sdt = sdt;
31 | }
32 | void Originator::PrintState()
33 | {
34 | cout << this->_sdt << "....." << endl;
35 | }
36 | void Originator::SetMemento(Memento *men)
37 | {
38 | }
39 | void Originator::RestoreToMemento(Memento *mt)
40 | {
41 | this->_sdt = mt->GetState();
42 | }
43 |
44 |
45 | //class Memento
46 | Memento::Memento()
47 | {
48 |
49 | }
50 | Memento::Memento(const State &sdt)
51 | {
52 | _sdt = sdt;
53 | }
54 | State Memento::GetState()
55 | {
56 | return _sdt;
57 | }
58 | void Memento::SetState(const State &sdt)
59 | {
60 | _sdt = sdt;
61 | }
62 |
--------------------------------------------------------------------------------
/DesignPatternOf23Kinds/Memento/Memento.h:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/lizhenghn123/CppLanguagePrograms/add5848861197a53feabba480e43fd8bb8f074fb/DesignPatternOf23Kinds/Memento/Memento.h
--------------------------------------------------------------------------------
/DesignPatternOf23Kinds/Memento/Memento.vcxproj.filters:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
--------------------------------------------------------------------------------
/DesignPatternOf23Kinds/Memento/testMemento.cpp:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/lizhenghn123/CppLanguagePrograms/add5848861197a53feabba480e43fd8bb8f074fb/DesignPatternOf23Kinds/Memento/testMemento.cpp
--------------------------------------------------------------------------------
/DesignPatternOf23Kinds/Observer/Observer.cpp:
--------------------------------------------------------------------------------
1 | //Observer.cpp
2 | #include "Observer.h"
3 | #include "Subject.h"
4 | #include
5 | #include
6 | using namespace std;
7 | Observer::Observer()
8 | {
9 | _st = '\0';
10 | }
11 | Observer::~Observer() { }
12 |
13 |
14 | ConcreteObserverA::ConcreteObserverA(Subject *sub)
15 | {
16 | _sub = sub;
17 | _sub->Attach(this);
18 | }
19 | ConcreteObserverA::~ConcreteObserverA()
20 | {
21 | _sub->Detach(this);
22 | if (_sub != 0)
23 | {
24 | delete _sub;
25 | }
26 | }
27 | Subject *ConcreteObserverA::GetSubject()
28 | {
29 | return _sub;
30 | }
31 | void ConcreteObserverA::PrintInfo()
32 | {
33 | cout << "ConcreteObserverA observer.... " << _sub->GetState() << endl;
34 | }
35 | void ConcreteObserverA::Update(Subject *sub)
36 | {
37 | _st = sub->GetState();
38 | PrintInfo();
39 | }
40 |
41 |
42 | ConcreteObserverB::ConcreteObserverB(Subject *sub)
43 | {
44 | _sub = sub;
45 | _sub->Attach(this);
46 | }
47 | ConcreteObserverB::~ConcreteObserverB()
48 | {
49 | _sub->Detach(this);
50 | if (_sub != 0)
51 | {
52 | delete _sub;
53 | }
54 | }
55 | Subject *ConcreteObserverB::GetSubject()
56 | {
57 | return _sub;
58 | }
59 | void ConcreteObserverB::PrintInfo()
60 | {
61 | cout << "ConcreteObserverB observer.... " << _sub->GetState() << endl;
62 | }
63 | void ConcreteObserverB::Update(Subject *sub)
64 | {
65 | _st = sub->GetState();
66 | PrintInfo();
67 | }
68 |
--------------------------------------------------------------------------------
/DesignPatternOf23Kinds/Observer/Observer.h:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/lizhenghn123/CppLanguagePrograms/add5848861197a53feabba480e43fd8bb8f074fb/DesignPatternOf23Kinds/Observer/Observer.h
--------------------------------------------------------------------------------
/DesignPatternOf23Kinds/Observer/Observer.vcxproj.filters:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
--------------------------------------------------------------------------------
/DesignPatternOf23Kinds/Observer/Subject.cpp:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/lizhenghn123/CppLanguagePrograms/add5848861197a53feabba480e43fd8bb8f074fb/DesignPatternOf23Kinds/Observer/Subject.cpp
--------------------------------------------------------------------------------
/DesignPatternOf23Kinds/Observer/Subject.h:
--------------------------------------------------------------------------------
1 | //Subject.h
2 | #ifndef _SUBJECT_H_
3 | #define _SUBJECT_H_
4 | #include
5 | #include
6 | using namespace std;
7 | typedef string State;
8 | class Observer;
9 |
10 | class Subject
11 | {
12 | public:
13 | virtual ~Subject();
14 | virtual void Attach(Observer *obv);
15 | virtual void Detach(Observer *obv);
16 | virtual void Notify();
17 | virtual void SetState(const State &st) = 0;
18 | virtual State GetState() = 0;
19 | protected:
20 | Subject();
21 | private:
22 | list *_obvs;
23 | };
24 |
25 |
26 | class ConcreteSubject: public Subject
27 | {
28 | public:
29 | ConcreteSubject();
30 | ~ConcreteSubject();
31 | State GetState();
32 | void SetState(const State &st);
33 | protected:
34 | private:
35 | State _st;
36 | };
37 | #endif //~_SUBJECT_H_
38 |
--------------------------------------------------------------------------------
/DesignPatternOf23Kinds/Observer/testObserver.cpp:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/lizhenghn123/CppLanguagePrograms/add5848861197a53feabba480e43fd8bb8f074fb/DesignPatternOf23Kinds/Observer/testObserver.cpp
--------------------------------------------------------------------------------
/DesignPatternOf23Kinds/Prototype/Prototype.h:
--------------------------------------------------------------------------------
1 | //Prototype.h
2 | #ifndef _PROTOTYPE_H_
3 | #define _PROTOTYPE_H_
4 |
5 | #include
6 | using namespace std;
7 |
8 |
9 | class Prototype
10 | {
11 | public:
12 | virtual ~Prototype() {}
13 | virtual Prototype *Clone() const = 0;
14 | protected:
15 | Prototype() {}
16 | private:
17 | };
18 |
19 | class ConcretePrototype: public Prototype
20 | {
21 | public:
22 | ConcretePrototype() {}
23 | ConcretePrototype(const ConcretePrototype &cp)
24 | {
25 | cout << "ConcretePrototype copy ..." << endl;
26 | }
27 | ~ConcretePrototype() {}
28 | Prototype *Clone() const
29 | {
30 | return new ConcretePrototype(*this);
31 | }
32 | protected:
33 | private:
34 | };
35 |
36 |
37 | Prototype *Prototype::Clone() const
38 | {
39 | return 0;
40 | }
41 |
42 |
43 | #endif //~_PROTOTYPE_H_
--------------------------------------------------------------------------------
/DesignPatternOf23Kinds/Prototype/Prototype.vcxproj.filters:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
--------------------------------------------------------------------------------
/DesignPatternOf23Kinds/Prototype/testPrototype.cpp:
--------------------------------------------------------------------------------
1 | #include "Prototype.h"
2 | #include
3 | using namespace std;
4 |
5 |
6 | int main(int argc, char *argv[])
7 | {
8 | Prototype *p = new ConcretePrototype();
9 | Prototype *p1 = p->Clone();
10 |
11 | system("pause");
12 | return 0;
13 | }
--------------------------------------------------------------------------------
/DesignPatternOf23Kinds/Proxy/Proxy.h:
--------------------------------------------------------------------------------
1 | //Proxy.h
2 | #ifndef _PROXY_H_
3 | #define _PROXY_H_
4 |
5 | #include
6 | using std::cout;
7 | using std::endl;
8 |
9 |
10 | class Subject
11 | {
12 | public:
13 | virtual ~Subject() { }
14 | virtual void Request() = 0;
15 | protected:
16 | Subject() { }
17 | };
18 |
19 | class ConcreteSubject: public Subject
20 | {
21 | public:
22 | ConcreteSubject() { }
23 | ~ConcreteSubject() { }
24 | void Request()
25 | {
26 | cout << "ConcreteSubject......request...." << endl;
27 | }
28 | };
29 |
30 |
31 | class Proxy
32 | {
33 | public:
34 | Proxy() { }
35 | Proxy(Subject *sub)
36 | {
37 | _sub = sub;
38 | }
39 | ~Proxy()
40 | {
41 | delete _sub;
42 | }
43 | void Request()
44 | {
45 | cout << "Proxy request...." << endl;
46 | _sub->Request();
47 | }
48 | private:
49 | Subject *_sub;
50 | };
51 | #endif //~_PROXY_H_
--------------------------------------------------------------------------------
/DesignPatternOf23Kinds/Proxy/Proxy.vcxproj.filters:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
--------------------------------------------------------------------------------
/DesignPatternOf23Kinds/Proxy/testProxy.cpp:
--------------------------------------------------------------------------------
1 | #include "Proxy.h"
2 | #include
3 | using namespace std;
4 |
5 | int main(int argc, char *argv[])
6 | {
7 | Subject *sub = new ConcreteSubject();
8 | Proxy *p = new Proxy(sub);
9 | p->Request();
10 |
11 | system("pause");
12 | return 0;
13 | }
--------------------------------------------------------------------------------
/DesignPatternOf23Kinds/Singleton/Singleton.h:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/lizhenghn123/CppLanguagePrograms/add5848861197a53feabba480e43fd8bb8f074fb/DesignPatternOf23Kinds/Singleton/Singleton.h
--------------------------------------------------------------------------------
/DesignPatternOf23Kinds/Singleton/Singleton.vcxproj.filters:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
--------------------------------------------------------------------------------
/DesignPatternOf23Kinds/Singleton/testSingleton.cpp:
--------------------------------------------------------------------------------
1 | #include
2 | #include "Singleton.h"
3 | using namespace std;
4 |
5 | int main()
6 | {
7 | //----------------------------------------------------------------
8 | Singleton *sgn = Singleton::Instance();
9 | //----------------------------------------------------------------
10 | Test *test = Test_Ton::getSingleTonPtr();
11 | test->i = 100;
12 | test->print();
13 | Test_Ton::getSingleTonPtr()->print();
14 | //----------------------------------------------------------------
15 | FGHYU *gh = FGHYU::getSingleTonPtr();
16 | gh->i = 1453;
17 | gh->print();
18 | FGHYU::getSingleTonPtr()->print();
19 |
20 | system("pause");
21 | return 0;
22 | }
--------------------------------------------------------------------------------
/DesignPatternOf23Kinds/State/Context.cpp:
--------------------------------------------------------------------------------
1 | //context.cpp
2 | #include "Context.h"
3 | #include "State.h"
4 | Context::Context()
5 | {
6 | }
7 | Context::Context(State *state)
8 | {
9 | this->_state = state;
10 | }
11 | Context::~Context()
12 | {
13 | delete _state;
14 | }
15 | void Context::OprationInterface()
16 | {
17 | _state->OperationInterface(this);
18 | }
19 | bool Context::ChangeState(State *state)
20 | {
21 | ///_state->ChangeState(this,state);
22 | this->_state = state;
23 | return true;
24 | }
25 | void Context::OperationChangState()
26 | {
27 | _state->OperationChangeState(this);
28 | }
--------------------------------------------------------------------------------
/DesignPatternOf23Kinds/State/Context.h:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/lizhenghn123/CppLanguagePrograms/add5848861197a53feabba480e43fd8bb8f074fb/DesignPatternOf23Kinds/State/Context.h
--------------------------------------------------------------------------------
/DesignPatternOf23Kinds/State/State.cpp:
--------------------------------------------------------------------------------
1 | //State.cpp
2 | #include "State.h"
3 | #include "Context.h"
4 | #include
5 | using namespace std;
6 | State::State()
7 | {
8 | }
9 | State::~State()
10 | {
11 | }
12 | void State::OperationInterface(Context *con)
13 | {
14 | cout << "State::.." << endl;
15 | }
16 | bool State::ChangeState(Context *con, State *st)
17 | {
18 | con->ChangeState(st);
19 | return true;
20 | }
21 | void State::OperationChangeState(Context *con)
22 | {
23 |
24 | }
25 | ///
26 | ConcreteStateA::ConcreteStateA()
27 | {
28 | }
29 | ConcreteStateA::~ConcreteStateA()
30 | {
31 | }
32 | void ConcreteStateA::OperationInterface(Context *con)
33 | {
34 | cout << "ConcreteStateA::OperationInterface......" << endl;
35 | }
36 | void ConcreteStateA::OperationChangeState(Context *con)
37 | {
38 | OperationInterface(con);
39 | this->ChangeState(con, new ConcreteStateB());
40 | }
41 | ///
42 | ConcreteStateB::ConcreteStateB()
43 | {
44 | }
45 | ConcreteStateB::~ConcreteStateB()
46 | {
47 | }
48 | void ConcreteStateB::OperationInterface(Context *con)
49 | {
50 | cout << "ConcreteStateB::OperationInterface......" << endl;
51 | }
52 | void ConcreteStateB::OperationChangeState(Context *con)
53 | {
54 | OperationInterface(con);
55 | this->ChangeState(con, new ConcreteStateA());
56 | }
--------------------------------------------------------------------------------
/DesignPatternOf23Kinds/State/State.h:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/lizhenghn123/CppLanguagePrograms/add5848861197a53feabba480e43fd8bb8f074fb/DesignPatternOf23Kinds/State/State.h
--------------------------------------------------------------------------------
/DesignPatternOf23Kinds/State/State.vcxproj.filters:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
--------------------------------------------------------------------------------
/DesignPatternOf23Kinds/State/testState.cpp:
--------------------------------------------------------------------------------
1 | #include "Context.h"
2 | #include "State.h"
3 | #include
4 | using namespace std;
5 | int main(int argc, char *argv[])
6 | {
7 | State *st = new ConcreteStateA();
8 | Context *con = new Context(st);
9 | con->OperationChangState();
10 | con->OperationChangState();
11 | con->OperationChangState();
12 | if (con != NULL)
13 | delete con;
14 | if (st != NULL)
15 | st = NULL;
16 |
17 | system("pause");
18 | return 0;
19 | }
--------------------------------------------------------------------------------
/DesignPatternOf23Kinds/Strategy/Context.h:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/lizhenghn123/CppLanguagePrograms/add5848861197a53feabba480e43fd8bb8f074fb/DesignPatternOf23Kinds/Strategy/Context.h
--------------------------------------------------------------------------------
/DesignPatternOf23Kinds/Strategy/Strategy.h:
--------------------------------------------------------------------------------
1 | //strategy.h
2 | #ifndef _STRATEGY_H_
3 | #define _STRATEGY_H_
4 | #include
5 | using namespace std;
6 |
7 | class Strategy
8 | {
9 | public:
10 | Strategy() { }
11 | virtual ~Strategy()
12 | {
13 | cout << "~Strategy....." << endl;
14 | }
15 | virtual void AlgrithmInterface() = 0 { }
16 | };
17 |
18 |
19 | class ConcreteStrategyA: public Strategy
20 | {
21 | public:
22 | ConcreteStrategyA() { }
23 | virtual ~ConcreteStrategyA()
24 | {
25 | cout << "~ConcreteStrategyA....." << endl;
26 | }
27 | void AlgrithmInterface()
28 | {
29 | cout << "test ConcreteStrategyA....." << endl;
30 | }
31 | };
32 |
33 |
34 | class ConcreteStrategyB: public Strategy
35 | {
36 | public:
37 | ConcreteStrategyB() { }
38 | virtual ~ConcreteStrategyB()
39 | {
40 | cout << "~ConcreteStrategyB....." << endl;
41 | }
42 | void AlgrithmInterface()
43 | {
44 | cout << "test ConcreteStrategyB....." << endl;
45 | }
46 | };
47 | #endif //~_STRATEGY_H_
--------------------------------------------------------------------------------
/DesignPatternOf23Kinds/Strategy/Strategy.vcxproj.filters:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
--------------------------------------------------------------------------------
/DesignPatternOf23Kinds/Strategy/testStrategy.cpp:
--------------------------------------------------------------------------------
1 | #include "Context.h"
2 | #include "Strategy.h"
3 | #include
4 | using namespace std;
5 |
6 |
7 | int main(int argc, char *argv[])
8 | {
9 | Strategy *ps = new ConcreteStrategyB();
10 | Context *pc = new Context(ps);
11 | pc->DoAction();
12 | if (NULL != pc)
13 | delete pc;
14 |
15 | system("pause");
16 | return 0;
17 | }
--------------------------------------------------------------------------------
/DesignPatternOf23Kinds/Template/Template.h:
--------------------------------------------------------------------------------
1 | //Template.h
2 |
3 | #ifndef _TEMPLATE_H_
4 | #define _TEMPLATE_H_
5 | #include
6 | using namespace std;
7 |
8 | class AbstractClass
9 | {
10 | public:
11 | virtual ~AbstractClass() { }
12 | void TemplateMethod()
13 | {
14 | this->PrimitiveOperation1();
15 | this->PrimitiveOperation2();
16 |
17 | }
18 | protected:
19 | virtual void PrimitiveOperation1() = 0;
20 | virtual void PrimitiveOperation2() = 0;
21 | AbstractClass() { }
22 | };
23 |
24 | class ConcreteClass1: public AbstractClass
25 | {
26 | public:
27 | ConcreteClass1() { }
28 | ~ConcreteClass1() { }
29 |
30 | protected:
31 | void PrimitiveOperation1()
32 | {
33 | cout << "ConcreteClass1...PrimitiveOperat ion1" << endl;
34 | }
35 | void PrimitiveOperation2()
36 | {
37 | cout << "ConcreteClass1...PrimitiveOperat ion2" << endl;
38 | }
39 | };
40 |
41 | class ConcreteClass2: public AbstractClass
42 | {
43 | public:
44 | ConcreteClass2() { }
45 | ~ConcreteClass2() { }
46 |
47 | protected:
48 | void PrimitiveOperation1()
49 | {
50 | cout << "ConcreteClass2...PrimitiveOperat ion1" << endl;
51 | }
52 | void PrimitiveOperation2()
53 | {
54 | cout << "ConcreteClass2...PrimitiveOperat ion2" << endl;
55 | }
56 | };
57 |
58 | #endif //~_TEMPLATE_H_
59 |
--------------------------------------------------------------------------------
/DesignPatternOf23Kinds/Template/Template.vcxproj.filters:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
--------------------------------------------------------------------------------
/DesignPatternOf23Kinds/Template/testTemplate.cpp:
--------------------------------------------------------------------------------
1 | #include "Template.h"
2 |
3 | #include
4 | using namespace std;
5 |
6 |
7 | int main(int argc, char *argv[])
8 | {
9 | AbstractClass *p1 = new ConcreteClass1();
10 | AbstractClass *p2 = new ConcreteClass2();
11 |
12 | p1->TemplateMethod();
13 | p2->TemplateMethod();
14 |
15 | system("pause");
16 | return 0;
17 | }
18 |
--------------------------------------------------------------------------------
/DesignPatternOf23Kinds/Visitor/Element.cpp:
--------------------------------------------------------------------------------
1 | //Element.cpp
2 | #include "Element.h"
3 | #include "Visitor.h"
4 |
5 | #include
6 | using namespace std;
7 |
8 | Element::Element()
9 | {
10 | }
11 | Element::~Element()
12 | {
13 | }
14 |
15 | void Element::Accept(Visitor *vis)
16 | {
17 | }
18 |
19 | ConcreteElementA::ConcreteElementA()
20 | {
21 | }
22 |
23 | ConcreteElementA::~ConcreteElementA()
24 | {
25 | }
26 | void ConcreteElementA::Accept(Visitor *vis)
27 | {
28 | vis->VisitConcreteElementA(this);
29 | cout << "visiting ConcreteElementA..." << endl;
30 | }
31 |
32 | ConcreteElementB::ConcreteElementB()
33 | {
34 | }
35 | ConcreteElementB::~ConcreteElementB()
36 | {
37 | }
38 |
39 | void ConcreteElementB::Accept(Visitor *vis)
40 | {
41 | cout << "visiting ConcreteElementB..." << endl;
42 | vis->VisitConcreteElementB(this);
43 | }
--------------------------------------------------------------------------------
/DesignPatternOf23Kinds/Visitor/Element.h:
--------------------------------------------------------------------------------
1 | //Element.h
2 | #ifndef _ELEMENT_H_
3 | #define _ELEMENT_H_
4 |
5 | class Visitor;
6 |
7 | class Element
8 | {
9 | public:
10 | virtual ~Element();
11 | virtual void Accept(Visitor *vis) = 0;
12 | protected:
13 | Element();
14 | };
15 |
16 | class ConcreteElementA: public Element
17 | {
18 | public:
19 | ConcreteElementA();
20 | ~ConcreteElementA();
21 | void Accept(Visitor *vis);
22 | };
23 |
24 | class ConcreteElementB: public Element
25 | {
26 | public:
27 | ConcreteElementB();
28 | ~ConcreteElementB();
29 | void Accept(Visitor *vis);
30 | };
31 |
32 | #endif //~_ELEMENT_H_
--------------------------------------------------------------------------------
/DesignPatternOf23Kinds/Visitor/Visitor.h:
--------------------------------------------------------------------------------
1 | //Visitor.h
2 | #ifndef _VISITOR_H_
3 | #define _VISITOR_H_
4 | #include "Element.h"
5 | #include
6 | using namespace std;
7 |
8 |
9 | class Element;
10 |
11 | class Visitor
12 | {
13 | public:
14 | virtual ~Visitor() { }
15 | virtual void VisitConcreteElementA(Element *elm) = 0;
16 | virtual void VisitConcreteElementB(Element *elm) = 0;
17 | protected:
18 | Visitor() { }
19 | private:
20 | };
21 |
22 |
23 | class ConcreteVisitorA: public Visitor
24 | {
25 | public:
26 | ConcreteVisitorA() { }
27 | virtual ~ConcreteVisitorA() { }
28 | virtual void VisitConcreteElementA(Element *elm)
29 | {
30 | cout << "ConcreteVisitorA will visit ConcreteElementA..." << endl;
31 | }
32 | virtual void VisitConcreteElementB(Element *elm)
33 | {
34 | cout << "ConcreteVisitorA will visit ConcreteElementB..." << endl;
35 | }
36 | };
37 |
38 |
39 | class ConcreteVisitorB: public Visitor
40 | {
41 | public:
42 | ConcreteVisitorB() { }
43 | virtual ~ConcreteVisitorB() { }
44 | virtual void VisitConcreteElementA(Element *elm)
45 | {
46 | cout << "ConcreteVisitorB will visit ConcreteElementA..." << endl;
47 | }
48 | virtual void VisitConcreteElementB(Element *elm)
49 | {
50 | cout << "ConcreteVisitorB will visit ConcreteElementB..." << endl;
51 | }
52 | };
53 |
54 |
55 | #endif //~_VISITOR_H_
56 |
--------------------------------------------------------------------------------
/DesignPatternOf23Kinds/Visitor/Visitor.vcxproj.filters:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
--------------------------------------------------------------------------------
/DesignPatternOf23Kinds/Visitor/testVisitor.cpp:
--------------------------------------------------------------------------------
1 | #include "Element.h"
2 | #include "Visitor.h"
3 |
4 | #include
5 | using namespace std;
6 | int main(int argc, char *argv[])
7 | {
8 | Visitor *vis = new ConcreteVisitorB();
9 | Element *elm = new ConcreteElementB();
10 | elm->Accept(vis);
11 |
12 | system("pause");
13 | return 0;
14 | }
--------------------------------------------------------------------------------
/STL/dequeDemo/dequeDemo.cpp:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/lizhenghn123/CppLanguagePrograms/add5848861197a53feabba480e43fd8bb8f074fb/STL/dequeDemo/dequeDemo.cpp
--------------------------------------------------------------------------------
/STL/dequeDemo/dequeDemo.vcxproj.filters:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 | {4FC737F1-C7A5-4376-A066-2A32D752A2FF}
6 | cpp;c;cc;cxx;def;odl;idl;hpj;bat;asm;asmx
7 |
8 |
9 | {93995380-89BD-4b04-88EB-625FBE52EBFB}
10 | h;hpp;hxx;hm;inl;inc;xsd
11 |
12 |
13 | {67DA6AB6-F800-4c08-8B7A-83BB121AAD01}
14 | rc;ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe;resx;tiff;tif;png;wav;mfcribbon-ms
15 |
16 |
17 |
18 |
19 | Source Files
20 |
21 |
22 |
--------------------------------------------------------------------------------
/STL/find和find_if/find和find_if.cpp:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/lizhenghn123/CppLanguagePrograms/add5848861197a53feabba480e43fd8bb8f074fb/STL/find和find_if/find和find_if.cpp
--------------------------------------------------------------------------------
/STL/find和find_if/find和find_if.vcxproj.filters:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 | {4FC737F1-C7A5-4376-A066-2A32D752A2FF}
6 | cpp;c;cc;cxx;def;odl;idl;hpj;bat;asm;asmx
7 |
8 |
9 | {93995380-89BD-4b04-88EB-625FBE52EBFB}
10 | h;hpp;hxx;hm;inl;inc;xsd
11 |
12 |
13 | {67DA6AB6-F800-4c08-8B7A-83BB121AAD01}
14 | rc;ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe;resx;tiff;tif;png;wav;mfcribbon-ms
15 |
16 |
17 |
18 |
19 | Source Files
20 |
21 |
22 |
--------------------------------------------------------------------------------
/STL/for_each/for_each.cpp:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/lizhenghn123/CppLanguagePrograms/add5848861197a53feabba480e43fd8bb8f074fb/STL/for_each/for_each.cpp
--------------------------------------------------------------------------------
/STL/for_each/for_each.vcxproj.filters:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 | {4FC737F1-C7A5-4376-A066-2A32D752A2FF}
6 | cpp;c;cc;cxx;def;odl;idl;hpj;bat;asm;asmx
7 |
8 |
9 | {93995380-89BD-4b04-88EB-625FBE52EBFB}
10 | h;hpp;hxx;hm;inl;inc;xsd
11 |
12 |
13 | {67DA6AB6-F800-4c08-8B7A-83BB121AAD01}
14 | rc;ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe;resx;tiff;tif;png;wav;mfcribbon-ms
15 |
16 |
17 |
18 |
19 | Source Files
20 |
21 |
22 |
--------------------------------------------------------------------------------
/STL/heapDemo/heapDemo.cpp:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/lizhenghn123/CppLanguagePrograms/add5848861197a53feabba480e43fd8bb8f074fb/STL/heapDemo/heapDemo.cpp
--------------------------------------------------------------------------------
/STL/heapDemo/heapDemo.vcxproj.filters:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 | {4FC737F1-C7A5-4376-A066-2A32D752A2FF}
6 | cpp;c;cc;cxx;def;odl;idl;hpj;bat;asm;asmx
7 |
8 |
9 | {93995380-89BD-4b04-88EB-625FBE52EBFB}
10 | h;hpp;hxx;hm;inl;inc;xsd
11 |
12 |
13 | {67DA6AB6-F800-4c08-8B7A-83BB121AAD01}
14 | rc;ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe;resx;tiff;tif;png;wav;mfcribbon-ms
15 |
16 |
17 |
18 |
19 | Source Files
20 |
21 |
22 |
--------------------------------------------------------------------------------
/STL/intrusive_list/intrusive_list.vcxproj.filters:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 | {4FC737F1-C7A5-4376-A066-2A32D752A2FF}
6 | cpp;c;cc;cxx;def;odl;idl;hpj;bat;asm;asmx
7 |
8 |
9 | {93995380-89BD-4b04-88EB-625FBE52EBFB}
10 | h;hpp;hxx;hm;inl;inc;xsd
11 |
12 |
13 | {67DA6AB6-F800-4c08-8B7A-83BB121AAD01}
14 | rc;ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe;resx;tiff;tif;png;wav;mfcribbon-ms
15 |
16 |
17 |
18 |
19 | Header Files
20 |
21 |
22 |
23 |
24 | Source Files
25 |
26 |
27 |
--------------------------------------------------------------------------------
/STL/listDemo/listDemo.cpp:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/lizhenghn123/CppLanguagePrograms/add5848861197a53feabba480e43fd8bb8f074fb/STL/listDemo/listDemo.cpp
--------------------------------------------------------------------------------
/STL/listDemo/listDemo.vcxproj.filters:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 | {4FC737F1-C7A5-4376-A066-2A32D752A2FF}
6 | cpp;c;cc;cxx;def;odl;idl;hpj;bat;asm;asmx
7 |
8 |
9 | {93995380-89BD-4b04-88EB-625FBE52EBFB}
10 | h;hpp;hxx;hm;inl;inc;xsd
11 |
12 |
13 | {67DA6AB6-F800-4c08-8B7A-83BB121AAD01}
14 | rc;ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe;resx;tiff;tif;png;wav;mfcribbon-ms
15 |
16 |
17 |
18 |
19 | Source Files
20 |
21 |
22 |
--------------------------------------------------------------------------------
/STL/mapDemo/mapDemo.cpp:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/lizhenghn123/CppLanguagePrograms/add5848861197a53feabba480e43fd8bb8f074fb/STL/mapDemo/mapDemo.cpp
--------------------------------------------------------------------------------
/STL/mapDemo/mapDemo.vcxproj.filters:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 | {4FC737F1-C7A5-4376-A066-2A32D752A2FF}
6 | cpp;c;cc;cxx;def;odl;idl;hpj;bat;asm;asmx
7 |
8 |
9 | {93995380-89BD-4b04-88EB-625FBE52EBFB}
10 | h;hpp;hxx;hm;inl;inc;xsd
11 |
12 |
13 | {67DA6AB6-F800-4c08-8B7A-83BB121AAD01}
14 | rc;ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe;resx;tiff;tif;png;wav;mfcribbon-ms
15 |
16 |
17 |
18 |
19 | Source Files
20 |
21 |
22 |
--------------------------------------------------------------------------------
/STL/multimapDemo/multimapDemo.cpp:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/lizhenghn123/CppLanguagePrograms/add5848861197a53feabba480e43fd8bb8f074fb/STL/multimapDemo/multimapDemo.cpp
--------------------------------------------------------------------------------
/STL/multimapDemo/multimapDemo.vcxproj.filters:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 | {4FC737F1-C7A5-4376-A066-2A32D752A2FF}
6 | cpp;c;cc;cxx;def;odl;idl;hpj;bat;asm;asmx
7 |
8 |
9 | {93995380-89BD-4b04-88EB-625FBE52EBFB}
10 | h;hpp;hxx;hm;inl;inc;xsd
11 |
12 |
13 | {67DA6AB6-F800-4c08-8B7A-83BB121AAD01}
14 | rc;ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe;resx;tiff;tif;png;wav;mfcribbon-ms
15 |
16 |
17 |
18 |
19 | Source Files
20 |
21 |
22 |
--------------------------------------------------------------------------------
/STL/multisetDemo/multisetDemo.vcxproj.filters:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 | {4FC737F1-C7A5-4376-A066-2A32D752A2FF}
6 | cpp;c;cc;cxx;def;odl;idl;hpj;bat;asm;asmx
7 |
8 |
9 | {93995380-89BD-4b04-88EB-625FBE52EBFB}
10 | h;hpp;hxx;hm;inl;inc;xsd
11 |
12 |
13 | {67DA6AB6-F800-4c08-8B7A-83BB121AAD01}
14 | rc;ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe;resx;tiff;tif;png;wav;mfcribbon-ms
15 |
16 |
17 |
18 |
19 | Source Files
20 |
21 |
22 |
--------------------------------------------------------------------------------
/STL/queueDemo/queueDemo.cpp:
--------------------------------------------------------------------------------
1 | #include
2 | #include
3 | #include
4 | using namespace std;
5 |
6 | int main ()
7 | {
8 | string s1("C++");
9 | string s2("is");
10 | string s3("powerfull");
11 | string s4("language");
12 |
13 | queue que;
14 | que.push(s1);
15 | que.push(s2);
16 | que.push(s3);
17 | que.push(s4);
18 |
19 | cout << "size of queue 'que' = " << que.size() << endl;
20 |
21 | string temp = que.back();
22 | cout << temp << endl;
23 | while ( !que.empty() )
24 | {
25 | temp = que.front();
26 | cout << temp << " ";
27 | que.pop();
28 | }
29 | cout << endl;
30 |
31 | system("pause");
32 | return 0;
33 | }
--------------------------------------------------------------------------------
/STL/queueDemo/queueDemo.vcxproj.filters:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 | {4FC737F1-C7A5-4376-A066-2A32D752A2FF}
6 | cpp;c;cc;cxx;def;odl;idl;hpj;bat;asm;asmx
7 |
8 |
9 | {93995380-89BD-4b04-88EB-625FBE52EBFB}
10 | h;hpp;hxx;hm;inl;inc;xsd
11 |
12 |
13 | {67DA6AB6-F800-4c08-8B7A-83BB121AAD01}
14 | rc;ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe;resx;tiff;tif;png;wav;mfcribbon-ms
15 |
16 |
17 |
18 |
19 | Source Files
20 |
21 |
22 |
--------------------------------------------------------------------------------
/STL/setDemo/setDemo.vcxproj.filters:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 | {4FC737F1-C7A5-4376-A066-2A32D752A2FF}
6 | cpp;c;cc;cxx;def;odl;idl;hpj;bat;asm;asmx
7 |
8 |
9 | {93995380-89BD-4b04-88EB-625FBE52EBFB}
10 | h;hpp;hxx;hm;inl;inc;xsd
11 |
12 |
13 | {67DA6AB6-F800-4c08-8B7A-83BB121AAD01}
14 | rc;ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe;resx;tiff;tif;png;wav;mfcribbon-ms
15 |
16 |
17 |
18 |
19 | Source Files
20 |
21 |
22 |
--------------------------------------------------------------------------------
/STL/stackDemo/stackDemo.cpp:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/lizhenghn123/CppLanguagePrograms/add5848861197a53feabba480e43fd8bb8f074fb/STL/stackDemo/stackDemo.cpp
--------------------------------------------------------------------------------
/STL/stackDemo/stackDemo.vcxproj.filters:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 | {4FC737F1-C7A5-4376-A066-2A32D752A2FF}
6 | cpp;c;cc;cxx;def;odl;idl;hpj;bat;asm;asmx
7 |
8 |
9 | {93995380-89BD-4b04-88EB-625FBE52EBFB}
10 | h;hpp;hxx;hm;inl;inc;xsd
11 |
12 |
13 | {67DA6AB6-F800-4c08-8B7A-83BB121AAD01}
14 | rc;ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe;resx;tiff;tif;png;wav;mfcribbon-ms
15 |
16 |
17 |
18 |
19 | Source Files
20 |
21 |
22 |
--------------------------------------------------------------------------------
/STL/string分割/string分割.cpp:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/lizhenghn123/CppLanguagePrograms/add5848861197a53feabba480e43fd8bb8f074fb/STL/string分割/string分割.cpp
--------------------------------------------------------------------------------
/STL/string分割/string分割.vcxproj.filters:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 | {4FC737F1-C7A5-4376-A066-2A32D752A2FF}
6 | cpp;c;cc;cxx;def;odl;idl;hpj;bat;asm;asmx
7 |
8 |
9 | {93995380-89BD-4b04-88EB-625FBE52EBFB}
10 | h;hpp;hxx;hm;inl;inc;xsd
11 |
12 |
13 | {67DA6AB6-F800-4c08-8B7A-83BB121AAD01}
14 | rc;ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe;resx;tiff;tif;png;wav;mfcribbon-ms
15 |
16 |
17 |
18 |
19 | Source Files
20 |
21 |
22 |
--------------------------------------------------------------------------------
/STL/vectorDemo/vectorDemo.cpp:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/lizhenghn123/CppLanguagePrograms/add5848861197a53feabba480e43fd8bb8f074fb/STL/vectorDemo/vectorDemo.cpp
--------------------------------------------------------------------------------
/STL/vectorDemo/vectorDemo.vcxproj.filters:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 | {4FC737F1-C7A5-4376-A066-2A32D752A2FF}
6 | cpp;c;cc;cxx;def;odl;idl;hpj;bat;asm;asmx
7 |
8 |
9 | {93995380-89BD-4b04-88EB-625FBE52EBFB}
10 | h;hpp;hxx;hm;inl;inc;xsd
11 |
12 |
13 | {67DA6AB6-F800-4c08-8B7A-83BB121AAD01}
14 | rc;ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe;resx;tiff;tif;png;wav;mfcribbon-ms
15 |
16 |
17 |
18 |
19 | Source Files
20 |
21 |
22 |
--------------------------------------------------------------------------------
/STL/vector_list/test_vector_list.cpp:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/lizhenghn123/CppLanguagePrograms/add5848861197a53feabba480e43fd8bb8f074fb/STL/vector_list/test_vector_list.cpp
--------------------------------------------------------------------------------
/STL/vector_list/vector_list.vcxproj.filters:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 | {4FC737F1-C7A5-4376-A066-2A32D752A2FF}
6 | cpp;c;cc;cxx;def;odl;idl;hpj;bat;asm;asmx
7 |
8 |
9 | {93995380-89BD-4b04-88EB-625FBE52EBFB}
10 | h;hpp;hxx;hm;inl;inc;xsd
11 |
12 |
13 | {67DA6AB6-F800-4c08-8B7A-83BB121AAD01}
14 | rc;ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe;resx;tiff;tif;png;wav;mfcribbon-ms
15 |
16 |
17 |
18 |
19 | Source Files
20 |
21 |
22 |
--------------------------------------------------------------------------------
/STL/vector和map/vector和map.cpp:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/lizhenghn123/CppLanguagePrograms/add5848861197a53feabba480e43fd8bb8f074fb/STL/vector和map/vector和map.cpp
--------------------------------------------------------------------------------
/STL/vector和map/vector和map.vcxproj.filters:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 | {4FC737F1-C7A5-4376-A066-2A32D752A2FF}
6 | cpp;c;cc;cxx;def;odl;idl;hpj;bat;asm;asmx
7 |
8 |
9 | {93995380-89BD-4b04-88EB-625FBE52EBFB}
10 | h;hpp;hxx;hm;inl;inc;xsd
11 |
12 |
13 | {67DA6AB6-F800-4c08-8B7A-83BB121AAD01}
14 | rc;ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe;resx;tiff;tif;png;wav;mfcribbon-ms
15 |
16 |
17 |
18 |
19 | Source Files
20 |
21 |
22 |
--------------------------------------------------------------------------------
/clear_vs.bat:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/lizhenghn123/CppLanguagePrograms/add5848861197a53feabba480e43fd8bb8f074fb/clear_vs.bat
--------------------------------------------------------------------------------
/include/OsDefine.h:
--------------------------------------------------------------------------------
1 | // ***********************************************************************
2 | // Filename : OsDefine.h
3 | // Author : LIZHENG
4 | // Created : 2014-07-01
5 | // Description : 平台定义
6 | //
7 | // Copyright (c) lizhenghn@gmail.com. All rights reserved.
8 | // ***********************************************************************
9 | #ifndef ZL_OSDEFINE_H
10 | #define ZL_OSDEFINE_H
11 |
12 | #if defined(WIN32) || defined(_WIN32) || defined(__WIN32__)
13 | # define OS_WINDOWS
14 | # define OS_X86
15 | #elif defined(WIN64) || defined(_WIN64) || defined(__WIN64__)
16 | # define OS_WINDOWS
17 | # define OS_X64
18 | #elif defined(__CYGWIN__) || defined(__CYGWIN32__)
19 | # define OS_CYGWIN
20 | #elif defined(linux) || defined(__linux) || defined(__linux__)
21 | # define OS_LINUX
22 | #if defined(__x86_64__)
23 | # define OS_X64
24 | #else
25 | # define OS_X86
26 | #endif
27 | #elif defined(macintosh) || defined(__APPLE__) || defined(__APPLE_CC__)
28 | # define OS_MACOSX
29 | #elif defined(__FreeBSD__)
30 | # define OS_FREEBSD
31 | #elif defined(__NetBSD__)
32 | # define OS_NETBSD
33 | #elif defined(__OpenBSD__)
34 | # define OS_OPENBSD
35 | #else
36 | #error "You Must Be Choose One Platform"
37 | #endif
38 |
39 | #endif /* ZL_OSDEFINE_H */
40 |
--------------------------------------------------------------------------------
/include/base/ByteArray.cpp:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/lizhenghn123/CppLanguagePrograms/add5848861197a53feabba480e43fd8bb8f074fb/include/base/ByteArray.cpp
--------------------------------------------------------------------------------
/include/base/ByteArray.h:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/lizhenghn123/CppLanguagePrograms/add5848861197a53feabba480e43fd8bb8f074fb/include/base/ByteArray.h
--------------------------------------------------------------------------------
/include/base/Daemonize.h:
--------------------------------------------------------------------------------
1 | // ***********************************************************************
2 | // Filename : Daemonize.h
3 | // Author : LIZHENG
4 | // Created : 2015-01-05
5 | // Description :
6 | //
7 | // Copyright (c) lizhenghn@gmail.com. All rights reserved.
8 | // ***********************************************************************
9 | #ifndef ZL_DAEMONIZE_H
10 | #define ZL_DAEMONIZE_H
11 | namespace zl
12 | {
13 | namespace base
14 | {
15 | /// 创建守护进程(设置同台机器是否允许多个进程启动)
16 | /// nochdir : 为0改变当前进程工作目录,否则不改变
17 | /// noclose : 为0重定向输入输出到/dev/null,否则不会改变, nochdir, noclose 参数意义同 man 3 daemon 参数
18 | /// pidfile : 为NULL时允许多个进程启动,否则禁止系统重复启动进程
19 | /// 成功返回当前进程pid,失败返回-1
20 | int createDaemonize(int nochdir = 1, int noclose = 0, const char *pidfile = 0);
21 |
22 | int exitDaemonize(const char *pidfile);
23 |
24 | }
25 | }
26 | #endif /* ZL_DAEMONIZE_H */
27 |
--------------------------------------------------------------------------------
/include/base/DateTimeUtil.cpp:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/lizhenghn123/CppLanguagePrograms/add5848861197a53feabba480e43fd8bb8f074fb/include/base/DateTimeUtil.cpp
--------------------------------------------------------------------------------
/include/base/Demangle.h:
--------------------------------------------------------------------------------
1 | // ***********************************************************************
2 | // Filename : Demangle.h
3 | // Author : LIZHENG
4 | // Created : 2014-11-05
5 | // Description :
6 | //
7 | // Copyright (c) lizhenghn@gmail.com. All rights reserved.
8 | // ***********************************************************************
9 | #ifndef ZL_DEMANGLE_H
10 | #define ZL_DEMANGLE_H
11 | #include "Define.h"
12 | NAMESPACE_ZL_BASE_START
13 |
14 | // 根据重整后的名字解析出原函数原型名字
15 | // 如果则返回true, 并将解析后的名字保存在unmangled
16 | // Demangle "mangled". On success, return true and write the
17 | // demangled symbol name to "unmangled". Otherwise, return false.
18 | // "unmangled" is modified even if demangling is unsuccessful.
19 | bool demangleName(const char *mangled, char *unmangled, size_t buf_size);
20 |
21 | bool demangleName(const char *mangled, std::string& unmangled);
22 |
23 | NAMESPACE_ZL_BASE_END
24 | #endif /* ZL_DEMANGLE_H */
25 |
--------------------------------------------------------------------------------
/include/base/Exception.h:
--------------------------------------------------------------------------------
1 | // ***********************************************************************
2 | // Filename : Exception.h
3 | // Author : LIZHENG
4 | // Created : 2014-11-05
5 | // Description :
6 | //
7 | // Copyright (c) lizhenghn@gmail.com. All rights reserved.
8 | // ***********************************************************************
9 | #ifndef ZL_EXCEPTION_H
10 | #define ZL_EXCEPTION_H
11 | #include "Define.h"
12 | #include
13 | NAMESPACE_ZL_BASE_START
14 |
15 | class Exception : public std::exception
16 | {
17 | public:
18 | explicit Exception(const char *errinfo);
19 | Exception(const char *filename, int linenumber, const char *errinfo);
20 | Exception(const char *filename, int linenumber, const std::string& errinfo);
21 | virtual ~Exception() throw();
22 |
23 | virtual const char *what() const throw()
24 | {
25 | return errmsg_.c_str();
26 | }
27 |
28 | const char* stackTrace() const throw()
29 | {
30 | return callStack_.c_str();
31 | }
32 |
33 | const char* filename() const throw()
34 | {
35 | return filename_.c_str();
36 | }
37 |
38 | int line() const throw()
39 | {
40 | return line_;
41 | }
42 | private:
43 | void trace_stack();
44 |
45 | int line_;
46 | std::string filename_;
47 | std::string errmsg_;
48 | std::string callStack_;
49 | };
50 |
51 | NAMESPACE_ZL_BASE_END
52 | #endif /* */
53 |
--------------------------------------------------------------------------------
/include/base/FileUtil.h:
--------------------------------------------------------------------------------
1 | // ***********************************************************************
2 | // Filename : FileUtil.h
3 | // Author : LIZHENG
4 | // Created : 2014-07-01
5 | // Description : 文件、目录相关工具函数
6 | //
7 | // Copyright (c) lizhenghn@gmail.com. All rights reserved.
8 | // ***********************************************************************
9 | #ifndef ZL_FILEUTIL_H
10 | #define ZL_FILEUTIL_H
11 | #include "Define.h"
12 | #include
13 | NAMESPACE_ZL_START
14 |
15 | namespace FileUtil
16 | {
17 | string getBinaryPath();
18 | string getBinaryName();
19 | string getBinaryDir();
20 |
21 | bool isDirectory(const char *dir);
22 | bool createRecursionDir(const char *dir);
23 |
24 | bool isFileExist(const char *filepath);
25 | long getFileSize(FILE *file);
26 | long getFileSize(const char *filepath);
27 | size_t readFile(const char *filepath, std::string& buf);
28 | };
29 |
30 | using namespace FileUtil;
31 |
32 | NAMESPACE_ZL_END
33 | #endif /* ZL_FILEUTIL_H */
34 |
--------------------------------------------------------------------------------
/include/base/GBKtoUTF8.cpp:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/lizhenghn123/CppLanguagePrograms/add5848861197a53feabba480e43fd8bb8f074fb/include/base/GBKtoUTF8.cpp
--------------------------------------------------------------------------------
/include/base/GBKtoUTF8.h:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/lizhenghn123/CppLanguagePrograms/add5848861197a53feabba480e43fd8bb8f074fb/include/base/GBKtoUTF8.h
--------------------------------------------------------------------------------
/include/base/IntrusiveList.h:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/lizhenghn123/CppLanguagePrograms/add5848861197a53feabba480e43fd8bb8f074fb/include/base/IntrusiveList.h
--------------------------------------------------------------------------------
/include/base/Makefile.am:
--------------------------------------------------------------------------------
1 | MAINTAINERCLEANFILES = Makefile.in
2 |
3 | SUBDIRS =
4 |
5 | SUBDIRS += tests
6 |
--------------------------------------------------------------------------------
/include/base/MathUtil.h:
--------------------------------------------------------------------------------
1 | // ***********************************************************************
2 | // Filename : MathUtil.h
3 | // Author : LIZHENG
4 | // Created : 2014-11-02
5 | // Description :
6 | //
7 | // Copyright (c) lizhenghn@gmail.com. All rights reserved.
8 | // ***********************************************************************
9 | #ifndef ZL_STOPWTACH_H
10 | #define ZL_STOPWTACH_H
11 | #include "Define.h"
12 | NAMESPACE_ZL_BASE_START
13 |
14 | /// 判断一个整数是否是2的幂次方
15 | inline bool is_pow2(uint32_t num)
16 | {
17 | return !(num & (num - 1));
18 | }
19 |
20 | /// 返回一个整数,其值不小于参数num,且为2的幂次方
21 | inline uint32_t num_of_pow2(uint32_t num)
22 | {
23 | if(is_pow2(num))
24 | return num;
25 | num = num-1;
26 | num = num | (num>>1);
27 | num = num | (num>>2);
28 | num = num | (num>>4);
29 | num = num | (num>>8);
30 | num = num | (num>>16);
31 | return num + 1;
32 | }
33 |
34 | /// 返回一个不小于参数num的整数的关于2的幂次
35 | inline uint8_t get_pow2(uint32_t num)
36 | {
37 | uint8_t pow2 = 0;
38 | if(!is_pow2(num))
39 | num = (num << 1);
40 | while(num > 1)
41 | {
42 | pow2++;
43 | num = num >> 1;
44 | }
45 | return pow2;
46 | }
47 |
48 | NAMESPACE_ZL_BASE_END
49 |
--------------------------------------------------------------------------------
/include/base/NonCopy.h:
--------------------------------------------------------------------------------
1 | // ***********************************************************************
2 | // Filename : NonCopy.h
3 | // Author : LIZHENG
4 | // Created : 2014-05-16
5 | // Description : 禁止拷贝构造、赋值构造,建议private继承
6 | //
7 | // Copyright (c) lizhenghn@gmail.com. All rights reserved.
8 | // ***********************************************************************
9 | #ifndef ZL_NONCOPY_H
10 | #define ZL_NONCOPY_H
11 |
12 | namespace zl
13 | {
14 | namespace base
15 | {
16 | class NonCopy
17 | {
18 | protected:
19 | NonCopy() {}
20 | ~NonCopy() {}
21 | private:
22 | NonCopy(const NonCopy&);
23 | const NonCopy& operator=(const NonCopy&);
24 | };
25 | }
26 |
27 | using base::NonCopy;
28 | }
29 |
30 | #endif /* ZL_NONCOPY_H */
31 |
--------------------------------------------------------------------------------
/include/base/ProcessTimeCounter.h:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/lizhenghn123/CppLanguagePrograms/add5848861197a53feabba480e43fd8bb8f074fb/include/base/ProcessTimeCounter.h
--------------------------------------------------------------------------------
/include/base/histogram.h:
--------------------------------------------------------------------------------
1 | // Copyright (c) 2011 The LevelDB Authors. All rights reserved.
2 | // Use of this source code is governed by a BSD-style license that can be
3 | // found in the LICENSE file. See the AUTHORS file for names of contributors.
4 |
5 | #ifndef STORAGE_LEVELDB_UTIL_HISTOGRAM_H_
6 | #define STORAGE_LEVELDB_UTIL_HISTOGRAM_H_
7 | #include
8 |
9 | namespace zl
10 | {
11 | namespace base
12 | {
13 |
14 | class Histogram
15 | {
16 | public:
17 | Histogram() { clear(); }
18 | ~Histogram() { }
19 |
20 | void clear();
21 | void add(double value);
22 | void merge(const Histogram& other);
23 |
24 | std::string toString() const;
25 |
26 | private:
27 | double median() const;
28 | double percentile(double p) const;
29 | double average() const;
30 | double standardDeviation() const;
31 |
32 | private:
33 | double min_;
34 | double max_;
35 | double num_;
36 | double sum_;
37 | double sum_squares_;
38 |
39 | enum { kNumBuckets = 154 };
40 | static const double kBucketLimit[kNumBuckets];
41 | double buckets_[kNumBuckets];
42 | };
43 |
44 | }
45 | }
46 |
47 | #endif // STORAGE_LEVELDB_UTIL_HISTOGRAM_H_
48 |
--------------------------------------------------------------------------------
/include/base/tests/Makefile.am:
--------------------------------------------------------------------------------
1 | #CXXFLAGS += -Wall -static -g -O2 -fPIC
2 |
3 | bin_PROGRAMS = Logger_test SmartAssert_test StringUtil_test Daemon_test Demangle_test ProcessUtil_test Timestamp_test ScopeExitGuard_test \
4 | StlUtil_test AsyncLogger_test Exception_test MasterWorkerProcess_test
5 |
6 | INCLUDES = -I../../../zlreactor
7 | CPPFLAGS = -std=c++0x -O2
8 | LDFLAGS = -O2 -L../../../lib -lzlreactor -lrt
9 |
10 | Logger_test_SOURCES = Logger_test.cpp
11 |
12 | AsyncLogger_test_SOURCES = AsyncLogger_test.cpp
13 |
14 | SmartAssert_test_SOURCES = SmartAssert_test.cpp
15 |
16 | StringUtil_test_SOURCES = StringUtil_test.cpp
17 |
18 | Daemon_test_SOURCES = Daemon_test.cpp
19 |
20 | Demangle_test_SOURCES = Demangle_test.cpp
21 |
22 | Exception_test_LDFLAGS = -rdynamic
23 | Exception_test_SOURCES = Exception_test.cpp
24 |
25 | ProcessUtil_test_CPPFLAGS = $(CPPFLAGS)
26 | ProcessUtil_test_LDFLAGS = $(CPPFLAGS)
27 | ProcessUtil_test_SOURCES = ProcessUtil_test.cpp
28 |
29 | MasterWorkerProcess_test_SOURCES = MasterWorkerProcess_test.cpp
30 |
31 | Timestamp_test_LDFLAGS = $(CPPFLAGS) -lrt
32 | Timestamp_test_SOURCES = Timestamp_test.cpp
33 |
34 | ScopeExitGuard_test_LDFLAGS = $(CPPFLAGS) -std=c++1y
35 | ScopeExitGuard_test_SOURCES = ScopeExitGuard_test.cpp
36 |
37 | StlUtil_test_SOURCES = StlUtil_test.cpp
38 |
--------------------------------------------------------------------------------
/include/base/tests/MasterWorkerProcess_test.cpp:
--------------------------------------------------------------------------------
1 | #include
2 | #include
3 | #include
4 | #include "base/MasterWorkerProcess.h"
5 | using namespace zl;
6 |
7 | class Test
8 | {
9 | public:
10 | Test() : num_(0) {}
11 |
12 | int num_;
13 | };
14 |
15 | //#define TEST_SUB_PROCESS_EXIT
16 |
17 | void child_process_work(zl::MasterWorkerProcess* main_process, int jobid, void* arg)
18 | {
19 | assert(main_process->pid() == MasterWorkerProcess::mainProcessPid());
20 | assert(MasterWorkerProcess::mainProcessPid() != ::getpid());
21 |
22 | while (!main_process->shutdown())
23 | {
24 | printf("[%d][%d][%d]=======[%d]======\n", main_process->pid(), MasterWorkerProcess::mainProcessPid(), ::getpid(), main_process->shutdown());
25 | printf("child process[%d], jobid[%d], just sleep 6s\n", ::getpid(), jobid);
26 | ::sleep(6);
27 | #if defined(TEST_SUB_PROCESS_EXIT)
28 | break;
29 | #endif
30 | }
31 | printf("child process[%d] [%d]: exit the work\n", ::getpid(), main_process->shutdown());
32 | }
33 |
34 | int main(int argc, char *argv[])
35 | {
36 | if (argc != 2)
37 | {
38 | printf("error, should run as : bin child_num, ex : %s 3\n", argv[0]);
39 | return 0;
40 | }
41 |
42 | printf("main process[%d] starting...\n", ::getpid());
43 |
44 | zl::MasterWorkerProcess process;
45 | process.createWorkProcess(atoi(argv[1]), child_process_work, NULL);
46 |
47 | return 0;
48 | }
49 |
--------------------------------------------------------------------------------
/include/base/tests/Process_test.cpp:
--------------------------------------------------------------------------------
1 | #include
2 | #include
3 | #include
4 | #include "base/Process.h"
5 | using namespace zl;
6 |
7 | class Test
8 | {
9 | public:
10 | Test() : num_(0) {}
11 |
12 | int num_;
13 | };
14 |
15 | //#define TEST_SUB_PROCESS_EXIT
16 |
17 | void child_process_work(zl::Process* main_process, int jobid, void* arg)
18 | {
19 | assert(main_process->pid() == Process::mainProcessPid());
20 | assert(Process::mainProcessPid() != ::getpid());
21 |
22 | while (!main_process->shutdown())
23 | {
24 | printf("[%d][%d][%d]=======[%d]======\n", main_process->pid(), Process::mainProcessPid(), ::getpid(), main_process->shutdown());
25 | printf("child process[%d], jobid[%d], just sleep 6s\n", ::getpid(), jobid);
26 | ::sleep(6);
27 | #if defined(TEST_SUB_PROCESS_EXIT)
28 | break;
29 | #endif
30 | }
31 | printf("child process[%d] [%d]: exit the work\n", ::getpid(), main_process->shutdown());
32 | }
33 |
34 | int main(int argc, char *argv[])
35 | {
36 | if (argc != 2)
37 | {
38 | printf("error, should run as : bin child_num, ex : %s 3\n", argv[0]);
39 | return 0;
40 | }
41 |
42 | printf("main process[%d] starting...\n", ::getpid());
43 |
44 | zl::Process process;
45 | process.createWorkProcess(atoi(argv[1]), child_process_work, NULL);
46 |
47 | return 0;
48 | }
49 |
--------------------------------------------------------------------------------
/include/base/tests/SmartAssert_test.cpp:
--------------------------------------------------------------------------------
1 | #include
2 | #include
3 | #include
4 | #include "base/SmartAssert.h"
5 | using namespace std;
6 | //using namespace zl::base;
7 |
8 | ZL_STATIC_ASSERT(SIGINT == 2, "SIGINT == 2 must be true");
9 |
10 | int main()
11 | {
12 | // cout << MACRO_CAT(__FILE__, __LINE__) << "\n";
13 | // cout << MACRO_CAT(__FILE__, "ee") << "\n";
14 | {
15 | const static int i = 2;
16 | ZL_STATIC_ASSERT(i>0);
17 | ZL_STATIC_ASSERT(i>0, "i must greater than 0");
18 | //ZL_STATIC_ASSERT(i>3);
19 | //ZL_STATIC_ASSERT(i>3, "must i>3");
20 | }
21 | {
22 | int i = 2;
23 |
24 | std::vector vec;
25 | vec.push_back(5);
26 | ZL_ASSERT_LOG(vec.size() >= i)(i)(vec.size());
27 | printf("---------------------------------\n");
28 | ZL_ASSERT_LOG(vec.size() >= i)(i)(vec.size());
29 | printf("---------------------------------\n");
30 |
31 | ZL_ASSERT(i != 2);
32 | printf("---------------------------------\n");
33 | ZL_ASSERTEX(i != 2, "sdfs", 342, "zxcvbnm");
34 | printf("---------------------------------\n");
35 | //ZL_STATIC_ASSERT(sizeof(i)>=8);
36 | ZL_ASSERT(i ==2 )(i);
37 | ZL_ASSERT(i != 2)(i);
38 | printf("---------------------------------\n");
39 |
40 | }
41 |
42 | system("pause");
43 | return 0;
44 | }
45 |
--------------------------------------------------------------------------------
/include/meta/meta_util.hpp:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/lizhenghn123/CppLanguagePrograms/add5848861197a53feabba480e43fd8bb8f074fb/include/meta/meta_util.hpp
--------------------------------------------------------------------------------
/include/net/ActiveSocket.cpp:
--------------------------------------------------------------------------------
1 | #include "net/ActiveSocket.h"
2 | NAMESPACE_ZL_NET_START
3 |
4 | ActiveSocket::ActiveSocket(ZL_SOCKET fd) : Socket(fd)
5 | {
6 |
7 | }
8 |
9 | ActiveSocket::ActiveSocket(const char *host, int port) : Socket(SocketUtil::createSocket())
10 | {
11 | if(!Socket::connect(host, port))
12 | {
13 | throw SocketException("Could not Connect to server.");
14 | }
15 | }
16 |
17 | ActiveSocket::~ActiveSocket()
18 | {
19 | }
20 |
21 | const ActiveSocket& ActiveSocket::operator << (const std::string& data) const
22 | {
23 | if(!Socket::send(data))
24 | {
25 | throw SocketException("Could not write to socket.");
26 | }
27 |
28 | return *this;
29 | }
30 |
31 | const ActiveSocket& ActiveSocket::operator >> (std::string& data) const
32 | {
33 | if(!Socket::recv(data))
34 | {
35 | throw SocketException("Could not read from socket.");
36 | //printf("Could not read from socket.");
37 | }
38 |
39 | return *this;
40 | }
41 |
42 | NAMESPACE_ZL_NET_END
43 |
--------------------------------------------------------------------------------
/include/net/ActiveSocket.h:
--------------------------------------------------------------------------------
1 | // ***********************************************************************
2 | // Filename : ActiveSocket.h
3 | // Author : LIZHENG
4 | // Created : 2014-07-04
5 | // Description : 用于主动发起连接请求的socket类,比如client向server的连接
6 | //
7 | // Last Modified By : LIZHENG
8 | // Last Modified On : 2014-07-04
9 | //
10 | // Copyright (c) lizhenghn@gmail.com. All rights reserved.
11 | // ***********************************************************************
12 | #ifndef ZL_ACTIVESOCKET_H
13 | #define ZL_ACTIVESOCKET_H
14 | #include "net/Socket.h"
15 |
16 | NAMESPACE_ZL_NET_START
17 |
18 | class ActiveSocket : public Socket
19 | {
20 | public:
21 | explicit ActiveSocket(ZL_SOCKET fd);
22 | ActiveSocket(const char *host, int port);
23 | ~ActiveSocket();
24 |
25 | public:
26 | const ActiveSocket& operator << (const std::string&) const;
27 | const ActiveSocket& operator >> (std::string&) const;
28 | };
29 |
30 | NAMESPACE_ZL_NET_END
31 |
32 | #endif /* ZL_ACTIVESOCKET_H */
33 |
--------------------------------------------------------------------------------
/include/net/ByteBuffer.cpp:
--------------------------------------------------------------------------------
1 | #include "net/ByteBuffer.h"
2 | NAMESPACE_ZL_NET_START
3 |
4 | const char ByteBuffer::kCRLF[] = "\r\n";
5 |
6 | //const size_t ByteBuffer::kCheapPrepend;
7 | //const size_t ByteBuffer::kInitialSize;
8 |
9 | NAMESPACE_ZL_NET_END
--------------------------------------------------------------------------------
/include/net/Eventfd.h:
--------------------------------------------------------------------------------
1 | // ***********************************************************************
2 | // Filename : Eventfd.h
3 | // Author : LIZHENG
4 | // Created : 2015-01-14
5 | // Description : 进程及线程间的事件通知,need linux kernel > 2.6.22
6 | //
7 | // Copyright (c) lizhenghn@gmail.com. All rights reserved.
8 | // ***********************************************************************
9 | #ifndef ZL_EVENTFD_H
10 | #define ZL_EVENTFD_H
11 | #include "Define.h"
12 | #include
13 | #include
14 | NAMESPACE_ZL_NET_START
15 |
16 | // eventfd的缓冲区大小是sizeof(uint64_t), 也即是8字节.
17 | // 它是一个64位计数器, 计数器不为零是有可读事件发生.
18 | // 写入一次增加计数器值,读取将获取计数器值,并清零.
19 |
20 | class EventfdHandler
21 | {
22 | public:
23 | EventfdHandler(unsigned int initval = 0, int flags = EFD_NONBLOCK | EFD_CLOEXEC);
24 | ~EventfdHandler();
25 |
26 | public:
27 | int fd() { return eventfd_; }
28 |
29 | void notify() { write(1); }
30 |
31 | ssize_t write(uint64_t value = 1);
32 |
33 | ssize_t read(uint64_t *value = NULL);
34 |
35 | private:
36 | /// iff success, return eventfd_, else return -1;
37 | int createEventfd(unsigned int initval, int flags);
38 |
39 | private:
40 | int eventfd_;
41 | };
42 |
43 | NAMESPACE_ZL_NET_END
44 | #endif /* ZL_EVENTFD_H */
45 |
--------------------------------------------------------------------------------
/include/net/Makefile.am:
--------------------------------------------------------------------------------
1 | MAINTAINERCLEANFILES = Makefile.in
2 |
3 | SUBDIRS =
4 |
5 | SUBDIRS += tests
6 |
--------------------------------------------------------------------------------
/include/net/PassiveSocket.cpp:
--------------------------------------------------------------------------------
1 | #include "net/PassiveSocket.h"
2 |
3 | NAMESPACE_ZL_NET_START
4 |
5 | PassiveSocket::PassiveSocket(ZL_SOCKET fd) : Socket(fd)
6 | {
7 |
8 | }
9 |
10 | PassiveSocket::PassiveSocket(const char *ip, int port) : Socket(SocketUtil::createSocket())
11 | {
12 | if(!Socket::bind(ip, port))
13 | {
14 | throw SocketException("Could not bind to port.");
15 | }
16 | if(!Socket::listen(5))
17 | {
18 | throw SocketException("Could not listen to port.");
19 | }
20 | }
21 |
22 | PassiveSocket::~PassiveSocket()
23 | {
24 | }
25 |
26 | const PassiveSocket& PassiveSocket::operator << (const std::string& data) const
27 | {
28 | if(!Socket::send(data))
29 | {
30 | throw SocketException("Could not write to socket.");
31 | }
32 |
33 | return *this;
34 | }
35 |
36 | const PassiveSocket& PassiveSocket::operator >> (std::string& data) const
37 | {
38 | if(!Socket::recv(data))
39 | {
40 | throw SocketException("Could not read from socket.");
41 | }
42 |
43 | return *this;
44 | }
45 |
46 | NAMESPACE_ZL_NET_END
47 |
--------------------------------------------------------------------------------
/include/net/PassiveSocket.h:
--------------------------------------------------------------------------------
1 | // ***********************************************************************
2 | // Filename : PassiveSocket.h
3 | // Author : LIZHENG
4 | // Created : 2014-07-04
5 | // Description : 用于被动接受连接请求的socket类,比如server接收client的连接
6 | //
7 | // Last Modified By : LIZHENG
8 | // Last Modified On : 2014-07-04
9 | //
10 | // Copyright (c) lizhenghn@gmail.com. All rights reserved.
11 | // ***********************************************************************
12 | #ifndef ZL_PASSIVESOCKET_H
13 | #define ZL_PASSIVESOCKET_H
14 | #include "net/Socket.h"
15 |
16 | NAMESPACE_ZL_NET_START
17 |
18 | class PassiveSocket : public Socket
19 | {
20 | public:
21 | explicit PassiveSocket(ZL_SOCKET fd);
22 | PassiveSocket(const char *ip, int port);
23 | ~PassiveSocket();
24 |
25 | public:
26 | const PassiveSocket& operator << (const std::string&) const;
27 | const PassiveSocket& operator >> (std::string&) const;
28 | };
29 |
30 | NAMESPACE_ZL_NET_END
31 |
32 | #endif /* ZL_PASSIVESOCKET_H */
33 |
--------------------------------------------------------------------------------
/include/net/SignalHandler.h:
--------------------------------------------------------------------------------
1 | // ***********************************************************************
2 | // Filename : SignalHandler.h
3 | // Author : LIZHENG
4 | // Created : 2015-01-07
5 | // Description : signalfd need linux kernel > 2.6.25
6 | //
7 | // Last Modified By : LIZHENG
8 | // Last Modified On : 2015-01-07
9 | //
10 | // Copyright (c) lizhenghn@gmail.com. All rights reserved.
11 | // ***********************************************************************
12 | #ifndef ZL_SIGNALHANDLER_H
13 | #define ZL_SIGNALHANDLER_H
14 | #include "Define.h"
15 | #include "net/CallBacks.h"
16 | #include
17 | #include
18 | NAMESPACE_ZL_NET_START
19 |
20 | class Channel;
21 | class EventLoop;
22 |
23 | class SignalHandler
24 | {
25 | public:
26 | explicit SignalHandler(EventLoop *loop);
27 | ~SignalHandler();
28 |
29 | public:
30 | void setSigHandler(int sig, const SignalCallback& handler);
31 | int registerAll();
32 | void removeSig(int sig);
33 | bool haveSignal(int sig);
34 |
35 | private:
36 | void sigOnRead();
37 |
38 | private:
39 | typedef std::unordered_map SigHandlerMap;
40 |
41 | EventLoop *loop_;
42 | int signalFd_;
43 | Channel *sigFdChannel_;
44 | SigHandlerMap sigHanhlers_;
45 | };
46 |
47 | NAMESPACE_ZL_NET_END
48 | #endif /* ZL_SIGNALHANDLER_H */
49 |
--------------------------------------------------------------------------------
/include/net/TcpAcceptor.h:
--------------------------------------------------------------------------------
1 | // ***********************************************************************
2 | // Filename : TcpAcceptor.h
3 | // Author : LIZHENG
4 | // Created : 2014-10-26
5 | // Description : 服务端接受器,监听在某一端口上,接受远程Socket连接
6 | //
7 | // Copyright (c) lizhenghn@gmail.com. All rights reserved.
8 | // ***********************************************************************
9 | #ifndef ZL_TCPACCEPTOR_H
10 | #define ZL_TCPACCEPTOR_H
11 | #include "Define.h"
12 | #include "base/Timestamp.h"
13 | #include "base/NonCopy.h"
14 | NAMESPACE_ZL_NET_START
15 | class Socket;
16 | class InetAddress;
17 | class Channel;
18 | class EventLoop;
19 | using zl::base::Timestamp;
20 |
21 | class TcpAcceptor : zl::NonCopy
22 | {
23 | public:
24 | //typedef std::function NewConnectionCallback;
25 | typedef std::function NewConnectionCallback;
26 | public:
27 | TcpAcceptor(EventLoop *loop, const InetAddress& listenAddr);
28 | ~TcpAcceptor();
29 |
30 | void setNewConnectionCallback(const NewConnectionCallback& callback)
31 | {
32 | newConnCallBack_ = callback;
33 | }
34 |
35 | void listen();
36 |
37 | private:
38 | void onAccept(Timestamp now);
39 |
40 | private:
41 | EventLoop *loop_;
42 | Socket *accept_socket;
43 | Channel *accept_channel_;
44 | NewConnectionCallback newConnCallBack_;
45 | };
46 |
47 | NAMESPACE_ZL_NET_END
48 | #endif /* ZL_TCPACCEPTOR_H */
49 |
--------------------------------------------------------------------------------
/include/net/Timer.cpp:
--------------------------------------------------------------------------------
1 | #include "net/Timer.h"
2 |
3 | NAMESPACE_ZL_NET_START
4 |
5 |
6 | NAMESPACE_ZL_NET_END
--------------------------------------------------------------------------------
/include/net/Timerfd.h:
--------------------------------------------------------------------------------
1 | // ***********************************************************************
2 | // Filename : Timerfd.h
3 | // Author : LIZHENG
4 | // Created : 2014-11-23
5 | // Description : timerfd need linux kernel > 2.6.25
6 | // Linux下基于基于文件描述符的定时器接口,通过fd的可读事件进行超时通知,能够用于select/poll
7 | //
8 | // Copyright (c) lizhenghn@gmail.com. All rights reserved.
9 | // ***********************************************************************
10 | #ifndef ZL_TIMERFD_H
11 | #define ZL_TIMERFD_H
12 | #include "Define.h"
13 | #include "base/Timestamp.h"
14 | #include
15 | using zl::base::Timestamp;
16 | NAMESPACE_ZL_NET_START
17 |
18 | typedef int Timerfd;
19 |
20 | class TimerfdHandler
21 | {
22 | public:
23 | TimerfdHandler(int clockid = CLOCK_MONOTONIC, int flags = TFD_NONBLOCK | TFD_CLOEXEC);
24 | ~TimerfdHandler();
25 |
26 | public:
27 | /// 返回定时器描述符
28 | Timerfd fd() { return timerfd_; }
29 |
30 | /// 设置新的超时时间(绝对时间)以及定时器循环间隔(<=0 表示只定时一次), 单位:微秒
31 | void resetTimerfd(Timestamp expiration, int interval_us = 0);
32 |
33 | /// 设置新的超时时间(相对时间)以及定时器循环间隔(<=0 表示只定时一次), 单位:微秒
34 | void resetTimerfd(uint64_t next_expire_us, int interval_us = 0);
35 |
36 | /// 获得当前有多少个定时器超时
37 | uint64_t read(uint64_t *howmany);
38 |
39 | /// 停止定时器
40 | void stop();
41 |
42 | private:
43 | Timerfd timerfd_;
44 | };
45 |
46 | NAMESPACE_ZL_NET_END
47 | #endif /* ZL_TIMERFD_H */
48 |
--------------------------------------------------------------------------------
/include/net/http/HttpKeyValue.h:
--------------------------------------------------------------------------------
1 | // ***********************************************************************
2 | // Filename : HttpKeyValue.h
3 | // Author : LIZHENG
4 | // Created : 2014-07-02
5 | // Description :
6 | //
7 | // Copyright (c) lizhenghn@gmail.com. All rights reserved.
8 | // ***********************************************************************
9 | #ifndef ZL_HTTPKEYVALUE_H
10 | #define ZL_HTTPKEYVALUE_H
11 | #include "Define.h"
12 | #include "base/Singleton.h"
13 | #include "HttpProtocol.h"
14 | NAMESPACE_ZL_NET_START
15 |
16 | class HttpKeyValue : public zl::Singleton < HttpKeyValue >
17 | {
18 | DECLARE_SINGLETON_CLASS(HttpKeyValue);
19 |
20 | public:
21 | std::string getStatusDesc(HttpStatusCode code) const;
22 | std::string getContentType(const std::string& file_type) const;
23 | std::string getMethodStr(HttpMethod method) const;
24 |
25 | private:
26 | std::map code_desc_;
27 | std::map content_type_;
28 | std::map method_str_;
29 |
30 | private:
31 | HttpKeyValue();
32 | void initialise();
33 | };
34 |
35 | NAMESPACE_ZL_NET_END
36 | #endif /* ZL_HTTPKEYVALUE_H */
37 |
--------------------------------------------------------------------------------
/include/net/poller/EpollPoller.h:
--------------------------------------------------------------------------------
1 | // ***********************************************************************
2 | // Filename : EpollPoller.h
3 | // Author : LIZHENG
4 | // Created : 2014-09-26
5 | // Description : I/O MultiPlexing 的 epoll 实现
6 | //
7 | // Copyright (c) lizhenghn@gmail.com. All rights reserved.
8 | // ***********************************************************************
9 | #ifndef ZL_EPOLLPOLLER_H
10 | #define ZL_EPOLLPOLLER_H
11 | #include "net/poller/Poller.h"
12 | struct epoll_event;
13 | NAMESPACE_ZL_NET_START
14 |
15 | class EpollPoller : public Poller
16 | {
17 | public:
18 | explicit EpollPoller(EventLoop *loop, bool enableET = false);
19 |
20 | ~EpollPoller();
21 |
22 | public:
23 | virtual bool updateChannel(Channel *channel);
24 |
25 | virtual bool removeChannel(Channel *channel);
26 |
27 | virtual Timestamp poll_once(int timeoutMs, ChannelList& activeChannels);
28 |
29 | virtual const char* ioMultiplexerName() const { return "linux_epoll"; }
30 |
31 | private:
32 | bool update(Channel *channel, int operation);
33 |
34 | void fireActiveChannels(int numEvents, ChannelList& activeChannels) const;
35 |
36 | private:
37 | typedef std::vector EpollEventList;
38 |
39 | int epollfd_;
40 | bool enableET_;
41 | EpollEventList events_;
42 | };
43 |
44 | NAMESPACE_ZL_NET_END
45 | #endif /* ZL_EPOLLPOLLER_H */
46 |
--------------------------------------------------------------------------------
/include/net/poller/Poller.cpp:
--------------------------------------------------------------------------------
1 | #include "net/poller/Poller.h"
2 | #include "net/Channel.h"
3 | #include "net/poller/EpollPoller.h"
4 | #include "net/poller/PollPoller.h"
5 | #include "net/poller/SelectPoller.h"
6 | NAMESPACE_ZL_NET_START
7 |
8 | Poller::Poller(EventLoop *loop) : loop_(loop)
9 | {
10 | }
11 |
12 | Poller::~Poller()
13 | {
14 | }
15 |
16 | bool Poller::hasChannel(const Channel* channel) const
17 | {
18 | ChannelMap::const_iterator itr = channelMap_.find(channel->fd());
19 | return itr != channelMap_.end() && itr->second == channel;
20 | }
21 |
22 | Channel* Poller::getChannel(ZL_SOCKET sock) const
23 | {
24 | ChannelMap::const_iterator itr = channelMap_.find(sock);
25 | if(itr == channelMap_.end())
26 | return NULL;
27 | return itr->second;
28 | }
29 |
30 | /*static*/ Poller* Poller::createPoller(EventLoop *loop)
31 | {
32 | #if defined(USE_POLLER_EPOLL)
33 | return new EpollPoller(loop);
34 | #elif defined(USE_POLLER_SELECT)
35 | return new SelectPoller(loop);
36 | #elif defined(USE_POLLER_POLL)
37 | return new PollPoller(loop);
38 | #else
39 | return NULL;
40 | #endif
41 | }
42 |
43 | NAMESPACE_ZL_NET_END
--------------------------------------------------------------------------------
/include/net/tests/Makefile.am:
--------------------------------------------------------------------------------
1 | #CXXFLAGS += -Wall -static -g -O2 -fPIC
2 |
3 | bin_PROGRAMS = Timer_test NetBuffer_test DomainResolver_test HttpRequestParser_test Socket_test\
4 | Eventfd_test Timerfd_test Signalfd_test \
5 | TcpAcceptor_test TcpClient_test EventLoop_test EventLoopThreadPool_test InetAddress_test
6 |
7 | INCLUDES = -I../../../zlreactor
8 | CPPFLAGS = -std=c++0x
9 | LDFLAGS = -L../../../lib -lzlreactor
10 |
11 | Timer_test_CPPFLAGS = $(CPPFLAGS)
12 | Timer_test_LDFLAGS = $(CPPFLAGS)
13 | Timer_test_SOURCES = Timer_test.cpp
14 |
15 | NetBuffer_test_SOURCES = NetBuffer_test.cpp
16 |
17 | DomainResolver_test_SOURCES = DomainResolver_test.cpp
18 |
19 | HttpRequestParser_test_SOURCES = HttpRequestParser_test.cpp
20 |
21 | Socket_test_SOURCES = Socket_test.cpp
22 |
23 | InetAddress_test_SOURCES = InetAddress_test.cpp
24 |
25 | Eventfd_test_SOURCES = Eventfd_test.cpp
26 | Timerfd_test_SOURCES = Timerfd_test.cpp
27 | Signalfd_test_SOURCES = Signalfd_test.cpp
28 |
29 | TcpAcceptor_test_SOURCES = TcpAcceptor_test.cpp
30 |
31 | TcpClient_test_SOURCES = TcpClient_test.cpp
32 |
33 | EventLoop_test_SOURCES = EventLoop_test.cpp
34 |
35 | EventLoopThreadPool_test_SOURCES = EventLoopThreadPool_test.cpp
36 |
--------------------------------------------------------------------------------
/include/net/tests/TcpAcceptor_test.cpp:
--------------------------------------------------------------------------------
1 | /*************************************************************************
2 | File Name : TcpAcceptor_test.cpp
3 | Author : LIZHENG
4 | Mail : lizhenghn@gmail.com
5 | Created Time: 2015年05月25日 星期一 20时45分36秒
6 | ************************************************************************/
7 | #include
8 | #include
9 | #include "net/TcpAcceptor.h"
10 | #include "net/InetAddress.h"
11 | #include "net/EventLoop.h"
12 | using namespace std;
13 | using namespace zl;
14 | using namespace zl::net;
15 |
16 | void accept_callback(int fd, const InetAddress& addr)
17 | {
18 | cout << "get " << fd << ", and close it.\n";
19 | ::close(fd);
20 | }
21 |
22 | void test_tcpacceptor()
23 | {
24 | EventLoop loop;
25 | InetAddress serverAddr(8888);
26 | TcpAcceptor acceptor(&loop, serverAddr);
27 | acceptor.setNewConnectionCallback(accept_callback);
28 | acceptor.listen();
29 |
30 | loop.loop();
31 | }
32 |
33 | int main()
34 | {
35 | test_tcpacceptor();
36 | }
37 |
--------------------------------------------------------------------------------
/include/smart_ptr/smart_ptr.h:
--------------------------------------------------------------------------------
1 | // ***********************************************************************
2 | // Filename : smart_ptr.h
3 | // Author : LIZHENG
4 | // Created : 2014-10-10
5 | // Description :
6 | // Last Modified By : LIZHENG
7 | // Last Modified On : 2014-10-10
8 | //
9 | // Copyright (c) lizhenghn@gmail.com. All rights reserved.
10 | // ***********************************************************************
11 | #ifndef ZL_SMART_PTR_H
12 | #define ZL_SMART_PTR_H
13 |
14 | #include "smart_ptr/unique_ptr.h"
15 | #include "smart_ptr/shared_ptr.h"
16 | #include "smart_ptr/weak_ptr.h"
17 | #include "smart_ptr/enable_shared_from_this.h"
18 |
19 | namespace zl
20 | {
21 | template >
22 | class scoped_ptr;
23 |
24 | template
25 | class shared_ptr;
26 |
27 | template
28 | class weak_ptr;
29 |
30 | template
31 | class enable_shared_from_this;
32 | }
33 |
34 | #endif /* ZL_SMART_PTR_H */
--------------------------------------------------------------------------------
/include/stl/any.h:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/lizhenghn123/CppLanguagePrograms/add5848861197a53feabba480e43fd8bb8f074fb/include/stl/any.h
--------------------------------------------------------------------------------
/include/stl/range.h:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/lizhenghn123/CppLanguagePrograms/add5848861197a53feabba480e43fd8bb8f074fb/include/stl/range.h
--------------------------------------------------------------------------------
/include/stl/tests/array_test.cpp:
--------------------------------------------------------------------------------
1 | #include
2 | #include
3 | #include "stl/array.h"
4 | using namespace zl::stl;
5 |
6 | int main()
7 | {
8 | zl::stl::array a, b;
9 | b.fill(1);
10 |
11 | b.back() += 1;
12 | b.front() -= 20;
13 |
14 | for (size_t i = 0; i < b.size(); ++i)
15 | {
16 | std::cout << ((i % 2 == 0) ? b[i] : b.at(i)) << ", ";
17 | }
18 | std::cout << "\n";
19 |
20 | a == b;
21 | a != b;
22 | a < b;
23 | a <= b;
24 | a > b;
25 | a >= b;
26 |
27 | //zl::stl::array az; // 'az' uses undefined class 'zl::stl::array'
28 |
29 | system("pause");
30 | return 0;
31 | }
32 |
--------------------------------------------------------------------------------
/include/stl/tests/iterator_test.cpp:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/lizhenghn123/CppLanguagePrograms/add5848861197a53feabba480e43fd8bb8f074fb/include/stl/tests/iterator_test.cpp
--------------------------------------------------------------------------------
/include/stl/tests/range_test.cpp:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/lizhenghn123/CppLanguagePrograms/add5848861197a53feabba480e43fd8bb8f074fb/include/stl/tests/range_test.cpp
--------------------------------------------------------------------------------
/include/thread/Makefile.am:
--------------------------------------------------------------------------------
1 | MAINTAINERCLEANFILES = Makefile.in
2 |
3 | SUBDIRS =
4 |
5 | SUBDIRS += tests
6 |
--------------------------------------------------------------------------------
/include/thread/ThreadGroup.h:
--------------------------------------------------------------------------------
1 | // ***********************************************************************
2 | // Filename : ThreadGroup.h
3 | // Author : LIZHENG
4 | // Created : 2014-10-13
5 | // Description :
6 | //
7 | // Copyright (c) lizhenghn@gmail.com. All rights reserved.
8 | // ***********************************************************************
9 | #ifndef ZL_THREADGROU_H
10 | #define ZL_THREADGROU_H
11 | #include "Define.h"
12 | #include "base/NonCopy.h"
13 | #include "thread/Thread.h"
14 | #include "thread/Mutex.h"
15 | NAMESPACE_ZL_THREAD_START
16 | class Thread;
17 |
18 | class ThreadGroup : zl::NonCopy
19 | {
20 | public:
21 | ThreadGroup();
22 | ~ThreadGroup();
23 |
24 | public:
25 | template
26 | Thread* create_thread(F threadfunc, const std::string& thrd_name="")
27 | {
28 | Thread *trd = new Thread(threadfunc, thrd_name);
29 | add_thread(trd);
30 | return trd;
31 | }
32 |
33 | void add_thread(Thread *thd);
34 | void remove_thread(Thread *thd);
35 | void join_all();
36 | size_t size() const;
37 |
38 | private:
39 | bool is_this_thread_in();
40 | bool is_thread_in(Thread* thrd);
41 |
42 | private:
43 | mutable Mutex mutex_;
44 | std::vector threads_;
45 | };
46 |
47 | NAMESPACE_ZL_THREAD_END
48 | #endif /* ZL_THREADGROU_H */
49 |
--------------------------------------------------------------------------------
/include/thread/ThreadPool.h:
--------------------------------------------------------------------------------
1 | // ***********************************************************************
2 | // Filename : ThreadPool.h
3 | // Author : LIZHENG
4 | // Created : 2014-10-06
5 | // Description :
6 | //
7 | // Copyright (c) lizhenghn@gmail.com. All rights reserved.
8 | // ***********************************************************************
9 | #ifndef ZL_THREADPOOL_H
10 | #define ZL_THREADPOOL_H
11 | #include "Define.h"
12 | #include "base/NonCopy.h"
13 | #include "thread/BlockingQueue.h"
14 | NAMESPACE_ZL_THREAD_START
15 |
16 | class Thread;
17 |
18 | class ThreadPool : zl::NonCopy
19 | {
20 | public:
21 | typedef std::function Task;
22 |
23 | public:
24 | explicit ThreadPool(const std::string& name = "ThreadPool");
25 | ~ThreadPool();
26 |
27 | public:
28 | void start(int numThreads);
29 | void stop();
30 | void run(const Task& f);
31 | size_t size() const { return queue_.size(); }
32 |
33 | private:
34 | void executeThread();
35 |
36 | private:
37 | std::string name_;
38 | bool running_;
39 | BlockingQueue queue_;
40 | std::vector threads_;
41 | };
42 |
43 | NAMESPACE_ZL_THREAD_END
44 | #endif /* ZL_THREADPOOL_H */
45 |
--------------------------------------------------------------------------------
/include/thread/tests/Makefile.am:
--------------------------------------------------------------------------------
1 | #CXXFLAGS += -Wall -static -g -O2 -fPIC
2 |
3 | bin_PROGRAMS = Atomic_test BlockingQueue_test CountDownLatch_test Thread_test ThreadLocal_test Mutex_test ThreadGroup_test BlockingQueueWorker_test ThreadId_test
4 |
5 | INCLUDES = -I../../../zlreactor
6 | CPPFLAGS = -std=c++0x
7 | LDFLAGS = -L../../../lib -lzlreactor
8 |
9 | #Atomic_test_CPPFLAGS = $(CPPFLAGS)
10 | #Atomic_test_LDFLAGS = $(CPPFLAGS)
11 | Atomic_test_SOURCES = Atomic_test.cpp
12 |
13 | Mutex_test_CPPFLAGS = $(CPPFLAGS) -O2
14 | Mutex_test_SOURCES = Mutex_test.cpp
15 |
16 | BlockingQueue_test_SOURCES = BlockingQueue_test.cpp
17 |
18 | CountDownLatch_test_SOURCES = CountDownLatch_test.cpp
19 |
20 | #Thread_test_CPPFLAGS = $(CPPFLAGS)
21 | #Thread_test_LDFLAGS = $(CPPFLAGS)
22 | Thread_test_SOURCES = Thread_test.cpp
23 |
24 | ThreadiId_test_SOURCES = ThreadId_test.cpp
25 |
26 | ThreadLocal_test_SOURCES = ThreadLocal_test.cpp
27 |
28 | ThreadGroup_test_SOURCES = ThreadGroup_test.cpp
29 |
30 | BlockingQueueWorker_test_SOURCES = BlockingQueueWorker_test.cpp
31 |
--------------------------------------------------------------------------------
/include/utility/Base64.cpp:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/lizhenghn123/CppLanguagePrograms/add5848861197a53feabba480e43fd8bb8f074fb/include/utility/Base64.cpp
--------------------------------------------------------------------------------
/include/utility/Base64.h:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/lizhenghn123/CppLanguagePrograms/add5848861197a53feabba480e43fd8bb8f074fb/include/utility/Base64.h
--------------------------------------------------------------------------------
/include/utility/CRC32.h:
--------------------------------------------------------------------------------
1 | #include
2 | #include
3 |
4 | class CRC32
5 | {
6 | public:
7 | CRC32();
8 | ~CRC32();
9 |
10 | static uint32_t Digest(const std::string& src);
11 | static std::string HexDigest(const std::string& src);
12 |
13 | public:
14 | void reInit();
15 | void Update(const std::string& src);
16 | uint32_t Final() const;
17 | // Finalizes the CRC operation and fills the buffer with the digest.
18 | // Data is uint32_t_t
19 | void Final(void* digest) const;
20 | // Hex encoding for result
21 | std::string HexFinal() const;
22 |
23 | private:
24 | uint32_t result_;
25 | };
--------------------------------------------------------------------------------
/include/utility/Hex2String.h:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/lizhenghn123/CppLanguagePrograms/add5848861197a53feabba480e43fd8bb8f074fb/include/utility/Hex2String.h
--------------------------------------------------------------------------------
/include/utility/StringHash.h:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/lizhenghn123/CppLanguagePrograms/add5848861197a53feabba480e43fd8bb8f074fb/include/utility/StringHash.h
--------------------------------------------------------------------------------
/include/utility/UUID.h:
--------------------------------------------------------------------------------
1 | #ifndef ZL_UUID_H
2 | #define ZL_UUID_H
3 | #include "Define.h"
4 | #ifdef OS_WINDOWS
5 | #include
6 | #else
7 | #include // need -luuid
8 | #endif
9 |
10 | NAMESPACE_ZL_UTIL_START
11 |
12 | std::string createUuid()
13 | {
14 | char buf[64] = {0};
15 | #ifdef OS_WINDOWS
16 | GUID guid;
17 | if (CoCreateGuid(&guid) == S_OK){
18 | ZL_SNPRINTF(buf, sizeof(buf),
19 | "%08X-%04X-%04X-%02X%02X-%02X%02X%02X%02X%02X%02X",
20 | guid.Data1, guid.Data2, guid.Data3,
21 | guid.Data4[0], guid.Data4[1],
22 | guid.Data4[2], guid.Data4[3],
23 | guid.Data4[4], guid.Data4[5],
24 | guid.Data4[6], guid.Data4[7]);
25 | }
26 | #else
27 | uuid_t uu;
28 | uuid_generate(uu);
29 | if (!uuid_is_null(uu)) {
30 | ZL_SNPRINTF(buf, sizeof(buf),
31 | "%02X%02X%02X%02X-%02X%02X-%02X%02X-%02X%02X-%02X%02X%02X%02X%02X%02X",
32 | uu[0], uu[1], uu[2], uu[3], uu[4], uu[5], uu[6], uu[7],
33 | uu[8], uu[9], uu[10], uu[11], uu[12], uu[13], uu[14], uu[15]);
34 | }
35 | #endif
36 |
37 | return buf;
38 | }
39 |
40 | NAMESPACE_ZL_UTIL_END
41 | #endif /* ZL_UUID_H */
--------------------------------------------------------------------------------
/include/utility/WildCard.cpp:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/lizhenghn123/CppLanguagePrograms/add5848861197a53feabba480e43fd8bb8f074fb/include/utility/WildCard.cpp
--------------------------------------------------------------------------------
/include/utility/WildCard.h:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/lizhenghn123/CppLanguagePrograms/add5848861197a53feabba480e43fd8bb8f074fb/include/utility/WildCard.h
--------------------------------------------------------------------------------
/include/utility/aes.h:
--------------------------------------------------------------------------------
1 | /*********************************************************************************
2 |
3 | Copyright 2006-2009 MakingThings
4 |
5 | Licensed under the Apache License,
6 | Version 2.0 (the "License"); you may not use this file except in compliance
7 | with the License. You may obtain a copy of the License at
8 |
9 | http://www.apache.org/licenses/LICENSE-2.0
10 |
11 | Unless required by applicable law or agreed to in writing, software distributed
12 | under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR
13 | CONDITIONS OF ANY KIND, either express or implied. See the License for
14 | the specific language governing permissions and limitations under the License.
15 |
16 | *********************************************************************************/
17 |
18 | #ifndef AES_H
19 | #define AES_H
20 |
21 | #ifdef __cplusplus
22 | extern "C" {
23 | #endif
24 | int aesEncrypt(unsigned char* output, int outlen, unsigned char* input, int inlen, unsigned char* key);
25 | int aesDecrypt(unsigned char* output, int outlen, unsigned char* input, int inlen, unsigned char* password);
26 | #ifdef __cplusplus
27 | }
28 | #endif
29 | #endif // AES_H
30 |
--------------------------------------------------------------------------------
/include/utility/jenkins_hash.h:
--------------------------------------------------------------------------------
1 | #ifndef JENKINS_HASH_H
2 | #define JENKINS_HASH_H
3 |
4 | #ifdef __cplusplus
5 | extern "C" {
6 | #endif
7 |
8 | uint32_t jenkins_hash(const void *key, size_t length);
9 |
10 | #ifdef __cplusplus
11 | }
12 | #endif
13 |
14 | #endif /* JENKINS_HASH_H */
15 |
16 |
--------------------------------------------------------------------------------
/include/utility/murmur3_hash.h:
--------------------------------------------------------------------------------
1 | //-----------------------------------------------------------------------------
2 | // MurmurHash3 was written by Austin Appleby, and is placed in the public
3 | // domain. The author hereby disclaims copyright to this source code.
4 |
5 | #ifndef MURMURHASH3_H
6 | #define MURMURHASH3_H
7 |
8 | //-----------------------------------------------------------------------------
9 | // Platform-specific functions and macros
10 | #include
11 | #include
12 |
13 | //-----------------------------------------------------------------------------
14 |
15 | uint32_t MurmurHash3_x86_32(const void *key, size_t length);
16 |
17 | //-----------------------------------------------------------------------------
18 |
19 | #endif // MURMURHASH3_H
20 |
--------------------------------------------------------------------------------
/test_3rdparty/Google_FlatBuffers_Test/Google_FlatBuffers_Test.vcxproj.GhostDoc.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 | .\Help
13 |
14 |
15 | true
16 | false
17 | false
18 | false
19 |
20 |
21 | true
22 | false
23 | false
24 | false
25 | true
26 | false
27 |
28 |
29 | true
30 |
31 |
32 |
33 |
34 |
35 |
36 |
--------------------------------------------------------------------------------
/test_3rdparty/Google_FlatBuffers_Test/Google_FlatBuffers_Test.vcxproj.filters:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 | {4FC737F1-C7A5-4376-A066-2A32D752A2FF}
6 | cpp;c;cc;cxx;def;odl;idl;hpj;bat;asm;asmx
7 |
8 |
9 | {93995380-89BD-4b04-88EB-625FBE52EBFB}
10 | h;hpp;hxx;hm;inl;inc;xsd
11 |
12 |
13 | {67DA6AB6-F800-4c08-8B7A-83BB121AAD01}
14 | rc;ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe;resx;tiff;tif;png;wav;mfcribbon-ms
15 |
16 |
17 |
18 |
19 | Source Files
20 |
21 |
22 |
23 |
24 | Header Files
25 |
26 |
27 | Header Files
28 |
29 |
30 |
--------------------------------------------------------------------------------
/test_3rdparty/Google_FlatBuffers_Test/gfb/flatc.exe:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/lizhenghn123/CppLanguagePrograms/add5848861197a53feabba480e43fd8bb8f074fb/test_3rdparty/Google_FlatBuffers_Test/gfb/flatc.exe
--------------------------------------------------------------------------------
/test_3rdparty/Google_FlatBuffers_Test/gfb/person_infos.fbs:
--------------------------------------------------------------------------------
1 | namespace zl.persons;
2 |
3 | enum GENDER_TYPE : byte
4 | {
5 | MALE = 0,
6 | FEMALE = 1,
7 | OTHER = 2
8 | }
9 |
10 | table personal_info
11 | {
12 | id : uint;
13 | name : string;
14 | age : byte;
15 | gender : GENDER_TYPE;
16 | phone_num : ulong;
17 | }
18 |
19 | table personal_info_list
20 | {
21 | info : [personal_info];
22 | }
23 |
24 | root_type personal_info_list;
--------------------------------------------------------------------------------
/test_3rdparty/Google_FlatBuffers_Test/gfb/readme.txt:
--------------------------------------------------------------------------------
1 | 用法:
2 | http://google.github.io/flatbuffers/md__cpp_usage.html
3 | http://google.github.io/flatbuffers/md__compiler.html
4 |
5 | 示例:
6 | flatc.exe -c person_infos.fbs //生成person_infos_generated.h文件
7 |
8 | 说明:
9 | 以person_infos.fbs为例
10 | namespace zl.persons;
11 |
12 | enum GENDER_TYPE : byte
13 | {
14 | MALE = 0,
15 | FEMALE = 1,
16 | OTHER = 2
17 | }
18 |
19 | table personal_info
20 | {
21 | id : uint;
22 | name : string;
23 | age : byte;
24 | gender : GENDER_TYPE;
25 | phone_num : ulong;
26 | }
27 |
28 | table personal_info_list
29 | {
30 | info : [personal_info];
31 | }
32 |
33 | root_type personal_info_list;
34 |
35 | 生成的person_infos_generated.h中命名空间即是zl::persons;
36 | 分别生成了枚举类GENDER_TYPE、结构体personal_info、结构体personal_info_list;另外还生成了结构体personal_infoBuilder和personal_info_listBuilder;
37 | 还有一些相关的全局函数。
38 |
39 | 注意上面的personal_info和personal_info_list是以table开头的,因为可以支持string类型,而struct不支持。
--------------------------------------------------------------------------------
/test_3rdparty/Google_FlatBuffers_Test/gfb/t.fbs:
--------------------------------------------------------------------------------
1 | namespace zl.persons;
2 |
3 | table Score
4 | {
5 | scores:[float];
6 | }
7 | table StuScore
8 | {
9 | ids:[int];
10 | }
11 |
12 | root_type StuScore;
--------------------------------------------------------------------------------
/test_3rdparty/Google_FlatBuffers_Test/main.cpp:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/lizhenghn123/CppLanguagePrograms/add5848861197a53feabba480e43fd8bb8f074fb/test_3rdparty/Google_FlatBuffers_Test/main.cpp
--------------------------------------------------------------------------------
/test_3rdparty/test_easylogging++/test_easylogging++.vcxproj.filters:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 | {4FC737F1-C7A5-4376-A066-2A32D752A2FF}
6 | cpp;c;cc;cxx;def;odl;idl;hpj;bat;asm;asmx
7 |
8 |
9 | {93995380-89BD-4b04-88EB-625FBE52EBFB}
10 | h;hpp;hxx;hm;inl;inc;xsd
11 |
12 |
13 | {67DA6AB6-F800-4c08-8B7A-83BB121AAD01}
14 | rc;ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe;resx;tiff;tif;png;wav;mfcribbon-ms
15 |
16 |
17 |
18 |
19 | Source Files
20 |
21 |
22 |
--------------------------------------------------------------------------------
/test_3rdparty/test_gtest/test_gtest.cpp:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/lizhenghn123/CppLanguagePrograms/add5848861197a53feabba480e43fd8bb8f074fb/test_3rdparty/test_gtest/test_gtest.cpp
--------------------------------------------------------------------------------
/test_3rdparty/test_gtest/test_gtest.vcxproj.filters:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 | {4FC737F1-C7A5-4376-A066-2A32D752A2FF}
6 | cpp;c;cc;cxx;def;odl;idl;hpj;bat;asm;asmx
7 |
8 |
9 | {93995380-89BD-4b04-88EB-625FBE52EBFB}
10 | h;hpp;hxx;hm;inl;inc;xsd
11 |
12 |
13 | {67DA6AB6-F800-4c08-8B7A-83BB121AAD01}
14 | rc;ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe;resx;tiff;tif;png;wav;mfcribbon-ms
15 |
16 |
17 |
18 |
19 | Source Files
20 |
21 |
22 |
--------------------------------------------------------------------------------
/test_net/InetAddressTest/InetAddressTest.cpp:
--------------------------------------------------------------------------------
1 | #include
2 | #include
3 | #include "net/SocketUtil.h"
4 | #include "net/InetAddress.h"
5 | using namespace std;
6 | using namespace zl;
7 | using namespace zl::net;
8 |
9 | int main()
10 | {
11 | {
12 | InetAddress addr0(80);
13 | assert(addr0.ip() == std::string("0.0.0.0"));
14 | assert(addr0.port() == 80);
15 |
16 | InetAddress addr1("192.22.12.78", 5000);
17 | assert(addr1.ip() == std::string("192.22.12.78"));
18 | assert(addr1.port() == 5000);
19 |
20 | InetAddress addr2("255.254.253.252", 65535);
21 | assert(addr2.ip() == std::string("255.254.253.252"));
22 | assert(addr2.port() == 65535);
23 | }
24 | {
25 | InetAddress addr0(80);
26 | bool res = InetAddress::resolve("www.baidu.com", &addr0);
27 | cout << addr0.ip()<< "\t" << addr0.port() << "\n";
28 | }
29 | system("pause");
30 | return 0;
31 | }
--------------------------------------------------------------------------------
/test_net/InetAddressTest/InetAddressTest.vcxproj.filters:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
15 |
16 |
17 |
18 |
19 |
20 |
--------------------------------------------------------------------------------
/test_net/NetUtilTest/NetUtilTest.cpp:
--------------------------------------------------------------------------------
1 | #include
2 | #include "net/NetUtil.h"
3 | using namespace std;
4 |
5 | int main()
6 | {
7 | printf("is little endian: %d\n", zl::net::NetUtil::isLittleEndian());
8 | printf("is valid ipaddress: %d\n", zl::net::NetUtil::isValidIpv4("1.2.3.4"));
9 | printf("is valid ipaddress: %d\n", zl::net::NetUtil::isValidIpv4("1x.2.3.4"));
10 | printf("is valid ipaddress: %d\n", zl::net::NetUtil::isValidIpv4("11711.2.3.4"));
11 | printf("is valid ipaddress: %d\n", zl::net::NetUtil::isValidIpv4("11.2.3.4345"));
12 | return 0;
13 | }
14 |
--------------------------------------------------------------------------------
/test_net/NetUtilTest/NetUtilTest.vcxproj.filters:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
--------------------------------------------------------------------------------
/test_net/Test_Timer/Timer.cpp:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/lizhenghn123/CppLanguagePrograms/add5848861197a53feabba480e43fd8bb8f074fb/test_net/Test_Timer/Timer.cpp
--------------------------------------------------------------------------------
/test_net/Test_Timer/TimerQueue.cpp:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/lizhenghn123/CppLanguagePrograms/add5848861197a53feabba480e43fd8bb8f074fb/test_net/Test_Timer/TimerQueue.cpp
--------------------------------------------------------------------------------
/test_net/Test_Timer/TimerQueue.h:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/lizhenghn123/CppLanguagePrograms/add5848861197a53feabba480e43fd8bb8f074fb/test_net/Test_Timer/TimerQueue.h
--------------------------------------------------------------------------------
/test_some/do-while(0)/do-while(0).cpp:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/lizhenghn123/CppLanguagePrograms/add5848861197a53feabba480e43fd8bb8f074fb/test_some/do-while(0)/do-while(0).cpp
--------------------------------------------------------------------------------
/test_some/do-while(0)/do-while(0).vcxproj.filters:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 | {4FC737F1-C7A5-4376-A066-2A32D752A2FF}
6 | cpp;c;cc;cxx;def;odl;idl;hpj;bat;asm;asmx
7 |
8 |
9 | {93995380-89BD-4b04-88EB-625FBE52EBFB}
10 | h;hpp;hxx;hm;inl;inc;xsd
11 |
12 |
13 | {67DA6AB6-F800-4c08-8B7A-83BB121AAD01}
14 | rc;ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe;resx;tiff;tif;png;wav;mfcribbon-ms
15 |
16 |
17 |
18 |
19 | Source Files
20 |
21 |
22 |
--------------------------------------------------------------------------------
/test_some/strlen_sizeof/strlen_sizeof.cpp:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/lizhenghn123/CppLanguagePrograms/add5848861197a53feabba480e43fd8bb8f074fb/test_some/strlen_sizeof/strlen_sizeof.cpp
--------------------------------------------------------------------------------
/test_some/strlen_sizeof/strlen_sizeof.vcxproj.filters:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 | {4FC737F1-C7A5-4376-A066-2A32D752A2FF}
6 | cpp;c;cc;cxx;def;odl;idl;hpj;bat;asm;asmx
7 |
8 |
9 | {93995380-89BD-4b04-88EB-625FBE52EBFB}
10 | h;hpp;hxx;hm;inl;inc;xsd
11 |
12 |
13 | {67DA6AB6-F800-4c08-8B7A-83BB121AAD01}
14 | rc;ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe;resx;tiff;tif;png;wav;mfcribbon-ms
15 |
16 |
17 |
18 |
19 | Source Files
20 |
21 |
22 |
--------------------------------------------------------------------------------
/test_some/time/test_time.cpp:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/lizhenghn123/CppLanguagePrograms/add5848861197a53feabba480e43fd8bb8f074fb/test_some/time/test_time.cpp
--------------------------------------------------------------------------------
/test_some/time/time.vcxproj.filters:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 | {4FC737F1-C7A5-4376-A066-2A32D752A2FF}
6 | cpp;c;cc;cxx;def;odl;idl;hpj;bat;asm;asmx
7 |
8 |
9 | {93995380-89BD-4b04-88EB-625FBE52EBFB}
10 | h;hpp;hxx;hm;inl;inc;xsd
11 |
12 |
13 | {67DA6AB6-F800-4c08-8B7A-83BB121AAD01}
14 | rc;ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe;resx;tiff;tif;png;wav;mfcribbon-ms
15 |
16 |
17 |
18 |
19 | Source Files
20 |
21 |
22 |
--------------------------------------------------------------------------------
/test_some/函数对象Demo/函数对象Demo.cpp:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/lizhenghn123/CppLanguagePrograms/add5848861197a53feabba480e43fd8bb8f074fb/test_some/函数对象Demo/函数对象Demo.cpp
--------------------------------------------------------------------------------
/test_some/函数对象Demo/函数对象Demo.vcxproj.filters:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 | {4FC737F1-C7A5-4376-A066-2A32D752A2FF}
6 | cpp;c;cc;cxx;def;odl;idl;hpj;bat;asm;asmx
7 |
8 |
9 | {93995380-89BD-4b04-88EB-625FBE52EBFB}
10 | h;hpp;hxx;hm;inl;inc;xsd
11 |
12 |
13 | {67DA6AB6-F800-4c08-8B7A-83BB121AAD01}
14 | rc;ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe;resx;tiff;tif;png;wav;mfcribbon-ms
15 |
16 |
17 |
18 |
19 | Source Files
20 |
21 |
22 |
--------------------------------------------------------------------------------
/test_some/名字重整(NameMangling)/c++_name_mangling.cpp:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/lizhenghn123/CppLanguagePrograms/add5848861197a53feabba480e43fd8bb8f074fb/test_some/名字重整(NameMangling)/c++_name_mangling.cpp
--------------------------------------------------------------------------------
/test_some/名字重整(NameMangling)/名字重整(NameMangling).vcxproj.filters:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 | {4FC737F1-C7A5-4376-A066-2A32D752A2FF}
6 | cpp;c;cc;cxx;def;odl;idl;hpj;bat;asm;asmx
7 |
8 |
9 | {93995380-89BD-4b04-88EB-625FBE52EBFB}
10 | h;hpp;hxx;hm;inl;inc;xsd
11 |
12 |
13 | {67DA6AB6-F800-4c08-8B7A-83BB121AAD01}
14 | rc;ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe;resx;tiff;tif;png;wav;mfcribbon-ms
15 |
16 |
17 |
18 |
19 | Source Files
20 |
21 |
22 | Source Files
23 |
24 |
25 |
26 |
27 | Header Files
28 |
29 |
30 |
--------------------------------------------------------------------------------
/test_some/指针常量和常量指针/指针常量和常量指针.cpp:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/lizhenghn123/CppLanguagePrograms/add5848861197a53feabba480e43fd8bb8f074fb/test_some/指针常量和常量指针/指针常量和常量指针.cpp
--------------------------------------------------------------------------------
/test_some/指针常量和常量指针/指针常量和常量指针.vcxproj.filters:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 | {4FC737F1-C7A5-4376-A066-2A32D752A2FF}
6 | cpp;c;cc;cxx;def;odl;idl;hpj;bat;asm;asmx
7 |
8 |
9 | {93995380-89BD-4b04-88EB-625FBE52EBFB}
10 | h;hpp;hxx;hm;inl;inc;xsd
11 |
12 |
13 | {67DA6AB6-F800-4c08-8B7A-83BB121AAD01}
14 | rc;ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe;resx;tiff;tif;png;wav;mfcribbon-ms
15 |
16 |
17 |
18 |
19 | Source Files
20 |
21 |
22 |
--------------------------------------------------------------------------------
/test_some/静态多态和动态多态/static_dynamic_polymorphic.cpp:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/lizhenghn123/CppLanguagePrograms/add5848861197a53feabba480e43fd8bb8f074fb/test_some/静态多态和动态多态/static_dynamic_polymorphic.cpp
--------------------------------------------------------------------------------
/test_some/静态多态和动态多态/静态多态和动态多态.vcxproj.filters:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 | {4FC737F1-C7A5-4376-A066-2A32D752A2FF}
6 | cpp;c;cc;cxx;def;odl;idl;hpj;bat;asm;asmx
7 |
8 |
9 | {93995380-89BD-4b04-88EB-625FBE52EBFB}
10 | h;hpp;hxx;hm;inl;inc;xsd
11 |
12 |
13 | {67DA6AB6-F800-4c08-8B7A-83BB121AAD01}
14 | rc;ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe;resx;tiff;tif;png;wav;mfcribbon-ms
15 |
16 |
17 |
18 |
19 | Source Files
20 |
21 |
22 |
--------------------------------------------------------------------------------
/test_some/静态绑定和动态绑定/static_dynamic_binding.cpp:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/lizhenghn123/CppLanguagePrograms/add5848861197a53feabba480e43fd8bb8f074fb/test_some/静态绑定和动态绑定/static_dynamic_binding.cpp
--------------------------------------------------------------------------------
/test_some/静态绑定和动态绑定/静态绑定和动态绑定.vcxproj.filters:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 | {4FC737F1-C7A5-4376-A066-2A32D752A2FF}
6 | cpp;c;cc;cxx;def;odl;idl;hpj;bat;asm;asmx
7 |
8 |
9 | {93995380-89BD-4b04-88EB-625FBE52EBFB}
10 | h;hpp;hxx;hm;inl;inc;xsd
11 |
12 |
13 | {67DA6AB6-F800-4c08-8B7A-83BB121AAD01}
14 | rc;ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe;resx;tiff;tif;png;wav;mfcribbon-ms
15 |
16 |
17 |
18 |
19 | Source Files
20 |
21 |
22 |
--------------------------------------------------------------------------------
/test_thread/Test_Atomic/Test_Atomic.vcxproj.filters:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
--------------------------------------------------------------------------------
/test_thread/Test_BlockingQueue/Test_BlockingQueue.vcxproj.filters:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
--------------------------------------------------------------------------------
/test_thread/Test_CountDownLatch/Test_CountDownLatch.cpp:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/lizhenghn123/CppLanguagePrograms/add5848861197a53feabba480e43fd8bb8f074fb/test_thread/Test_CountDownLatch/Test_CountDownLatch.cpp
--------------------------------------------------------------------------------
/test_thread/Test_CountDownLatch/Test_CountDownLatch.vcxproj.filters:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
15 |
16 |
17 |
--------------------------------------------------------------------------------
/test_thread/Test_Thread/TinyThread++-1.1-src.zip:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/lizhenghn123/CppLanguagePrograms/add5848861197a53feabba480e43fd8bb8f074fb/test_thread/Test_Thread/TinyThread++-1.1-src.zip
--------------------------------------------------------------------------------
/test_tmp-meta/test_tmp_meta/test_tmp_meta.cpp:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/lizhenghn123/CppLanguagePrograms/add5848861197a53feabba480e43fd8bb8f074fb/test_tmp-meta/test_tmp_meta/test_tmp_meta.cpp
--------------------------------------------------------------------------------
/test_tmp-meta/test_tmp_meta/test_tmp_meta.vcxproj.filters:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 | {4FC737F1-C7A5-4376-A066-2A32D752A2FF}
6 | cpp;c;cc;cxx;def;odl;idl;hpj;bat;asm;asmx
7 |
8 |
9 | {93995380-89BD-4b04-88EB-625FBE52EBFB}
10 | h;hpp;hxx;hm;inl;inc;xsd
11 |
12 |
13 | {67DA6AB6-F800-4c08-8B7A-83BB121AAD01}
14 | rc;ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe;resx;tiff;tif;png;wav;mfcribbon-ms
15 |
16 |
17 |
18 |
19 | Source Files
20 |
21 |
22 |
--------------------------------------------------------------------------------
/tools/Base64Encode/Base64Encode.vcxproj.filters:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
--------------------------------------------------------------------------------
/tools/Base64Encode/Test_Base64Encode.cpp:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/lizhenghn123/CppLanguagePrograms/add5848861197a53feabba480e43fd8bb8f074fb/tools/Base64Encode/Test_Base64Encode.cpp
--------------------------------------------------------------------------------
/tools/BitTwiddlingHacks/BitTwiddlingHacks.cpp:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/lizhenghn123/CppLanguagePrograms/add5848861197a53feabba480e43fd8bb8f074fb/tools/BitTwiddlingHacks/BitTwiddlingHacks.cpp
--------------------------------------------------------------------------------
/tools/BitTwiddlingHacks/BitTwiddlingHacks.vcxproj.filters:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
--------------------------------------------------------------------------------
/tools/Bitset/Bitset.vcxproj.filters:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
--------------------------------------------------------------------------------
/tools/Bitset/Bitset_test.cpp:
--------------------------------------------------------------------------------
1 | #include
2 | #include "base/Bitset.h"
3 | using namespace std;
4 | using namespace zl;
5 |
6 | template< typename T>
7 | void test_t()
8 | {
9 | T i = 0;
10 | Bitset p(i);
11 | p.set(9);
12 | cout << p << "\n";
13 | cout << p.test(9) << "\n";
14 | p.clr(9);
15 | cout << p << "\n";
16 | cout << p.test(9) << "\n";
17 | cout << p.test(10) << "\n";
18 |
19 | p.dump();
20 | p.set(9);
21 | p.set(10);
22 | p.dump();
23 | cout << p << "\n";
24 | p.clr(9);
25 | cout << p << "\n";
26 | }
27 |
28 | int main(int argc, char* argv[])
29 | {
30 | cout << "*****************\n";
31 | test_t();
32 |
33 | cout << "*****************\n";
34 | test_t();
35 |
36 | system("pause");
37 |
38 | return 0;
39 | }
--------------------------------------------------------------------------------
/tools/ByteArrayTest/ByteArrayTest.vcxproj.filters:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
--------------------------------------------------------------------------------
/tools/ByteBufferTest/ByteBufferTest.vcxproj.filters:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
--------------------------------------------------------------------------------
/tools/CStopWatch/CStopWatch.vcxproj.filters:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 | {4FC737F1-C7A5-4376-A066-2A32D752A2FF}
6 | cpp;c;cc;cxx;def;odl;idl;hpj;bat;asm;asmx
7 |
8 |
9 | {93995380-89BD-4b04-88EB-625FBE52EBFB}
10 | h;hpp;hxx;hm;inl;inc;xsd
11 |
12 |
13 | {67DA6AB6-F800-4c08-8B7A-83BB121AAD01}
14 | rc;ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe;resx;tiff;tif;png;wav;mfcribbon-ms
15 |
16 |
17 |
18 |
19 | Source Files
20 |
21 |
22 |
--------------------------------------------------------------------------------
/tools/CStopWatch/test_stopwatch.cpp:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/lizhenghn123/CppLanguagePrograms/add5848861197a53feabba480e43fd8bb8f074fb/tools/CStopWatch/test_stopwatch.cpp
--------------------------------------------------------------------------------
/tools/DateTimeTest/DateTimeTest.vcxproj.filters:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
--------------------------------------------------------------------------------
/tools/GBKtoUTF8/GBKtoUTF8.vcxproj.filters:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
--------------------------------------------------------------------------------
/tools/GBKtoUTF8/gbk.txt:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/lizhenghn123/CppLanguagePrograms/add5848861197a53feabba480e43fd8bb8f074fb/tools/GBKtoUTF8/gbk.txt
--------------------------------------------------------------------------------
/tools/GBKtoUTF8/main.cpp:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/lizhenghn123/CppLanguagePrograms/add5848861197a53feabba480e43fd8bb8f074fb/tools/GBKtoUTF8/main.cpp
--------------------------------------------------------------------------------
/tools/GBKtoUTF8/utf8.txt:
--------------------------------------------------------------------------------
1 | 谢谢
2 | 你好
3 | 中国.北京
--------------------------------------------------------------------------------
/tools/Histogram_test/Histogram_test.cpp:
--------------------------------------------------------------------------------
1 | #include
2 | #include "base/Histogram.h"
3 | using namespace std;
4 |
5 | int main()
6 | {
7 | {
8 | zl::base::Histogram hi;
9 | hi.add(2.4);
10 | hi.add(4.3);
11 | hi.add(5.3);
12 | hi.add(4.6);
13 | hi.add(4.9);
14 | cout << hi.toString() << "\n";
15 | }
16 | {
17 | zl::base::Histogram hi;
18 | hi.add(24);
19 | hi.add(43);
20 | hi.add(53);
21 | hi.add(46);
22 | hi.add(49);
23 | cout << hi.toString() << "\n";
24 | }
25 | system("pause");
26 | }
--------------------------------------------------------------------------------
/tools/Histogram_test/Histogram_test.vcxproj.filters:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
--------------------------------------------------------------------------------
/tools/HttpRestClient_Test/HttpRestClient.cpp:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/lizhenghn123/CppLanguagePrograms/add5848861197a53feabba480e43fd8bb8f074fb/tools/HttpRestClient_Test/HttpRestClient.cpp
--------------------------------------------------------------------------------
/tools/HttpRestClient_Test/HttpRestClient.h:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/lizhenghn123/CppLanguagePrograms/add5848861197a53feabba480e43fd8bb8f074fb/tools/HttpRestClient_Test/HttpRestClient.h
--------------------------------------------------------------------------------
/tools/HttpRestClient_Test/HttpRestClient_Test.cpp:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/lizhenghn123/CppLanguagePrograms/add5848861197a53feabba480e43fd8bb8f074fb/tools/HttpRestClient_Test/HttpRestClient_Test.cpp
--------------------------------------------------------------------------------
/tools/HttpRestClient_Test/HttpRestClient_Test.vcxproj.filters:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
--------------------------------------------------------------------------------
/tools/HttpRestClient_Test/curl_win32/lib/libcurl.dll:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/lizhenghn123/CppLanguagePrograms/add5848861197a53feabba480e43fd8bb8f074fb/tools/HttpRestClient_Test/curl_win32/lib/libcurl.dll
--------------------------------------------------------------------------------
/tools/HttpRestClient_Test/curl_win32/lib/libcurl.lib:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/lizhenghn123/CppLanguagePrograms/add5848861197a53feabba480e43fd8bb8f074fb/tools/HttpRestClient_Test/curl_win32/lib/libcurl.lib
--------------------------------------------------------------------------------
/tools/HttpRestClient_Test/curl_win32/lib/libcurld.dll:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/lizhenghn123/CppLanguagePrograms/add5848861197a53feabba480e43fd8bb8f074fb/tools/HttpRestClient_Test/curl_win32/lib/libcurld.dll
--------------------------------------------------------------------------------
/tools/HttpRestClient_Test/curl_win32/lib/libcurld_imp.lib:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/lizhenghn123/CppLanguagePrograms/add5848861197a53feabba480e43fd8bb8f074fb/tools/HttpRestClient_Test/curl_win32/lib/libcurld_imp.lib
--------------------------------------------------------------------------------
/tools/LruCacheTest/LruCache.vcxproj.filters:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
--------------------------------------------------------------------------------
/tools/ObjectPool/ObjectPool.vcxproj.filters:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
--------------------------------------------------------------------------------
/tools/Profiling/Profiler.cpp:
--------------------------------------------------------------------------------
1 | #include "Profiler.h"
2 |
3 | //Profiler g_profiler;
--------------------------------------------------------------------------------
/tools/Profiling/ProfilerTest.cpp:
--------------------------------------------------------------------------------
1 | #include
2 | #include
3 | #include