Noutați

Learn How To Use C++ Defaulted Functions For Windows Development With C++ Builder

A defaulted function is a function that contains =default; in its prototype. This construction indicates that the function’s default definition should be used. Defaulted functions are a C++11 specific feature. Defaulted functions example class A { A() = default; // OK A& operator = (A & a) = default; // OK void f() = default; // ill-formed, only special member function may be defaulted }; class A {         A() = default;                    // OK         A& operator = (A & a) = default;  // OK         void f() = default;               // ill-formed, only special member function may be defaulted }; By default, C++ provides four default special member functions. Users may override these defaults. destructor default constructor copy constructor copy assignment operator = Also by default, C++ applies several global operators to classes. Users may provide class-specific operators. sequence operator , address-of operator & indirection operator * member access operator -> member indirection operator ->* free-store allocation operator new free-store deallocation operator delete The management of defaults has several problems: Constructor definitions are coupled; declaring any constructor suppresses the default constructor. The destructor default is inappropriate to polymorphic classes, requiring an explicit definition. Once a default is suppressed, there is no means to resurrect it. Default implementations are often more efficient than manually specified implementations. Non-default implementations are non-trivial, which affects type semantics, e.g. makes a type non-POD. There is no means to prohibit a special member function or global operator without declaring a (non-trivial) substitute. The most common encounter with these problems is when disabling copying of a class. The accepted technique is to declare a private copy constructor and a private copy assignment operator, and then fail to define either. Head over and check out more information about defaulted functions on Windows in C++.

Read More

Low-Hanging Fruit: The Top 8 Cybersecurity Vulnerabilities in Enterprise Software

Published December 9, 2020 WRITTEN BY MICHAEL SOLOMON Michael G. Solomon, PhD, CISSP, PMP, CISM, PenTest+, is a security, privacy, blockchain, and data science author, consultant, educator and speaker who specializes in leading organizations toward achieving and maintaining compliant and secure IT environments. Cybersecurity is getting a lot of attention, from the break room to the board room. Few weeks pass without another salacious story in the media about a new large-scale data breach, ransomware outbreak or other attack designed to disrupt normal life.  Cybercriminals know what they are doing, and they’re able to succeed in their goals with uncomfortable regularity. Those goals are increasingly focused on enterprise applications due to the large number of access opportunities that are supposed to support end-users and internal personnel. For example, last year 62 US colleges were targets of cyberattacks that exploited their enterprise resource planning (ERP) system vulnerabilities. Cybercriminals constantly search for easy targets. Expanding complexity, growing numbers of users and partners, and rapidly emerging exploits make security an elusive target. Learning about the most common security gaps found in software, why those gaps really matter, and how to close them can make you less likely to be the next big victim. Instead of approaching security by being as secure as you can be, a better approach is to just be as secure as you need to be. That’s a subtle difference, but the outcome of the latter can be similar to the goal of the former, with much less effort and expense. Let’s cover some rudimentary aspects of security and a basic approach that balances security with budget and effort.  The lure of low-hanging fruit In this article I’m focusing on general cybercriminals who are looking for financial gain. They don’t care who their next victim is. Other types of cybercriminals, such as disgruntled (possibly former) personnel, “hacktivists,” or other people who are targeting your specific data or intellectual property are more determined and motivated to succeed. But here, we’re talking about cybercriminals looking for any victim, so they mainly want a quick and easy attack. Using the path of least resistance is a good thing. The easiest and cheapest path to the bottom line is most commonly the desirable path. Of course, there are reputational impacts and other obstacles that affect the decision-making process, but there is always some appeal to the path of least resistance. Cybercriminals spend a lot of effort identifying the easiest targets. What does this have to do with your security? One important key to being as secure as you need to be is simply avoiding being a hacker’s “low-hanging fruit.” Most cybercriminals use automated scanners to find potential victims they can attack without much work. They look for well-known vulnerabilities that their potential victims haven’t addressed. Cybercriminals know that keeping security controls current takes time and effort, and many organizations have “more important” tasks than hardening systems and networks. This gap between known vulnerabilities and implemented controls defines the sweet spot that cybercriminals are looking for. The best defense from most cybercriminals is to just be secure enough to not be worth their effort. This approach to cyber defense simply means that you should learn about the most common vulnerabilities and fix those first. If you have more budget to go further, that’s great. But at […]

Read More

Quickly Write Efficient Code With Modern Structured Bindings Available In C++17 On Windows With C++Builder

C++17 has a new feature that consolidates syntactic sugar and automatic type deduction: structured bindings. This helps to assign values from tuples, pairs, and structs into individual variables. In another programming language, you can find this as unpacking. Applying a structured binding to specify various variables from one bundled structure is one step. Structured bindings always applied with the same pattern: auto [var1, var2, …] = ; auto [var1, var2, …] = pair, tuple, struct, or array expression>; The list of variables var1, var2 – must exactly match the number of variables contained by the expression being assigned from Then there should be one of the following std::pair std::tuple struct or array The type can be auto, const auto, or even auto&& If you write too many or not enough variables between the square brackets, the compiler will give an error, telling us about our mistake std::tuple tup {3.55, 1, 99}; auto [a, b] = tup; // gives an error std::tuplefloat, int, long> tup {3.55, 1, 99}; auto [a, b] = tup; // gives an error Here is a complete real example of a use case for structured bindings: #ifdef _WIN32 #include #else typedef char _TCHAR; #define _tmain main #endif #include #include #include // Demonstrate structured bindings – here, a method might in the past // have had a bool success result, and an error param written to. // Now, can return both (all error info) as one tuple, bound automatically // to local vars through the auto keyword (much nicer than std::tie // in C++11/14) auto connect_to_network() { // The connection could succeed, or fail with an error message // Here, mimic it failing bool connected{ false }; // failed! std::string str_error{ “404: resource not found” }; return std::make_tuple(connected, str_error); } int _tmain(int argc, _TCHAR* argv[]) { auto [connected, str_error] = connect_to_network(); if (!connected) { std::cout 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 #ifdef _WIN32 #include #else typedef char _TCHAR; #define _tmain main #endif   #include #include #include   // Demonstrate structured bindings – here, a method might in the past // have had a bool success result, and an error param written to. // Now, can return both (all error info) as one tuple, bound automatically // to local vars through the auto keyword (much nicer than std::tie // in C++11/14)   auto connect_to_network() {   // The connection could succeed, or fail with an error message   // Here, mimic it failing   bool connected{ false }; // failed!     std::string str_error{ “404: resource not found” };     return std::make_tuple(connected, str_error); }   int _tmain(int argc, _TCHAR* argv[]) {   auto [connected, str_error] = connect_to_network();     if (!connected) {     std::cout str_error;   }     system(“pause”);     return 0; } As you can see, by using structured bindings, you can write more efficient and clean code. Be sure to check out the official documentation on structured bindings here! Check out the structured bindings demo for C++Builder on GitHub!

Read More

Flexible Multi-Tenancy REST Support Demo For RAD Server In Delphi

It requires InterBase to be installed on the machine or to connect to a remote server. Make sure that the server is running before you run the sample application. With Multi-Tenancy support, a single RAD Server instance with a single RAD Server database connection can support multiple isolated tenants. Each tenant has a unique set of RAD Server resources including Users, Groups, Installations, Edge Modules, and other data. All tenants have custom resources that are installed in the EMS Server. Also, as an administrator you can create new tenants, edit existing ones, add, edit, or delete details of your tenants, specify if the tenant is active, and delete the tenants that you do not need. Location You can find the RAD Server Overview Multi-tenant sample project at: Start | Programs | Embarcadero RAD Studio Sydney | Samples and then navigate to the following: Object PascalDataBaseEMSMulti-Tenancy Demo Subversion Repository: You can find Delphi code samples in GitHub Repositories. Search by name into the samples repositories according to your RAD Studio version. Overview This sample application demonstrates RAD Server’s Multi-Tenancy support. RAD Server Overview is a turn-key application foundation for rapidly building and deploying services based applications. RAD Server enables developers to quickly build new application back-ends or migrate existing Delphi or C++ client/server business logic to a modern services based architecture that is open, stateless, secure and scalable. A single RAD Server Overview instance with a single RAD Server database connection can support multiple isolated tenants. This demo uses a chain of toy stores to highlight RAD Server’s multi-tenancy support where each store with its employees and goods is a tenant implementation. Using the RAD Server Multi-Tenant Application The sample application demonstrates a retail store deployment use case. Each store with its employees and goods is a tenant implementation. Employees There are two groups of users with different rights: Managers can add new store items, delete them, and edit the details of the existing ones while cashiers can only view the information about the existing goods. Neither employee can see the information about the other stores in the chain.   Description Now, let us have a look at the sample application. Store Log in Page To access store specific information, enter the following information on the Store Log in page: Toy Store: select a store from the list. Each store is a tenant implementation. Store password: enter the password. Tip: You can find credentials in the Readme.txt file provided with the sample application. Employee Log in Page On the Employee Log in page, each employee enters the following: Employee login Employee password Tip: You can find credentials in the Readme.txt file provided with the sample application. Store Items Page After logging in, each employee sees the store items screen. The screen is displayed in two different modes: edit or view only, and access depends on the employee’s position. This uses EMS groups (a feature of RAD Server) to define access rights. Managers can view, add, and delete the store items and edit the details. Cashiers can view the items’ details only. Please follow the link to the original post for more information: http://docwiki.embarcadero.com/CodeExamples/Sydney/en/EMS.Sample_RAD_Server_Multi-Tenant_Application Check out the full source code for the Multi-Tenancy REST Demo over on GitHub.

Read More

Learn How To Use Python Functions With Keyword Arguments In A Delphi Windows App

rocedure TForm1.Button1Click(Sender: TObject); var   P : Variant; begin   PythonEngine1.ExecStrings( Memo1.Lines );   P := MainModule.Person(‘John’, ‘Doe’);   Assert(P.first_name = ‘John’);   Assert(P.last_name = ‘Doe’);   Assert(VarIsNone(P.weight));   Assert(VarIsNone(P.height));   Assert(VarIsNone(P.age));   P := MainModule.Person(‘John’, ‘Doe’, weight := 70);   Assert(P.first_name = ‘John’);   Assert(P.last_name = ‘Doe’);   Assert(P.weight = 70);   Assert(VarIsNone(P.height));   Assert(VarIsNone(P.age));   P := MainModule.Person(‘John’, ‘Doe’, weight := 70, height := 172);   Assert(P.first_name = ‘John’);   Assert(P.last_name = ‘Doe’);   Assert(P.weight = 70);   Assert(P.height = 172);   Assert(VarIsNone(P.age));   P := MainModule.Person(‘John’, ‘Doe’, weight := 70, height := 172, age := 35);   Assert(P.first_name = ‘John’);   Assert(P.last_name = ‘Doe’);   Assert(P.weight = 70);   Assert(P.height = 172);   Assert(P.age = 35);   P := MainModule.Person(last_name := ‘Doe’, first_name := ‘John’, weight := 70, height := 172, age := 35);   Assert(P.first_name = ‘John’);   Assert(P.last_name = ‘Doe’);   Assert(P.weight = 70);   Assert(P.height = 172);   Assert(P.age = 35);   P := MainModule.Person(‘John’, ‘Doe’, 35, 172, 70);   Assert(P.first_name = ‘John’);   Assert(P.last_name = ‘Doe’);   Assert(P.weight = 70);   Assert(P.height = 172);   Assert(P.age = 35);   Memo2.Lines.Add(‘Success’) end;

Read More

Learn How To Solve The C++ SFINAE Problem For Expressions In Windows Development With C++ Builder

Substitution failure is not an error (SFINAE) refers to a situation in C++ where an invalid substitution of template parameters is not in itself an error. We’re talking here about something related to templates, template substitution rules and metaprogramming… A quick example: template struct A {}; char xxx(int); char xxx(float); template A f(T){} int main() { f(1); }   template <int I> struct A {};     char xxx(int);   char xxx(float);     template <class T> A<sizeof(xxx((T)0))> f(T){}     int main()   {     f(1);   } This example is rejected by all major compilers because template deduction/substitution has historically used a simplified model of semantic checking, i.e., the SFINAE rules (which are mostly about types), instead of full semantic checking. But in C++ 11, fully general expressions allowed, and that most errors in such expressions be treated as SFINAE failures rather than errors. There’s a continuum of errors, some errors being clearly SFINAE failures, and some clearly “real” errors, with lots of unclear cases in between. We decided it’s easier to write the definition by listing the errors that are not treated as SFINAE failures, and the list we came up with is as follows: errors that occur while processing some entity external to the expression, e.g., an instantiation of a template or the generation of the definition of an implicitly-declared copy constructor. errors due to implementation limits (it’s probably a category error to list these here, since they’re not errors in the normal sense, but we wanted to make it very clear that compilers don’t have to take steps to capture and recover from violations of implementation limits; such violations cause hard errors, compiler crashes, etc., the same as anywhere else in a program). errors due to access violations (this is a judgment call, but the philosophy of access has always been that it doesn’t affect visibility)Everything else produces a SFINAE failure rather than a hard error. At certain points in the template argument deduction process it is is necessary to take a function type that makes use of template parameters and replace those template parameters with the corresponding template arguments. This is done at the beginning of template argument deduction when any explicitly specified template arguments are substituted into the function type, and again at the end of template argument deduction when any template arguments that were deduced or obtained from default arguments are substituted. The substitution occurs in all types and expressions that are used in the function type and in template parameter declarations. The expressions include not only constant expressions such as those that appear in array bounds or as nontype template arguments but also general expressions (i.e., non-constant expressions) inside sizeof, decltype, and other contexts that allow non-constant expressions. [Note: The equivalent substitution in exception specifications is done only when the function is instantiated, at which point a program is ill-formed if the substitution results in an invalid type or expression.] For example, template auto f(T t1, T t2) -> decltype(t1 + t2); template <class T> auto f(T t1, T t2) -> decltype(t1 + t2); Head over and check out more information about SFINAE problems for expressions in Windows Development.

Read More

TMS WEB Core v1.6 beta in a nutshell (video)

Yesterday we announced the beta release for TMS WEB Core v1.6 Pesaro. Before moving to a final release of TMS WEB Core v1.6.0.0, we want to give our registered TMS ALL-ACCESS and TMS WEB Core users sufficient time to test the new version. Registered users can find the beta download now on the “My Products” page on our website. This beta version can be used from Delphi XE7 to Delphi 10.4 Sydney as well as Lazarus 2.0.10. At the same time our team is also working on bringing the pas2js v2.0 compiler to TMS WEB Core for Visual Studio Code. The stunning new pas2js v2.0 features are not only coming in Delphi but also in Visual Studio Code. Watch our colleague Holger Flick show the use of generics in a TMS WEB Core application in an internal beta of TMS WEB Core for Visual Studio Code that will soon also be coming to you. Dali’s words: “Have no fear of perfection, you will never reach it” are the motivating force and inspiration behind everything we do. So, here we literally follow up the video about generics in TMS WEB Core with code improvement suggestions that bring it one step closer to perfection: enumerators. Stay tuned for more updates!

Read More

TMS WEB Core v1.6 beta brings the pas2js v2.0 quantum leap

The past couple of months and especially weeks have been a nerve-racking ride! Nerve-racking because the scope of introducing the new pas2js v2.0 compiler in TMS WEB Core is huge. Our code library that works with TMS WEB Core and the pas2js compiler meanwhile got huge, so there is a lot of testing and polishing involved to ensure everything continues to work smoothly with the new compiler. But also nerve-racking because the new compiler offers so many exciting features we are eager to take advantage of.But well, we think we have reached the level of stability where we can offer a beta release for our TMS WEB Core users that should work smooth out of the box and ready to take advantage of the new amazing features! The new pas2js v2.0 compiler is nothing short of amazing and a quantum leap forward for Object Pascal developers to tackle the most challenging rich web client application developments! And it is not just the compiler itself, it is of course also the supporting RTL for features such as generics. What an honor and experience to work so closely together with the two masterminds of the project Mattias Gaertner and Michael Van Canneyt to bring TMS WEB Core with pas2js v2.0 to life. The list of new features in the pas2js v2.0 compiler is long and can be consulted in detail here but let me highlight the major new capabilities: Generics Attributes Class constructors Resource strings Async procedure decorator Await support JavaScript promises support Best of all, we expect the introduction of this huge step forward to be smooth. All our demos for example continue to work without changing any line of code. Unless you did perhaps very specific things directly with underlying JavaScript objects or event handlers, the new version should be fully backwards compatible. Before moving to a final release of TMS WEB Core v1.6.0.0, we want to give you, users of TMS ALL-ACCESS or TMS WEB Core sufficient time to test the new version, give your feedback, address issues in case these would arise. You can find the beta download now on the “My Products” page on your account on our website. This beta version can be used from Delphi XE7 to Delphi 10.4 Sydney as well as Lazarus 2.0.10. At the same time our team is feverishly working on bringing the pas2js v2.0 compiler also to TMS WEB Core for Visual Studio Code. The challenge is even bigger here as we need to test and validate everything on 3 different operating systems as you can use TMS WEB Core for Visual Studio Code directly on Windows, macOS and Linux to build Object Pascal based web client applications. Expect also here that a beta will follow shortly! Oh, and by the way, TMS WEB Core v1.6 will be get the name Pesaro. Pesaro is the town along the legendary Mille Miglia 1955 race after Rimini that was the name of version v1.5. So, our race with TMS WEB Core enjoys the beautiful scenery of Pesaro.

Read More

GXT 4.0.4 Patch Release is Available

December 8, 2020 | Kirti Joshi The Sencha team would like to announce the availability of GXT 4.0.4 software patch release for our customers on maintenance. This release addresses more than a dozen customer reported tickets spanning improvements in the grid component, layout, selection, and more. Review the full list in our GXT 4.0.4 Release Notes and download this latest release from the Sencha support portal. If you have any questions, get in touch with our support team.    Developing Apps in Java?   Then GXT might be the right choice for you! GXT is a comprehensive Java framework for building web apps using Google Web Toolkit. Easily write code in Java and compile it into highly optimized HTML5 code. Try GXT for Free The fully featured GXT is available for you to try for 30-days, free of charge! See how the complete library of 140+ UI components can speed your development cycles! Download GXT 30-day free trial

Read More

A Peek at the Many New and Exciting Data Grid Features in Ext JS 7.4

The entire Sencha team is hard at work getting Ext JS 7.4 release complete and in your hands. We plan to have this out pretty soon, but wanted to take this opportunity to provide you with the details of the several new features (yes, there are many, and you won’t be disappointed!) that the release brings.*Please note that features are not committed until completed and GA released.* So here we go … Ext JS 7.4 includes new Data Grid features and addresses some solid improvements and enhancements to both Classic and Modern Toolkits. Multi-level Grouping Group data on multiple levels with the advanced Multi-Grouping feature. Easily add one or more desired fields to the group and the Grid Panel can display the data based on that grouping. Here is an example of a header menu that allows users to change grouping on the fly. Multi-level Grouping for Ext JS Classic Toolkit   Multi-level Grouping for Ext JS Modern Toolkit   Grouping Panel The Grouping Panel allows users to drag-and-drop the desired columns to the grouping panel section. Use this feature to quickly perform operations such as sort, remove, move or change the order of the grouped fields. Grouping Panel for Ext JS Classic Toolkit   Grouping Panel for Ext JS Modern Toolkit   Summaries for Grid Groups and Total The new Grid Summary feature will allow users to define functions for aggregation such as Sum, Min, Max, Average, Count, and more for each column. The feature also allows users to set the position of the group summary for easy viewing.Available for Classic and Modern Toolkit   Filterbar We are adding a new docked bar under the grid headers which will allow the filtered fields and configurations for each column to be easily viewable. The feature will be present in both toolkits. New KitchenSink Examples We’ll be adding new Grid examples to demonstrate how to configure and use the cool new Grid features in Ext JS 7.4. Coming soon! Other Enhancements Ext JS 7.4 will address over a dozen other enhancements and improvements that will benefit all our users. We know you are eagerly waiting to try out these new enhancements. Our team is working hard to get these coveted Grid features to you.*Please note that features are not committed until completed and GA released.*Stay tuned for release updates coming soon! New Data Grid Examples In the meantime, check out this brand new collection of interactive Grid examples and see how you could use them to enhance your application. Grid Classic Examples                         Grid Modern Examples If you haven’t already, check out the performant Ext JS Grid in action with this Interactive Grid Performance Analyzer Haven’t tried Ext JS Data Grid yet? Try a 30-day free trial of Ext JS and check out the power and scalability of the Ext JS Grid for yourself. Ext JS trial is available via public npm or through an easy zip download. Get started and build your first app in 3 easy steps. Download Ext JS 30-day free trialGet a snapshot of the Grid FeaturesExplore More Learning Materials Lock in Your 7.4 Presale Discount Time is ticking, don’t wait to grab your presale discount. Contact your account manager to unlock you discount or get […]

Read More