Skip to content
GitLab
Menu
Projects
Groups
Snippets
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Menu
Open sidebar
OpenDAS
dlib
Commits
636144d5
"tools/python/vscode:/vscode.git/clone" did not exist on "fbe597be0380775c85c8e2f42f601529b56bf97f"
Commit
636144d5
authored
Jan 29, 2012
by
Davis King
Browse files
Added the pad_int_with_zeros() function.
parent
7ec5fc07
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
27 additions
and
0 deletions
+27
-0
dlib/string/string.h
dlib/string/string.h
+14
-0
dlib/string/string_abstract.h
dlib/string/string_abstract.h
+13
-0
No files found.
dlib/string/string.h
View file @
636144d5
...
@@ -4,9 +4,11 @@
...
@@ -4,9 +4,11 @@
#define DLIB_STRINg_
#define DLIB_STRINg_
#include "string_abstract.h"
#include "string_abstract.h"
#include <sstream>
#include "../algs.h"
#include "../algs.h"
#include <string>
#include <string>
#include <iostream>
#include <iostream>
#include <iomanip>
#include "../error.h"
#include "../error.h"
#include "../assert.h"
#include "../assert.h"
#include "../uintn.h"
#include "../uintn.h"
...
@@ -257,6 +259,18 @@ namespace dlib
...
@@ -257,6 +259,18 @@ namespace dlib
}
}
#endif
#endif
// ----------------------------------------------------------------------------------------
inline
std
::
string
pad_int_with_zeros
(
int
i
,
unsigned
long
width
=
6
)
{
std
::
ostringstream
sout
;
sout
<<
std
::
setw
(
width
)
<<
std
::
setfill
(
'0'
)
<<
i
;
return
sout
.
str
();
}
// ----------------------------------------------------------------------------------------
// ----------------------------------------------------------------------------------------
class
string_cast_error
:
public
error
class
string_cast_error
:
public
error
...
...
dlib/string/string_abstract.h
View file @
636144d5
...
@@ -113,6 +113,19 @@ namespace dlib
...
@@ -113,6 +113,19 @@ namespace dlib
item into a std::string.
item into a std::string.
!*/
!*/
// ----------------------------------------------------------------------------------------
std
::
string
pad_int_with_zeros
(
int
i
,
unsigned
long
width
=
6
);
/*!
ensures
- converts i into a string of at least width characters in length. If
necessary, the string will be padded with leading zeros to get
to width characters.
!*/
// ----------------------------------------------------------------------------------------
// ----------------------------------------------------------------------------------------
template
<
template
<
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment