You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: docs/cpp/implementation.md
+38-41Lines changed: 38 additions & 41 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -78,7 +78,7 @@ Note that modifying the enumerators in an enumeration is considered a breaking c
78
78
79
79
##### Extendable Enumerations
80
80
81
-
When the set of values in an enumeration is *not* fixed, the `Azure::Core::_internal::ExtendableEnumeration` template should be used.
81
+
When the set of values in an enumeration is *not* fixed, the `Azure::Core::_internal::ExtendableEnumeration` template should be used.
82
82
83
83
{% highlight cpp %}
84
84
class MyEnumeration final : public ExtendableEnumeration<MyEnumeration> {
@@ -107,6 +107,7 @@ Subtypes of `Operation<T>` are returned from service client methods invoking lon
107
107
108
108
- If an underlying service operation call from `Poll` or `PollUntilDone` throws, re-throw `RequestFailedException` or its subtype.
109
109
- If the operation completes with a non-success result, throw `RequestFailedException` or its subtype from `Poll` or `PollUntilDone`.
110
+
110
111
- Include any relevant error state information in the exception message.
111
112
112
113
- If the ```Value``` property is evaluated after the operation failed (```HasValue``` is false and ```IsDone``` is true) throw the same exception as the one thrown when the operation failed.
@@ -262,7 +263,7 @@ We believe testing is a part of the development process, so we expect unit and i
262
263
263
264
All code should contain, at least, requirements, unit tests, end-to-end tests, and samples.
264
265
265
-
Tests should be written using the [Google Test][] library.
266
+
Tests should be written using the [Google Test][https://google.github.io/googletest/] library.
{% include requirement/SHOULD id="cpp-use-cpp-core-guidelines" %} follow the [CPP Core Guidelines](https://github.com/isocpp/CppCoreGuidelines/blob/master/CppCoreGuidelines.md) whenever possible, with the following exceptions:
389
391
390
-
<TBD>
391
-
392
+
- List TBD.
392
393
393
394
#### Complexity Management
394
395
@@ -403,6 +404,8 @@ not escape from the innermost lexical scope.
403
404
404
405
{% include requirement/MUST id="cpp-use-explicit-compares" %} use explicit comparisons when testing for failure. Use `if (FAIL != f())` rather than `if (f())`, even though FAIL may have the value 0 which C considers to be false. An explicit test will help you out later when somebody decides that a failure return should be -1 instead of 0.
405
406
407
+
{% include requirement/MUSTNOT id="cpp-do-not-compare-booleans-against-true" %} compare boolean values with explicit comparisons. Rather than writing `if (f() == true)`, write `if (f())` - the result is clearer and more succinct. The same applies to objects that implement `operator bool()`
408
+
406
409
Explicit comparison should be used even if the comparison value will never change. e.g. `if (!(bufsize % sizeof(int)))` should be written as `if (0 == (bufsize % sizeof(int))` to reflect the numeric (not boolean) nature of the test.
407
410
408
411
A frequent trouble spot is using `strcmp` to test for string equality. You should **never** use a default action. The preferred approach is to use an inline function:
{% include requirement/SHOULDNOT id="cpp-embedded-assign" %} use embedded assignments. There is a time and a place for embedded assignment statements. In some constructs, there is no better way to accomplish the results without making the code bulkier and less readable.
418
422
419
423
{% highlight cpp %}
@@ -498,7 +502,6 @@ void TheCustomerCode() {
498
502
}
499
503
{% endhighlight %}
500
504
501
-
502
505
{% include requirement/MUST id="cpp-design-logical-no-getters-or-setters" %} define getters and setters for data transfer objects. Expose the members directly to users unless you need to enforce some constraints on the data. For example:
503
506
{% highlight cpp %}
504
507
// Good - no restrictions on values
@@ -535,7 +538,7 @@ public:
535
538
return m_size;
536
539
}
537
540
void AddData(int i) noexcept {
538
-
m_data\[m_size++\] = i;
541
+
m_data[m_size++] = i;
539
542
}
540
543
};
541
544
@@ -560,7 +563,7 @@ public:
560
563
{% highlight cpp %}
561
564
// Bad
562
565
struct Foo {
563
-
int A; // the compiler will insert 4 bytes of padding after A to align B
566
+
int A; // the compiler will insert up to 4 bytes of padding after A to align B
564
567
char *B;
565
568
int C;
566
569
char *D;
@@ -605,6 +608,10 @@ public:
605
608
};
606
609
{% endhighlight %}
607
610
611
+
#### Parameter passing rules
612
+
613
+
In general, all method parameters that are not POD should be passed by `const reference`.
614
+
608
615
#### Integer sizes
609
616
610
617
The following integer rules are listed in rough priority order. Integer size selections are primarily driven by service future compatibility. For example, just because today a service might have a 2 GiB file size limit does not mean that it will have such a limit forever. We believe 64 bit length limits will be sufficient for sizes an individual program works with for the foreseeable future.
* We use the `DOXYGEN_<PREF>` CMake variables instead of writing your own `doxyfile`.
847
856
* We set `OPTIMIZE_OUTPUT_FOR_C` in order to get more C appropriate output.
@@ -859,39 +868,27 @@ endif()
859
868
860
869
## Supported platforms
861
870
862
-
{% include requirement/MUST id="cpp-platform-min" %} support the following platforms and associated compilers when implementing your client library.
863
-
864
-
### Windows
871
+
{% include requirement/MUST id="cpp-platform-min" %} support at least the following platforms and associated compilers when implementing your client library:
865
872
866
-
| Operating System | Version | Architectures | Compiler Version | Notes
For a current list of supported platforms, see the [platform matrix](https://github.com/Azure/azure-sdk-for-cpp/blob/main/eng/pipelines/templates/stages/platform-matrix.json).
881
887
882
-
| Operating System | Version | Architectures | Compiler Version | Notes
| Red Hat Enterprise Linux <br> CentOS <br> Oracle Linux | 7+ | x64 | gcc-4.8 | [Red Hat lifecycle](https://access.redhat.com/support/policy/updates/errata/) <br> [CentOS lifecycle](https://www.centos.org/centos-linux-eol/) <br> [Oracle Linux lifecycle](https://www.oracle.com/us/support/library/elsp-lifetime-069338.pdf)
{% include requirement/SHOULD id="cpp-platform" %} support the following additional platforms and associated compilers when implementing your client library.
892
890
893
-
894
-
{% include requirement/SHOULDNOT id="cpp-cpp-extensions" %} use compiler extensions. Examples of extensions to avoid include:
891
+
{% include requirement/SHOULDNOT id="cpp-cpp-extensions" %} use compiler extensions. Examples of extensions to avoid include:
Copy file name to clipboardExpand all lines: docs/cpp/introduction.md
+7Lines changed: 7 additions & 0 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -675,6 +675,7 @@ NOTE: Since these types are typically located in the `azure-core` package, care
675
675
In addition, it is critical to realize that the only dependencies between Azure SDK packages is a >= dependency. That means that a particular version of an existing Azure SDK package is expected to work with any future versions of other Azure SDK packages, even of those packages on which it depends. That means that any breaking changes to internal types MUST be upward compatible.
676
676
677
677
##### Private types
678
+
678
679
Private types are types located in a `_detail` namespace. Private types are only intended to be called within a single package, and follow the following requirements:
679
680
680
681
{% include requirement/MUSTNOT id="cpp-design-private-types-private" %} define private types in public Azure SDK headers.
@@ -840,6 +841,12 @@ Filenames should be concise, but convey what role the file plays within the libr
840
841
- `<package short name>/` - eg `certificates`, `blobs`, `datalake`, etc.
841
842
- `<package specific headers>`
842
843
844
+
{% include requirement/MUST id="cpp-client-name" %} base the file name for the service client on the name of the service client.
845
+
846
+
For example, the class declaration for the `AttestationClient` class should be contained in a file named `attestation_client.hpp`.
847
+
848
+
{% include requirement/SHOULD id="cpp-docs-file-contents-exception" %} have at most one service client declaration per include file.
849
+
843
850
{% include requirement/MUST id="cpp-docs-source-layout-src" %} lay out directories under the `src` directory as follows:
0 commit comments