Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
G
Gruppe44-PROG1003-2022
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Requirements
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Locked files
Build
Pipelines
Jobs
Pipeline schedules
Test cases
Artifacts
Deploy
Releases
Package registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Code review analytics
Issue analytics
Insights
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Andreas Blakli
Gruppe44-PROG1003-2022
Commits
80c0edf9
Commit
80c0edf9
authored
3 years ago
by
Andreas Blakli
Browse files
Options
Downloads
Patches
Plain Diff
La til doxygen kommentarer for alle funksjonene i hjelpeFunksjoner.cpp.
La til kommentar i hjelpeFunksjoner.h.
parent
89461f92
No related branches found
No related tags found
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
hjelpeFunksjoner.cpp
+47
-2
47 additions, 2 deletions
hjelpeFunksjoner.cpp
hjelpeFunksjoner.h
+4
-0
4 additions, 0 deletions
hjelpeFunksjoner.h
with
51 additions
and
2 deletions
hjelpeFunksjoner.cpp
+
47
−
2
View file @
80c0edf9
...
...
@@ -2,6 +2,12 @@
using
namespace
std
;
/**
* Fjerner uønskede tegn fra en string.
*
* @param str - Stringen som skal renses.
* @return string - Renset streng.
*/
string
HjelpeFunksjoner
::
rensStreng
(
const
string
str
)
{
string
rensetStreng
,
tmp
,
tmp2
;
int
i
=
0
;
...
...
@@ -45,6 +51,13 @@ string HjelpeFunksjoner::rensStreng(const string str) {
return
rensetStreng
;
}
/**
* Sjekker om en streng inneholder ulovlige/uønskede tegn.
*
* @param str - Strngen som skal sjekkes.
* @return true - Hvis strengen har ulovlige tegn.
* @return false - Hvis strengen ikke har noen ulovlige tegn.
*/
bool
HjelpeFunksjoner
::
sjekkForUlovligTegn
(
const
string
str
)
{
regex
re
(
"[^ÆØÅæøåa-zA-Z0-9 ]"
);
if
(
regex_search
(
str
,
re
))
{
...
...
@@ -55,6 +68,13 @@ bool HjelpeFunksjoner::sjekkForUlovligTegn(const string str) {
return
false
;
}
/**
* Sjekker om en streng inneholder alfanumeriske tegn.
*
* @param str - Stringen som skal sjekkes.
* @return true - Hvis den innholder en eller flere bokstaver.
* @return false - Hvis den ikke inneholder noen bokstaver.
*/
bool
HjelpeFunksjoner
::
erBokstav
(
const
string
str
)
{
auto
it
=
find_if
(
str
.
begin
(),
str
.
end
(),
[](
const
char
&
val
)
{
return
isalpha
(
val
)
==
true
;
});
...
...
@@ -66,6 +86,12 @@ bool HjelpeFunksjoner::erBokstav(const string str) {
return
false
;
}
/**
* Gjør om alle bokstaver i en streng til Store bokstaver.
*
* @param str - Stringen som skal endres.
* @return string - Endret streng.
*/
string
HjelpeFunksjoner
::
gjorOmTilStorBokstav
(
const
string
&
str
)
{
string
tmp
=
""
;
for
(
const
auto
&
val
:
str
)
{
...
...
@@ -74,6 +100,13 @@ string HjelpeFunksjoner::gjorOmTilStorBokstav(const string& str) {
return
tmp
;
}
/**
* Splitter en streng på char'en gitt som input parameter.
*
* @param splittPa - Tegnet stringen skal splittes på.
* @param str - Stringen som skal splittes.
* @return vector<string> - Splittet streng.
*/
vector
<
string
>
HjelpeFunksjoner
::
splittStreng
(
const
char
&
splittPa
,
const
string
&
str
)
{
vector
<
string
>
split
;
string
tmp
=
""
;
...
...
@@ -88,6 +121,12 @@ vector<string> HjelpeFunksjoner::splittStreng(const char& splittPa, const string
return
split
;
}
/**
* Legger til 0 foran time og minutt hvis de er lavere enn 9.
*
* @param time - Time.
* @param min - Minutt(er).
*/
void
HjelpeFunksjoner
::
skrivKlokkeslett
(
const
int
&
time
,
const
int
&
min
)
{
if
(
time
<=
9
)
cout
<<
"0"
<<
time
;
...
...
@@ -100,7 +139,13 @@ void HjelpeFunksjoner::skrivKlokkeslett(const int& time, const int& min) {
cout
<<
min
;
}
// Basert på Frodes lesInt() funk fra lesData3.cpp
/**
* Basert på Frodes lesInt() funk fra lesData3.cpp
*
* Leser inn en int, looper helt til et tall tastes inn.
*
* @return int - Inntastet tall.
*/
int
HjelpeFunksjoner
::
lesTall
()
{
char
buffer
[
MAX_CHAR
]
=
""
;
int
tall
=
0
;
...
...
@@ -112,7 +157,7 @@ int HjelpeFunksjoner::lesTall() {
tall
=
atoi
(
buffer
);
if
(
tall
==
0
&&
buffer
[
0
]
!=
'0'
)
{
feil
=
true
;
std
::
cout
<<
"
\n
Error: Ikke et tall!"
<<
'\n'
;
cout
<<
"
\n
Error: Ikke et tall!"
<<
'\n'
;
}
}
while
(
feil
);
...
...
This diff is collapsed.
Click to expand it.
hjelpeFunksjoner.h
+
4
−
0
View file @
80c0edf9
...
...
@@ -9,6 +9,10 @@
#include
"konstanter.h"
/**
* HjelpeFunksjoner klasse.
*
*/
class
HjelpeFunksjoner
{
public:
std
::
string
rensStreng
(
std
::
string
str
);
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment