Skip to content
Projects
Groups
Snippets
Help
Loading...
Sign in
Toggle navigation
D
dlib
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
钟尚武
dlib
Commits
636144d5
Commit
636144d5
authored
Jan 29, 2012
by
Davis King
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Added the pad_int_with_zeros() function.
parent
7ec5fc07
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
27 additions
and
0 deletions
+27
-0
string.h
dlib/string/string.h
+14
-0
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