Skip to content

Commit bc4b8a6

Browse files
committed
Reduce dependencies on common.h (countof).
1 parent 4abde1b commit bc4b8a6

8 files changed

Lines changed: 850 additions & 863 deletions

File tree

Application.ixx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -124,7 +124,7 @@ int Application::DisplayError(__in_z const char16_t* message, __in_z_opt const c
124124

125125
StringCchPrintf(
126126
buffer,
127-
countof(buffer),
127+
std::size(buffer),
128128
ToWChar(formatString),
129129
ToWChar(message),
130130
functionResult
@@ -150,7 +150,7 @@ void Application::DebugLog(const char16_t* logMessage, ...)
150150
buffer[0] = 0;
151151
StringCchVPrintf(
152152
buffer,
153-
countof(buffer),
153+
std::size(buffer),
154154
ToWChar(logMessage),
155155
argList
156156
);

Common.String.ixx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -385,8 +385,8 @@ void ConvertTextUtf8ToUtf16(
385385

386386
// Skip byte-order-mark.
387387
int32_t startingOffset = 0;
388-
if (utf8text.size() >= countof(utf8bom)
389-
&& memcmp(utf8text.data(), utf8bom, countof(utf8bom)) == 0)
388+
if (utf8text.size() >= std::size(utf8bom)
389+
&& memcmp(utf8text.data(), utf8bom, std::size(utf8bom)) == 0)
390390
{
391391
startingOffset = ARRAYSIZE(utf8bom);
392392
}

Common.cpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
#include "precomp.h"
66
#include <string>
77
#include <stdint.h>
8+
#include "Common.h"
89

910
import Common.String;
1011

Common.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ bool ThrowIf(bool value, _In_opt_z_ char const* message = nullptr);
2626
#define DEBUG_ASSERT assert
2727

2828
template <typename T, size_t N>
29-
constexpr size_t countof(T(&a)[N])
29+
constexpr size_t countof(const T(&a)[N])
3030
{
3131
return N;// _countof(a);
3232
}

DWritEx.ixx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99
#include "precomp.h"
1010

1111
#include <windows.h>
12-
#include <Dwrite_2.h>
12+
#include <Dwrite_3.h>
1313

1414
import Common.ArrayRef;
1515
import Common.String;

DrawableObjectAndValues.ixx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -713,7 +713,7 @@ HRESULT DrawableObjectAndValues::Set(DrawableObjectAttribute attributeIndex, _In
713713
{
714714
// Set a single attribute's value, parsing the string according to attribute data type.
715715

716-
static_assert(_countof(values_) == countof(DrawableObject::attributeList), "Attribute and value arrays differ in size.");
716+
static_assert(_countof(DrawableObjectAndValues::values_) == countof(DrawableObject::attributeList), "Attribute and value arrays differ in size.");
717717
if (attributeIndex >= countof(values_))
718718
E_INVALIDARG;
719719

TextTreeParser.h

Lines changed: 842 additions & 842 deletions
Large diffs are not rendered by default.

precomp.h

Lines changed: 0 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -147,20 +147,6 @@
147147
// Generic.
148148

149149
#include "Common.h"
150-
//!#include "Common.OptionalValue.h"
151-
//!#include "Common.AutoResource.h"
152-
//!#include "DWritEx.h"
153-
//!#include "Common.ListSubstringPrioritizer.h"
154-
155-
//////////////////////////////
156-
// Application specific.
157-
158-
//!#include "DrawingCanvas.h"
159-
//!#include "Attributes.h"
160-
//!#include "TextTreeParser.h"
161-
//!#include "DrawableObject.h"
162-
//!#include "DrawableObjectAndValues.h"
163-
//!#include "TextLayoutSampler.h"
164150

165151
void DebugLog(const wchar_t* logMessage, ...);
166152

0 commit comments

Comments
 (0)