-
Notifications
You must be signed in to change notification settings - Fork 10
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
7 changed files
with
484 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,192 @@ | ||
## Ignore Visual Studio temporary files, build results, and | ||
## files generated by popular Visual Studio add-ons. | ||
|
||
build | ||
|
||
# User-specific files | ||
*.suo | ||
*.user | ||
*.sln.docstates | ||
|
||
# Build results | ||
[Dd]ebug/ | ||
[Dd]ebugPublic/ | ||
[Rr]elease/ | ||
x64/ | ||
build/ | ||
bld/ | ||
[Bb]in/ | ||
[Oo]bj/ | ||
|
||
# MSTest test Results | ||
[Tt]est[Rr]esult*/ | ||
[Bb]uild[Ll]og.* | ||
|
||
#NUNIT | ||
*.VisualState.xml | ||
TestResult.xml | ||
|
||
# Build Results of an ATL Project | ||
[Dd]ebugPS/ | ||
[Rr]eleasePS/ | ||
dlldata.c | ||
|
||
*_i.c | ||
*_p.c | ||
*_i.h | ||
*.ilk | ||
*.meta | ||
*.obj | ||
*.pch | ||
*.pdb | ||
*.pgc | ||
*.pgd | ||
*.rsp | ||
*.sbr | ||
*.tlb | ||
*.tli | ||
*.tlh | ||
*.tmp | ||
*.tmp_proj | ||
*.log | ||
*.vspscc | ||
*.vssscc | ||
.builds | ||
*.pidb | ||
*.svclog | ||
*.scc | ||
|
||
# Chutzpah Test files | ||
_Chutzpah* | ||
|
||
# Visual C++ cache files | ||
ipch/ | ||
*.aps | ||
*.ncb | ||
*.opensdf | ||
*.sdf | ||
*.cachefile | ||
|
||
# Visual Studio profiler | ||
*.psess | ||
*.vsp | ||
*.vspx | ||
|
||
# TFS 2012 Local Workspace | ||
$tf/ | ||
|
||
# Guidance Automation Toolkit | ||
*.gpState | ||
|
||
# ReSharper is a .NET coding add-in | ||
_ReSharper*/ | ||
*.[Rr]e[Ss]harper | ||
*.DotSettings.user | ||
|
||
# JustCode is a .NET coding addin-in | ||
.JustCode | ||
|
||
# TeamCity is a build add-in | ||
_TeamCity* | ||
|
||
# DotCover is a Code Coverage Tool | ||
*.dotCover | ||
|
||
# NCrunch | ||
*.ncrunch* | ||
_NCrunch_* | ||
.*crunch*.local.xml | ||
|
||
# MightyMoose | ||
*.mm.* | ||
AutoTest.Net/ | ||
|
||
# Web workbench (sass) | ||
.sass-cache/ | ||
|
||
# Installshield output folder | ||
[Ee]xpress/ | ||
|
||
# DocProject is a documentation generator add-in | ||
DocProject/buildhelp/ | ||
DocProject/Help/*.HxT | ||
DocProject/Help/*.HxC | ||
DocProject/Help/*.hhc | ||
DocProject/Help/*.hhk | ||
DocProject/Help/*.hhp | ||
DocProject/Help/Html2 | ||
DocProject/Help/html | ||
|
||
# Click-Once directory | ||
publish/ | ||
|
||
# Publish Web Output | ||
*.[Pp]ublish.xml | ||
*.azurePubxml | ||
|
||
# NuGet Packages Directory | ||
packages/ | ||
## TODO: If the tool you use requires repositories.config uncomment the next line | ||
#!packages/repositories.config | ||
|
||
# Enable "build/" folder in the NuGet Packages folder since NuGet packages use it for MSBuild targets | ||
# This line needs to be after the ignore of the build folder (and the packages folder if the line above has been uncommented) | ||
!packages/build/ | ||
|
||
# Windows Azure Build Output | ||
csx/ | ||
*.build.csdef | ||
|
||
# Windows Store app package directory | ||
AppPackages/ | ||
|
||
# Others | ||
sql/ | ||
*.Cache | ||
ClientBin/ | ||
[Ss]tyle[Cc]op.* | ||
~$* | ||
*~ | ||
*.dbmdl | ||
*.dbproj.schemaview | ||
*.pfx | ||
*.publishsettings | ||
node_modules/ | ||
|
||
# RIA/Silverlight projects | ||
Generated_Code/ | ||
|
||
# Backup & report files from converting an old project file to a newer | ||
# Visual Studio version. Backup files are not needed, because we have git ;-) | ||
_UpgradeReport_Files/ | ||
Backup*/ | ||
UpgradeLog*.XML | ||
UpgradeLog*.htm | ||
|
||
# SQL Server files | ||
*.mdf | ||
*.ldf | ||
|
||
# Business Intelligence projects | ||
*.rdl.data | ||
*.bim.layout | ||
*.bim_*.settings | ||
|
||
# Microsoft Fakes | ||
FakesAssemblies/ | ||
|
||
# cmake folders | ||
cmake/ALL_BUILD.vcxproj | ||
cmake/ALL_BUILD.vcxproj.filters | ||
cmake/CMakeCache.txt | ||
cmake/CMakeFiles/ | ||
cmake/Project.sln | ||
cmake/ZERO_CHECK.vcxproj | ||
cmake/ZERO_CHECK.vcxproj.filters | ||
cmake/cmake_install.cmake | ||
cmake/cvImagePipeline.vcxproj | ||
cmake/cvImagePipeline.vcxproj.filters | ||
cmake/sample.vcxproj | ||
cmake/sample.vcxproj.filters | ||
cmake/test.vcxproj | ||
cmake/test.vcxproj.filters |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
cmake_minimum_required(VERSION 2.8) | ||
project( win-c ) | ||
set(SOURCES source/getopt.c) | ||
include_directories( include ) | ||
add_library(libwinc ${SOURCES}) | ||
add_executable(test test/test.cpp) | ||
target_link_libraries(test libwinc) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,95 @@ | ||
win-c | ||
============ | ||
|
||
C/C++から使えるWindowsのコンソールアプリケーション用のライブラリです。 | ||
|
||
__関数__ | ||
|
||
* getopt() - コマンドラインオプション解析 | ||
|
||
|
||
## getopt() - コマンドラインオプション解析 | ||
|
||
関数の動作は、[POSIXのgetopt](http://linuxjm.sourceforge.jp/html/LDP_man-pages/man3/getopt.3.html)にあわせているつもりです。 | ||
|
||
* argvを並べ替えることはありません。 | ||
* オプションでない引数が現れた時点で解析を終了します。 | ||
* オプションは1文字だけです。長いオプション名には対応していません。 | ||
|
||
### 使用例 | ||
|
||
以下は、C++での使い方サンプルです。 | ||
|
||
``` | ||
#include <iostream> | ||
#include "getopt.h" | ||
using namespace std; | ||
int main(int argc, char* argv[]) { | ||
//オプションの定義。a, b, c, dで、bとcは引数を取る | ||
// -a | ||
// -b <opt_b_arg> | ||
// -c <opt_c_arg> | ||
// -d | ||
char const * optstring = "ab:c:d"; | ||
int opt_a = 0; | ||
char* opt:w | ||
_b = 0; | ||
char* opt_c = 0; | ||
int opt_d = 0; | ||
//オプションの解析 | ||
int opt = 0; | ||
while((opt = getopt(argc, argv, optstring)) != -1) { | ||
switch(opt) { | ||
case 'a': | ||
opt_a = 1; | ||
break; | ||
case 'b': | ||
opt_b = optarg; | ||
break; | ||
case 'c': | ||
opt_c = optarg; | ||
break; | ||
case 'd': | ||
opt_d = 1; | ||
break; | ||
default: | ||
cerr << "unknown option." << endl; | ||
exit(-1); | ||
break; | ||
} | ||
} | ||
//オプション以外のパラメータ | ||
char* noptarg = argv[optind++]; | ||
} | ||
``` | ||
|
||
### 使い方 | ||
|
||
main関数のargc,argvとオプション定義の文字列を渡して、(-1)が返されるまで繰り返し呼び出して、オプション解析を行います。 | ||
|
||
#### オプションの定義 | ||
|
||
オプションは、オプションの文字列を並べた文字列で定義。 | ||
|
||
引数を取るオプションは、オプション文字の次にコロンを記述。 | ||
|
||
#### 戻り値 | ||
|
||
(-1)はオプション解析が終了したことを表します。 | ||
|
||
オプションが見つかるとその文字を返します。 | ||
|
||
オプションでない文字が指定されているときは、'?'が返されます。 | ||
|
||
#### オプションの引数 | ||
|
||
引数を取るオプションが見つかった場合、`optarg`がその引数を指し示しています。 | ||
|
||
#### オプション以外のコマンドラインパラメータ | ||
|
||
オプション解析が終了すると、グローバル変数 `optind` が、オプションでない最初のコマンドラインパラメータを指しています。 | ||
`optind < argc` なら、`argv[optind]`が、オプションではない最初のコマンドラインパラメータです。 | ||
`optind >= argc` なら、オプションでないパラメータはありません。 | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,44 @@ | ||
/* | ||
* getopt - POSIX like getopt for Windows console Application | ||
* | ||
* win-c - Windows Console Library | ||
* Copyright (c) 2015 Koji Takami | ||
* Released under the MIT license | ||
* https://github.com/takamin/win-c/blob/master/LICENSE | ||
*/ | ||
#ifndef _GETOPT_H_ | ||
#define _GETOPT_H_ | ||
|
||
#ifdef __cplusplus | ||
extern "C" { | ||
#endif // __cplusplus | ||
|
||
int getopt(int argc, char* const argv[], | ||
const char* optstring); | ||
|
||
extern char *optarg; | ||
extern int optind, opterr, optopt; | ||
|
||
/**************************************************************************** | ||
#define no_argument 0 | ||
#define required_argument 1 | ||
#define optional_argument 2 | ||
struct option { | ||
const char *name; | ||
int has_arg; | ||
int* flag; | ||
int val; | ||
}; | ||
int getopt_long(int argc, char* const argv[], | ||
const char* optstring, | ||
const struct option* longopts, int* longindex); | ||
int getopt_long_only(int argc, char* const argv[], | ||
const char* optstring, | ||
const struct option* longopts, int* longindex); | ||
****************************************************************************/ | ||
#ifdef __cplusplus | ||
} | ||
#endif // __cplusplus | ||
#endif // _GETOPT_H_ |
Oops, something went wrong.