Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
K
KenPanCS
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Boards
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
QCD
Tools
KenPanCS
Commits
c95477a8
Commit
c95477a8
authored
May 08, 2022
by
AP matsuo koji
😲
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
引数解析整理 getValue()
parent
f236a640
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
25 additions
and
18 deletions
+25
-18
Program.cs
CSRender/Program.cs
+25
-18
No files found.
CSRender/Program.cs
View file @
c95477a8
...
@@ -34,7 +34,7 @@ namespace CSRenderMain {
...
@@ -34,7 +34,7 @@ namespace CSRenderMain {
[
DataMember
]
[
DataMember
]
public
string
pdfPathRef
=
""
;
//比較ファイル
public
string
pdfPathRef
=
""
;
//比較ファイル
[
DataMember
]
[
DataMember
]
public
string
out
up
tImageDir
=
""
;
// /O
public
string
out
pu
tImageDir
=
""
;
// /O
[
DataMember
]
[
DataMember
]
public
string
dpi
=
"72.0"
;
// /D
public
string
dpi
=
"72.0"
;
// /D
[
DataMember
]
[
DataMember
]
...
@@ -193,8 +193,16 @@ For more information,see /H /? or /?
...
@@ -193,8 +193,16 @@ For more information,see /H /? or /?
}
}
//大文字小文字無視でオプションチェック
//大文字小文字無視でオプションチェック
var
eIgnoreCase
=
StringComparer
.
OrdinalIgnoreCase
;
var
eIgnoreCase
=
StringComparer
.
OrdinalIgnoreCase
;
//
オプションチェックローカル関数
//
ローカル関数:オプションチェック
bool
isOpt
(
params
string
[]
opts
)
=>
opts
.
Contains
<
string
>(
wd
,
eIgnoreCase
);
bool
isOpt
(
params
string
[]
opts
)
=>
opts
.
Contains
<
string
>(
wd
,
eIgnoreCase
);
// ローカル関数:オプションの値を取得
string
getValue
(
string
defaultValue
=
""
)
{
if
(
qu
.
Count
==
0
)
return
defaultValue
;
if
(
Regex
.
Match
(
qu
.
Peek
(),
$@"^[\/\-]"
).
Success
)
return
defaultValue
;
// 次のオプションキー -> 初期値を返す
return
qu
.
Dequeue
();
//値をキューから取り出す
}
// ボックスオプション辞書
// ボックスオプション辞書
var
BoxSelOptDic
=
new
Dictionary
<
string
,
string
>(
eIgnoreCase
)
{
[
"/BM"
]
=
"Media"
,
[
"/BT"
]
=
"Trim"
,
var
BoxSelOptDic
=
new
Dictionary
<
string
,
string
>(
eIgnoreCase
)
{
[
"/BM"
]
=
"Media"
,
[
"/BT"
]
=
"Trim"
,
[
"/BB"
]
=
"Bleed"
,
[
"/BC"
]
=
"Crop"
,
[
"/BB"
]
=
"Bleed"
,
[
"/BC"
]
=
"Crop"
,
...
@@ -204,34 +212,34 @@ For more information,see /H /? or /?
...
@@ -204,34 +212,34 @@ For more information,see /H /? or /?
DispHelpDetail
();
DispHelpDetail
();
return
-
1
;
return
-
1
;
}
else
if
(
isOpt
(
"/F"
,
"/Tgt"
,
"/Target"
))
{
}
else
if
(
isOpt
(
"/F"
,
"/Tgt"
,
"/Target"
))
{
pm
.
pdfPath
=
(
qu
.
Count
>
0
)
?
qu
.
Dequeue
()
:
""
;
// next word
.
pm
.
pdfPath
=
getValue
();
// next value
.
}
else
if
(
isOpt
(
"/Ref"
,
"/Reference"
))
{
}
else
if
(
isOpt
(
"/Ref"
,
"/Reference"
))
{
pm
.
pdfPathRef
=
(
qu
.
Count
>
0
)
?
qu
.
Dequeue
()
:
""
;
// next word
.
pm
.
pdfPathRef
=
getValue
();
// next value
.
}
else
if
(
isOpt
(
"/O"
,
"/Output"
))
{
}
else
if
(
isOpt
(
"/O"
,
"/Output"
))
{
pm
.
out
uptImageDir
=
(
qu
.
Count
>
0
)
?
qu
.
Dequeue
()
:
""
;
// next word
.
pm
.
out
putImageDir
=
getValue
();
// next value
.
}
else
if
(
isOpt
(
"/D"
,
"/DPI"
))
{
}
else
if
(
isOpt
(
"/D"
,
"/DPI"
))
{
pm
.
dpi
=
(
qu
.
Count
>
0
)
?
qu
.
Dequeue
()
:
""
;
// next word
.
pm
.
dpi
=
getValue
();
// next value
.
if
(!
double
.
TryParse
(
pm
.
dpi
,
out
double
dmy
))
{
if
(!
double
.
TryParse
(
pm
.
dpi
,
out
double
dmy
))
{
Console
.
WriteLine
(
$"解像度が不正です:/D
{
pm
.
dpi
}
"
);
Console
.
WriteLine
(
$"解像度が不正です:/D
{
pm
.
dpi
}
"
);
DispHelpNoArg
();
DispHelpNoArg
();
return
-
1
;
return
-
1
;
}
}
}
else
if
(
isOpt
(
"/Para"
))
{
}
else
if
(
isOpt
(
"/Para"
))
{
string
paraNum
=
(
qu
.
Count
>
0
)
?
qu
.
Dequeue
()
:
""
;
// next word
.
string
paraNum
=
getValue
();
// next value
.
if
(!
int
.
TryParse
(
paraNum
,
out
pm
.
para
))
{
if
(!
int
.
TryParse
(
paraNum
,
out
pm
.
para
))
{
Console
.
WriteLine
(
$"並行数が不正です:/para
{
paraNum
}
"
);
Console
.
WriteLine
(
$"並行数が不正です:/para
{
paraNum
}
"
);
DispHelpNoArg
();
DispHelpNoArg
();
return
-
1
;
return
-
1
;
}
}
}
else
if
(
isOpt
(
"/ParaPage"
))
{
}
else
if
(
isOpt
(
"/ParaPage"
))
{
string
paraNum
=
(
qu
.
Count
>
0
)
?
qu
.
Dequeue
()
:
""
;
// next word
.
string
paraNum
=
getValue
();
// next value
.
if
(!
int
.
TryParse
(
paraNum
,
out
pm
.
paraPage
)){
if
(!
int
.
TryParse
(
paraNum
,
out
pm
.
paraPage
)){
Console
.
WriteLine
(
$"並行数(ページスレッド数が不正です:/ParaPage
{
paraNum
}
"
);
Console
.
WriteLine
(
$"並行数(ページスレッド数が不正です:/ParaPage
{
paraNum
}
"
);
DispHelpNoArg
();
DispHelpNoArg
();
return
-
1
;
return
-
1
;
}
}
}
else
if
(
isOpt
(
"/P"
,
"/Page"
))
{
}
else
if
(
isOpt
(
"/P"
,
"/Page"
))
{
pm
.
pageRange
=
(
qu
.
Count
>
0
)
?
qu
.
Dequeue
()
:
""
;
// next word
.
pm
.
pageRange
=
getValue
();
// next value
.
}
else
if
(
isOpt
(
"/JPG"
,
"/JPEG"
))
{
}
else
if
(
isOpt
(
"/JPG"
,
"/JPEG"
))
{
pm
.
imageType
=
"JPG"
;
pm
.
imageType
=
"JPG"
;
}
else
if
(
isOpt
(
"/PNG"
))
{
}
else
if
(
isOpt
(
"/PNG"
))
{
...
@@ -243,7 +251,7 @@ For more information,see /H /? or /?
...
@@ -243,7 +251,7 @@ For more information,see /H /? or /?
}
else
if
(
isOpt
(
"/BMP"
))
{
}
else
if
(
isOpt
(
"/BMP"
))
{
pm
.
imageType
=
"BMP"
;
pm
.
imageType
=
"BMP"
;
}
else
if
(
isOpt
(
"/JPEGQ"
))
{
}
else
if
(
isOpt
(
"/JPEGQ"
))
{
pm
.
jpegQ
=
(
qu
.
Count
>
0
)
?
qu
.
Dequeue
()
:
""
;
// next word
.
pm
.
jpegQ
=
getValue
();
// next value
.
if
(!
int
.
TryParse
(
pm
.
jpegQ
,
out
int
dmy
))
{
if
(!
int
.
TryParse
(
pm
.
jpegQ
,
out
int
dmy
))
{
Console
.
WriteLine
(
$"JPEG Qualityが不正です:/JPEGQ
{
pm
.
jpegQ
}
"
);
Console
.
WriteLine
(
$"JPEG Qualityが不正です:/JPEGQ
{
pm
.
jpegQ
}
"
);
DispHelpNoArg
();
DispHelpNoArg
();
...
@@ -254,7 +262,7 @@ For more information,see /H /? or /?
...
@@ -254,7 +262,7 @@ For more information,see /H /? or /?
return
-
1
;
return
-
1
;
}
}
}
else
if
(
isOpt
(
"/M"
))
{
}
else
if
(
isOpt
(
"/M"
))
{
pm
.
mode
=
(
qu
.
Count
>
0
)
?
qu
.
Dequeue
()
:
""
;
// next word
.
pm
.
mode
=
getValue
();
// next value
.
}
else
if
(
BoxSelOptDic
.
ContainsKey
(
wd
))
{
}
else
if
(
BoxSelOptDic
.
ContainsKey
(
wd
))
{
pm
.
boxSelect
=
BoxSelOptDic
[
wd
];
// "/BT" -> "Trim",...
pm
.
boxSelect
=
BoxSelOptDic
[
wd
];
// "/BT" -> "Trim",...
}
else
if
(
isOpt
(
"/HASH"
))
{
}
else
if
(
isOpt
(
"/HASH"
))
{
...
@@ -266,7 +274,7 @@ For more information,see /H /? or /?
...
@@ -266,7 +274,7 @@ For more information,see /H /? or /?
pm
.
bFC
=
true
;
pm
.
bFC
=
true
;
}
else
if
(
isOpt
(
"/PDFium"
))
{
}
else
if
(
isOpt
(
"/PDFium"
))
{
pm
.
bPDFium
=
true
;
pm
.
bPDFium
=
true
;
var
flgStr
=
(
qu
.
Count
>
0
)
?
qu
.
Dequeue
()
:
""
;
// next word
.
var
flgStr
=
getValue
();
// next value
.
if
(!
int
.
TryParse
(
flgStr
,
out
int
dmy
))
{
if
(!
int
.
TryParse
(
flgStr
,
out
int
dmy
))
{
Console
.
WriteLine
(
$"PDFiumフラグが不正です:/PDFium
{
flgStr
}
"
);
Console
.
WriteLine
(
$"PDFiumフラグが不正です:/PDFium
{
flgStr
}
"
);
return
-
1
;
return
-
1
;
...
@@ -280,11 +288,11 @@ For more information,see /H /? or /?
...
@@ -280,11 +288,11 @@ For more information,see /H /? or /?
return
-
1
;
return
-
1
;
}
}
}
else
if
(
isOpt
(
"/Verbose"
))
{
}
else
if
(
isOpt
(
"/Verbose"
))
{
var
arg
=
(
qu
.
Count
>
0
)
?
(!
qu
.
Peek
().
StartsWith
(
"/"
)?
qu
.
Dequeue
()
:
"True"
)
:
"True"
;
// next word
.
var
arg
=
getValue
(
"True"
);
// next value
.
string
[]
sel
=
{
"True"
,
"1"
,
"ON"
};
string
[]
sel
=
{
"True"
,
"1"
,
"ON"
};
pm
.
bVerbose
=
sel
.
Contains
(
arg
,
eIgnoreCase
);
pm
.
bVerbose
=
sel
.
Contains
(
arg
,
eIgnoreCase
);
}
else
if
(
isOpt
(
"/SubExe"
))
{
}
else
if
(
isOpt
(
"/SubExe"
))
{
pm
.
subExe
=
(
qu
.
Count
>
0
)
?
qu
.
Dequeue
()
:
null
;
// next word
.
pm
.
subExe
=
getValue
(
null
);
// next value
.
var
sp
=
pm
.
subExe
.
Split
(
':'
);
var
sp
=
pm
.
subExe
.
Split
(
':'
);
if
(
sp
.
Length
<
2
)
{
if
(
sp
.
Length
<
2
)
{
Console
.
WriteLine
(
$"SubExe指定は\":\"区切りが必要:
{
pm
.
subExe
}
"
);
Console
.
WriteLine
(
$"SubExe指定は\":\"区切りが必要:
{
pm
.
subExe
}
"
);
...
@@ -293,7 +301,7 @@ For more information,see /H /? or /?
...
@@ -293,7 +301,7 @@ For more information,see /H /? or /?
}
else
if
(
isOpt
(
"/NoExeSepa"
))
{
}
else
if
(
isOpt
(
"/NoExeSepa"
))
{
pm
.
bExeSepa
=
false
;
pm
.
bExeSepa
=
false
;
}
else
if
(
isOpt
(
"/RESULT"
))
{
}
else
if
(
isOpt
(
"/RESULT"
))
{
pm
.
resultPath
=
(
qu
.
Count
>
0
)
?
qu
.
Dequeue
()
:
""
;
// next word
.
pm
.
resultPath
=
getValue
(
""
);
// next value
.
}
else
if
(
wd
.
First
()
==
'/'
)
{
}
else
if
(
wd
.
First
()
==
'/'
)
{
// 処理の無いオプションを明示的に無視する
// 処理の無いオプションを明示的に無視する
Console
.
WriteLine
(
$"Warning::Ignore opt:
{
wd
}
"
);
Console
.
WriteLine
(
$"Warning::Ignore opt:
{
wd
}
"
);
...
@@ -310,7 +318,6 @@ For more information,see /H /? or /?
...
@@ -310,7 +318,6 @@ For more information,see /H /? or /?
}
}
}
}
// ↑引数解析終わり
// ↑引数解析終わり
setEcho
(
pm
.
bVerbose
);
setEcho
(
pm
.
bVerbose
);
if
(
pm
.
bVerbose
)
if
(
pm
.
bVerbose
)
echo
(
"Varbose Mode!"
);
echo
(
"Varbose Mode!"
);
...
@@ -418,7 +425,7 @@ For more information,see /H /? or /?
...
@@ -418,7 +425,7 @@ For more information,see /H /? or /?
}
}
}
}
var
watch
=
System
.
Diagnostics
.
Stopwatch
.
StartNew
();
// 時間の生成と計測開始を同時に行う
var
watch
=
System
.
Diagnostics
.
Stopwatch
.
StartNew
();
// 時間の生成と計測開始を同時に行う
var
otDir
=
pm
.
out
up
tImageDir
;
var
otDir
=
pm
.
out
pu
tImageDir
;
if
(
otDir
==
""
)
{
if
(
otDir
==
""
)
{
if
(
bDir
)
{
if
(
bDir
)
{
var
suffix
=
pm
.
bFC
?
".DiffImage"
:
".IMG"
;
var
suffix
=
pm
.
bFC
?
".DiffImage"
:
".IMG"
;
...
@@ -431,7 +438,7 @@ For more information,see /H /? or /?
...
@@ -431,7 +438,7 @@ For more information,see /H /? or /?
// 出力ディレクトリの作成 // 元PDFの同一フォルダにIMGフォルダを作成する
// 出力ディレクトリの作成 // 元PDFの同一フォルダにIMGフォルダを作成する
otDir
=
Path
.
Combine
(
Directory
.
GetParent
(
pm
.
pdfPath
).
FullName
,
"IMG"
);
otDir
=
Path
.
Combine
(
Directory
.
GetParent
(
pm
.
pdfPath
).
FullName
,
"IMG"
);
}
}
pm
.
out
up
tImageDir
=
otDir
;
// pmに戻す
pm
.
out
pu
tImageDir
=
otDir
;
// pmに戻す
}
}
var
otHashPath
=
""
;
var
otHashPath
=
""
;
var
otHashPath2
=
""
;
var
otHashPath2
=
""
;
...
...
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